]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.8.6-201304111817.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.8.6-201304111817.patch
1 diff --git a/Documentation/dontdiff b/Documentation/dontdiff
2 index b89a739..b47493f 100644
3 --- a/Documentation/dontdiff
4 +++ b/Documentation/dontdiff
5 @@ -2,9 +2,11 @@
6 *.aux
7 *.bin
8 *.bz2
9 +*.c.[012]*.*
10 *.cis
11 *.cpio
12 *.csp
13 +*.dbg
14 *.dsp
15 *.dvi
16 *.elf
17 @@ -14,6 +16,7 @@
18 *.gcov
19 *.gen.S
20 *.gif
21 +*.gmo
22 *.grep
23 *.grp
24 *.gz
25 @@ -48,14 +51,17 @@
26 *.tab.h
27 *.tex
28 *.ver
29 +*.vim
30 *.xml
31 *.xz
32 *_MODULES
33 +*_reg_safe.h
34 *_vga16.c
35 *~
36 \#*#
37 *.9
38 -.*
39 +.[^g]*
40 +.gen*
41 .*.d
42 .mm
43 53c700_d.h
44 @@ -69,6 +75,7 @@ Image
45 Module.markers
46 Module.symvers
47 PENDING
48 +PERF*
49 SCCS
50 System.map*
51 TAGS
52 @@ -80,6 +87,7 @@ aic7*seq.h*
53 aicasm
54 aicdb.h*
55 altivec*.c
56 +ashldi3.S
57 asm-offsets.h
58 asm_offsets.h
59 autoconf.h*
60 @@ -92,19 +100,24 @@ bounds.h
61 bsetup
62 btfixupprep
63 build
64 +builtin-policy.h
65 bvmlinux
66 bzImage*
67 capability_names.h
68 capflags.c
69 classlist.h*
70 +clut_vga16.c
71 +common-cmds.h
72 comp*.log
73 compile.h*
74 conf
75 config
76 config-*
77 config_data.h*
78 +config.c
79 config.mak
80 config.mak.autogen
81 +config.tmp
82 conmakehash
83 consolemap_deftbl.c*
84 cpustr.h
85 @@ -115,9 +128,11 @@ devlist.h*
86 dnotify_test
87 docproc
88 dslm
89 +dtc-lexer.lex.c
90 elf2ecoff
91 elfconfig.h*
92 evergreen_reg_safe.h
93 +exception_policy.conf
94 fixdep
95 flask.h
96 fore200e_mkfirm
97 @@ -125,12 +140,15 @@ fore200e_pca_fw.c*
98 gconf
99 gconf.glade.h
100 gen-devlist
101 +gen-kdb_cmds.c
102 gen_crc32table
103 gen_init_cpio
104 generated
105 genheaders
106 genksyms
107 *_gray256.c
108 +hash
109 +hid-example
110 hpet_example
111 hugepage-mmap
112 hugepage-shm
113 @@ -145,14 +163,14 @@ int32.c
114 int4.c
115 int8.c
116 kallsyms
117 -kconfig
118 +kern_constants.h
119 keywords.c
120 ksym.c*
121 ksym.h*
122 kxgettext
123 lex.c
124 lex.*.c
125 -linux
126 +lib1funcs.S
127 logo_*.c
128 logo_*_clut224.c
129 logo_*_mono.c
130 @@ -162,14 +180,15 @@ mach-types.h
131 machtypes.h
132 map
133 map_hugetlb
134 -media
135 mconf
136 +mdp
137 miboot*
138 mk_elfconfig
139 mkboot
140 mkbugboot
141 mkcpustr
142 mkdep
143 +mkpiggy
144 mkprep
145 mkregtable
146 mktables
147 @@ -185,6 +204,8 @@ oui.c*
148 page-types
149 parse.c
150 parse.h
151 +parse-events*
152 +pasyms.h
153 patches*
154 pca200e.bin
155 pca200e_ecd.bin2
156 @@ -194,6 +215,7 @@ perf-archive
157 piggyback
158 piggy.gzip
159 piggy.S
160 +pmu-*
161 pnmtologo
162 ppc_defs.h*
163 pss_boot.h
164 @@ -203,7 +225,10 @@ r200_reg_safe.h
165 r300_reg_safe.h
166 r420_reg_safe.h
167 r600_reg_safe.h
168 +realmode.lds
169 +realmode.relocs
170 recordmcount
171 +regdb.c
172 relocs
173 rlim_names.h
174 rn50_reg_safe.h
175 @@ -213,8 +238,12 @@ series
176 setup
177 setup.bin
178 setup.elf
179 +signing_key*
180 +size_overflow_hash.h
181 sImage
182 +slabinfo
183 sm_tbl*
184 +sortextable
185 split-include
186 syscalltab.h
187 tables.c
188 @@ -224,6 +253,7 @@ tftpboot.img
189 timeconst.h
190 times.h*
191 trix_boot.h
192 +user_constants.h
193 utsrelease.h*
194 vdso-syms.lds
195 vdso.lds
196 @@ -235,13 +265,17 @@ vdso32.lds
197 vdso32.so.dbg
198 vdso64.lds
199 vdso64.so.dbg
200 +vdsox32.lds
201 +vdsox32-syms.lds
202 version.h*
203 vmImage
204 vmlinux
205 vmlinux-*
206 vmlinux.aout
207 vmlinux.bin.all
208 +vmlinux.bin.bz2
209 vmlinux.lds
210 +vmlinux.relocs
211 vmlinuz
212 voffset.h
213 vsyscall.lds
214 @@ -249,9 +283,12 @@ vsyscall_32.lds
215 wanxlfw.inc
216 uImage
217 unifdef
218 +utsrelease.h
219 wakeup.bin
220 wakeup.elf
221 wakeup.lds
222 +x509*
223 zImage*
224 zconf.hash.c
225 +zconf.lex.c
226 zoffset.h
227 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
228 index 986614d..e8bfedc 100644
229 --- a/Documentation/kernel-parameters.txt
230 +++ b/Documentation/kernel-parameters.txt
231 @@ -922,6 +922,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
232 Format: <unsigned int> such that (rxsize & ~0x1fffc0) == 0.
233 Default: 1024
234
235 + grsec_proc_gid= [GRKERNSEC_PROC_USERGROUP] Chooses GID to
236 + ignore grsecurity's /proc restrictions
237 +
238 +
239 hashdist= [KNL,NUMA] Large hashes allocated during boot
240 are distributed across NUMA nodes. Defaults on
241 for 64-bit NUMA, off otherwise.
242 @@ -2121,6 +2125,18 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
243 the specified number of seconds. This is to be used if
244 your oopses keep scrolling off the screen.
245
246 + pax_nouderef [X86] disables UDEREF. Most likely needed under certain
247 + virtualization environments that don't cope well with the
248 + expand down segment used by UDEREF on X86-32 or the frequent
249 + page table updates on X86-64.
250 +
251 + pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
252 +
253 + pax_extra_latent_entropy
254 + Enable a very simple form of latent entropy extraction
255 + from the first 4GB of memory as the bootmem allocator
256 + passes the memory pages to the buddy allocator.
257 +
258 pcbit= [HW,ISDN]
259
260 pcd. [PARIDE]
261 diff --git a/Makefile b/Makefile
262 index 10075d6..8a01f3b 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/delay.h b/arch/arm/include/asm/delay.h
1563 index 720799f..2f67631 100644
1564 --- a/arch/arm/include/asm/delay.h
1565 +++ b/arch/arm/include/asm/delay.h
1566 @@ -25,9 +25,9 @@ extern struct arm_delay_ops {
1567 void (*const_udelay)(unsigned long);
1568 void (*udelay)(unsigned long);
1569 bool const_clock;
1570 -} arm_delay_ops;
1571 +} *arm_delay_ops;
1572
1573 -#define __delay(n) arm_delay_ops.delay(n)
1574 +#define __delay(n) arm_delay_ops->delay(n)
1575
1576 /*
1577 * This function intentionally does not exist; if you see references to
1578 @@ -48,8 +48,8 @@ extern void __bad_udelay(void);
1579 * first constant multiplications gets optimized away if the delay is
1580 * a constant)
1581 */
1582 -#define __udelay(n) arm_delay_ops.udelay(n)
1583 -#define __const_udelay(n) arm_delay_ops.const_udelay(n)
1584 +#define __udelay(n) arm_delay_ops->udelay(n)
1585 +#define __const_udelay(n) arm_delay_ops->const_udelay(n)
1586
1587 #define udelay(n) \
1588 (__builtin_constant_p(n) ? \
1589 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1590 index 6ddbe44..b5e38b1 100644
1591 --- a/arch/arm/include/asm/domain.h
1592 +++ b/arch/arm/include/asm/domain.h
1593 @@ -48,18 +48,37 @@
1594 * Domain types
1595 */
1596 #define DOMAIN_NOACCESS 0
1597 -#define DOMAIN_CLIENT 1
1598 #ifdef CONFIG_CPU_USE_DOMAINS
1599 +#define DOMAIN_USERCLIENT 1
1600 +#define DOMAIN_KERNELCLIENT 1
1601 #define DOMAIN_MANAGER 3
1602 +#define DOMAIN_VECTORS DOMAIN_USER
1603 #else
1604 +
1605 +#ifdef CONFIG_PAX_KERNEXEC
1606 #define DOMAIN_MANAGER 1
1607 +#define DOMAIN_KERNEXEC 3
1608 +#else
1609 +#define DOMAIN_MANAGER 1
1610 +#endif
1611 +
1612 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1613 +#define DOMAIN_USERCLIENT 0
1614 +#define DOMAIN_UDEREF 1
1615 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1616 +#else
1617 +#define DOMAIN_USERCLIENT 1
1618 +#define DOMAIN_VECTORS DOMAIN_USER
1619 +#endif
1620 +#define DOMAIN_KERNELCLIENT 1
1621 +
1622 #endif
1623
1624 #define domain_val(dom,type) ((type) << (2*(dom)))
1625
1626 #ifndef __ASSEMBLY__
1627
1628 -#ifdef CONFIG_CPU_USE_DOMAINS
1629 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1630 static inline void set_domain(unsigned val)
1631 {
1632 asm volatile(
1633 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1634 isb();
1635 }
1636
1637 -#define modify_domain(dom,type) \
1638 - do { \
1639 - struct thread_info *thread = current_thread_info(); \
1640 - unsigned int domain = thread->cpu_domain; \
1641 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1642 - thread->cpu_domain = domain | domain_val(dom, type); \
1643 - set_domain(thread->cpu_domain); \
1644 - } while (0)
1645 -
1646 +extern void modify_domain(unsigned int dom, unsigned int type);
1647 #else
1648 static inline void set_domain(unsigned val) { }
1649 static inline void modify_domain(unsigned dom, unsigned type) { }
1650 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1651 index 38050b1..9d90e8b 100644
1652 --- a/arch/arm/include/asm/elf.h
1653 +++ b/arch/arm/include/asm/elf.h
1654 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1655 the loader. We need to make sure that it is out of the way of the program
1656 that it will "exec", and that there is sufficient room for the brk. */
1657
1658 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1659 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1660 +
1661 +#ifdef CONFIG_PAX_ASLR
1662 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1663 +
1664 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1665 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1666 +#endif
1667
1668 /* When the program starts, a1 contains a pointer to a function to be
1669 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1670 @@ -126,8 +133,4 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1671 extern void elf_set_personality(const struct elf32_hdr *);
1672 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1673
1674 -struct mm_struct;
1675 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1676 -#define arch_randomize_brk arch_randomize_brk
1677 -
1678 #endif
1679 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1680 index de53547..52b9a28 100644
1681 --- a/arch/arm/include/asm/fncpy.h
1682 +++ b/arch/arm/include/asm/fncpy.h
1683 @@ -81,7 +81,9 @@
1684 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1685 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1686 \
1687 + pax_open_kernel(); \
1688 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1689 + pax_close_kernel(); \
1690 flush_icache_range((unsigned long)(dest_buf), \
1691 (unsigned long)(dest_buf) + (size)); \
1692 \
1693 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1694 index e42cf59..7b94b8f 100644
1695 --- a/arch/arm/include/asm/futex.h
1696 +++ b/arch/arm/include/asm/futex.h
1697 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1698 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1699 return -EFAULT;
1700
1701 + pax_open_userland();
1702 +
1703 smp_mb();
1704 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1705 "1: ldrex %1, [%4]\n"
1706 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1707 : "cc", "memory");
1708 smp_mb();
1709
1710 + pax_close_userland();
1711 +
1712 *uval = val;
1713 return ret;
1714 }
1715 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1716 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1717 return -EFAULT;
1718
1719 + pax_open_userland();
1720 +
1721 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1722 "1: " TUSER(ldr) " %1, [%4]\n"
1723 " teq %1, %2\n"
1724 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1725 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1726 : "cc", "memory");
1727
1728 + pax_close_userland();
1729 +
1730 *uval = val;
1731 return ret;
1732 }
1733 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1734 return -EFAULT;
1735
1736 pagefault_disable(); /* implies preempt_disable() */
1737 + pax_open_userland();
1738
1739 switch (op) {
1740 case FUTEX_OP_SET:
1741 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1742 ret = -ENOSYS;
1743 }
1744
1745 + pax_close_userland();
1746 pagefault_enable(); /* subsumes preempt_enable() */
1747
1748 if (!ret) {
1749 diff --git a/arch/arm/include/asm/hardware/gic.h b/arch/arm/include/asm/hardware/gic.h
1750 index 4b1ce6c..bea3f73 100644
1751 --- a/arch/arm/include/asm/hardware/gic.h
1752 +++ b/arch/arm/include/asm/hardware/gic.h
1753 @@ -34,9 +34,10 @@
1754
1755 #ifndef __ASSEMBLY__
1756 #include <linux/irqdomain.h>
1757 +#include <linux/irq.h>
1758 struct device_node;
1759
1760 -extern struct irq_chip gic_arch_extn;
1761 +extern irq_chip_no_const gic_arch_extn;
1762
1763 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
1764 u32 offset, struct device_node *);
1765 diff --git a/arch/arm/include/asm/highmem.h b/arch/arm/include/asm/highmem.h
1766 index 8c5e828..91b99ab 100644
1767 --- a/arch/arm/include/asm/highmem.h
1768 +++ b/arch/arm/include/asm/highmem.h
1769 @@ -41,6 +41,13 @@ extern void kunmap_high(struct page *page);
1770 #endif
1771 #endif
1772
1773 +/*
1774 + * Needed to be able to broadcast the TLB invalidation for kmap.
1775 + */
1776 +#ifdef CONFIG_ARM_ERRATA_798181
1777 +#undef ARCH_NEEDS_KMAP_HIGH_GET
1778 +#endif
1779 +
1780 #ifdef ARCH_NEEDS_KMAP_HIGH_GET
1781 extern void *kmap_high_get(struct page *page);
1782 #else
1783 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1784 index 83eb2f7..ed77159 100644
1785 --- a/arch/arm/include/asm/kmap_types.h
1786 +++ b/arch/arm/include/asm/kmap_types.h
1787 @@ -4,6 +4,6 @@
1788 /*
1789 * This is the "bare minimum". AIO seems to require this.
1790 */
1791 -#define KM_TYPE_NR 16
1792 +#define KM_TYPE_NR 17
1793
1794 #endif
1795 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1796 index 9e614a1..3302cca 100644
1797 --- a/arch/arm/include/asm/mach/dma.h
1798 +++ b/arch/arm/include/asm/mach/dma.h
1799 @@ -22,7 +22,7 @@ struct dma_ops {
1800 int (*residue)(unsigned int, dma_t *); /* optional */
1801 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1802 const char *type;
1803 -};
1804 +} __do_const;
1805
1806 struct dma_struct {
1807 void *addr; /* single DMA address */
1808 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1809 index 2fe141f..192dc01 100644
1810 --- a/arch/arm/include/asm/mach/map.h
1811 +++ b/arch/arm/include/asm/mach/map.h
1812 @@ -27,13 +27,16 @@ struct map_desc {
1813 #define MT_MINICLEAN 6
1814 #define MT_LOW_VECTORS 7
1815 #define MT_HIGH_VECTORS 8
1816 -#define MT_MEMORY 9
1817 +#define MT_MEMORY_RWX 9
1818 #define MT_ROM 10
1819 -#define MT_MEMORY_NONCACHED 11
1820 +#define MT_MEMORY_NONCACHED_RX 11
1821 #define MT_MEMORY_DTCM 12
1822 #define MT_MEMORY_ITCM 13
1823 #define MT_MEMORY_SO 14
1824 #define MT_MEMORY_DMA_READY 15
1825 +#define MT_MEMORY_RW 16
1826 +#define MT_MEMORY_RX 17
1827 +#define MT_MEMORY_NONCACHED_RW 18
1828
1829 #ifdef CONFIG_MMU
1830 extern void iotable_init(struct map_desc *, int);
1831 diff --git a/arch/arm/include/asm/mmu_context.h b/arch/arm/include/asm/mmu_context.h
1832 index 863a661..a7b85e0 100644
1833 --- a/arch/arm/include/asm/mmu_context.h
1834 +++ b/arch/arm/include/asm/mmu_context.h
1835 @@ -27,6 +27,8 @@ void __check_vmalloc_seq(struct mm_struct *mm);
1836 void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk);
1837 #define init_new_context(tsk,mm) ({ atomic64_set(&mm->context.id, 0); 0; })
1838
1839 +DECLARE_PER_CPU(atomic64_t, active_asids);
1840 +
1841 #else /* !CONFIG_CPU_HAS_ASID */
1842
1843 #ifdef CONFIG_MMU
1844 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1845 index 53426c6..c7baff3 100644
1846 --- a/arch/arm/include/asm/outercache.h
1847 +++ b/arch/arm/include/asm/outercache.h
1848 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1849 #endif
1850 void (*set_debug)(unsigned long);
1851 void (*resume)(void);
1852 -};
1853 +} __no_const;
1854
1855 #ifdef CONFIG_OUTER_CACHE
1856
1857 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1858 index 812a494..71fc0b6 100644
1859 --- a/arch/arm/include/asm/page.h
1860 +++ b/arch/arm/include/asm/page.h
1861 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1862 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1863 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1864 unsigned long vaddr, struct vm_area_struct *vma);
1865 -};
1866 +} __no_const;
1867
1868 #ifdef MULTI_USER
1869 extern struct cpu_user_fns cpu_user;
1870 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1871 index 943504f..c37a730 100644
1872 --- a/arch/arm/include/asm/pgalloc.h
1873 +++ b/arch/arm/include/asm/pgalloc.h
1874 @@ -17,6 +17,7 @@
1875 #include <asm/processor.h>
1876 #include <asm/cacheflush.h>
1877 #include <asm/tlbflush.h>
1878 +#include <asm/system_info.h>
1879
1880 #define check_pgt_cache() do { } while (0)
1881
1882 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1883 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1884 }
1885
1886 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1887 +{
1888 + pud_populate(mm, pud, pmd);
1889 +}
1890 +
1891 #else /* !CONFIG_ARM_LPAE */
1892
1893 /*
1894 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1895 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1896 #define pmd_free(mm, pmd) do { } while (0)
1897 #define pud_populate(mm,pmd,pte) BUG()
1898 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1899
1900 #endif /* CONFIG_ARM_LPAE */
1901
1902 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1903 __free_page(pte);
1904 }
1905
1906 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1907 +{
1908 +#ifdef CONFIG_ARM_LPAE
1909 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1910 +#else
1911 + if (addr & SECTION_SIZE)
1912 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1913 + else
1914 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1915 +#endif
1916 + flush_pmd_entry(pmdp);
1917 +}
1918 +
1919 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1920 pmdval_t prot)
1921 {
1922 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1923 static inline void
1924 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1925 {
1926 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1927 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1928 }
1929 #define pmd_pgtable(pmd) pmd_page(pmd)
1930
1931 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1932 index 5cfba15..f415e1a 100644
1933 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1934 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1935 @@ -20,12 +20,15 @@
1936 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1937 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1938 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1939 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1940 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1941 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1942 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1943 +
1944 /*
1945 * - section
1946 */
1947 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1948 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1949 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1950 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1951 @@ -37,6 +40,7 @@
1952 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1953 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1954 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1955 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1956
1957 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1958 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1959 @@ -66,6 +70,7 @@
1960 * - extended small page/tiny page
1961 */
1962 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1963 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1964 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1965 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1966 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1967 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1968 index f97ee02..07f1be5 100644
1969 --- a/arch/arm/include/asm/pgtable-2level.h
1970 +++ b/arch/arm/include/asm/pgtable-2level.h
1971 @@ -125,6 +125,7 @@
1972 #define L_PTE_XN (_AT(pteval_t, 1) << 9)
1973 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1974 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1975 +#define L_PTE_PXN (_AT(pteval_t, 1) << 12) /* v7*/
1976
1977 /*
1978 * These are the memory types, defined to be compatible with
1979 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1980 index d795282..a43ea90 100644
1981 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1982 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1983 @@ -32,15 +32,18 @@
1984 #define PMD_TYPE_SECT (_AT(pmdval_t, 1) << 0)
1985 #define PMD_BIT4 (_AT(pmdval_t, 0))
1986 #define PMD_DOMAIN(x) (_AT(pmdval_t, 0))
1987 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 59) /* PXNTable */
1988
1989 /*
1990 * - section
1991 */
1992 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1993 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1994 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7)
1995 #define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
1996 #define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
1997 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 11)
1998 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 53)
1999 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 54)
2000 #define PMD_SECT_AP_WRITE (_AT(pmdval_t, 0))
2001 #define PMD_SECT_AP_READ (_AT(pmdval_t, 0))
2002 @@ -66,6 +69,7 @@
2003 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
2004 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
2005 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
2006 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
2007 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
2008
2009 /*
2010 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
2011 index a3f3792..7b932a6 100644
2012 --- a/arch/arm/include/asm/pgtable-3level.h
2013 +++ b/arch/arm/include/asm/pgtable-3level.h
2014 @@ -74,6 +74,7 @@
2015 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
2016 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
2017 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
2018 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
2019 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
2020 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
2021 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
2022 @@ -82,6 +83,7 @@
2023 /*
2024 * To be used in assembly code with the upper page attributes.
2025 */
2026 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
2027 #define L_PTE_XN_HIGH (1 << (54 - 32))
2028 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
2029
2030 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
2031 index c094749..a6ff605 100644
2032 --- a/arch/arm/include/asm/pgtable.h
2033 +++ b/arch/arm/include/asm/pgtable.h
2034 @@ -30,6 +30,9 @@
2035 #include <asm/pgtable-2level.h>
2036 #endif
2037
2038 +#define ktla_ktva(addr) (addr)
2039 +#define ktva_ktla(addr) (addr)
2040 +
2041 /*
2042 * Just any arbitrary offset to the start of the vmalloc VM area: the
2043 * current 8MB value just means that there will be a 8MB "hole" after the
2044 @@ -45,6 +48,9 @@
2045 #define LIBRARY_TEXT_START 0x0c000000
2046
2047 #ifndef __ASSEMBLY__
2048 +extern pteval_t __supported_pte_mask;
2049 +extern pmdval_t __supported_pmd_mask;
2050 +
2051 extern void __pte_error(const char *file, int line, pte_t);
2052 extern void __pmd_error(const char *file, int line, pmd_t);
2053 extern void __pgd_error(const char *file, int line, pgd_t);
2054 @@ -53,6 +59,50 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2055 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
2056 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
2057
2058 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
2059 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
2060 +
2061 +#ifdef CONFIG_PAX_KERNEXEC
2062 +#include <asm/domain.h>
2063 +#include <linux/thread_info.h>
2064 +#include <linux/preempt.h>
2065 +#endif
2066 +
2067 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2068 +static inline int test_domain(int domain, int domaintype)
2069 +{
2070 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2071 +}
2072 +#endif
2073 +
2074 +#ifdef CONFIG_PAX_KERNEXEC
2075 +static inline unsigned long pax_open_kernel(void) {
2076 +#ifdef CONFIG_ARM_LPAE
2077 + /* TODO */
2078 +#else
2079 + preempt_disable();
2080 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2081 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2082 +#endif
2083 + return 0;
2084 +}
2085 +
2086 +static inline unsigned long pax_close_kernel(void) {
2087 +#ifdef CONFIG_ARM_LPAE
2088 + /* TODO */
2089 +#else
2090 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2091 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2092 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2093 + preempt_enable_no_resched();
2094 +#endif
2095 + return 0;
2096 +}
2097 +#else
2098 +static inline unsigned long pax_open_kernel(void) { return 0; }
2099 +static inline unsigned long pax_close_kernel(void) { return 0; }
2100 +#endif
2101 +
2102 /*
2103 * This is the lowest virtual address we can permit any user space
2104 * mapping to be mapped at. This is particularly important for
2105 @@ -63,8 +113,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2106 /*
2107 * The pgprot_* and protection_map entries will be fixed up in runtime
2108 * to include the cachable and bufferable bits based on memory policy,
2109 - * as well as any architecture dependent bits like global/ASID and SMP
2110 - * shared mapping bits.
2111 + * as well as any architecture dependent bits like global/ASID, PXN,
2112 + * and SMP shared mapping bits.
2113 */
2114 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2115
2116 @@ -241,7 +291,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2117 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2118 {
2119 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2120 - L_PTE_NONE | L_PTE_VALID;
2121 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2122 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2123 return pte;
2124 }
2125 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2126 index f3628fb..a0672dd 100644
2127 --- a/arch/arm/include/asm/proc-fns.h
2128 +++ b/arch/arm/include/asm/proc-fns.h
2129 @@ -75,7 +75,7 @@ extern struct processor {
2130 unsigned int suspend_size;
2131 void (*do_suspend)(void *);
2132 void (*do_resume)(void *);
2133 -} processor;
2134 +} __do_const processor;
2135
2136 #ifndef MULTI_CPU
2137 extern void cpu_proc_init(void);
2138 diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
2139 index 06e7d50..8a8e251 100644
2140 --- a/arch/arm/include/asm/processor.h
2141 +++ b/arch/arm/include/asm/processor.h
2142 @@ -65,9 +65,8 @@ struct thread_struct {
2143 regs->ARM_cpsr |= PSR_ENDSTATE; \
2144 regs->ARM_pc = pc & ~1; /* pc */ \
2145 regs->ARM_sp = sp; /* sp */ \
2146 - regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
2147 - regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
2148 - regs->ARM_r0 = stack[0]; /* r0 (argc) */ \
2149 + /* r2 (envp), r1 (argv), r0 (argc) */ \
2150 + (void)copy_from_user(&regs->ARM_r0, (const char __user *)stack, 3 * sizeof(unsigned long)); \
2151 nommu_start_thread(regs); \
2152 })
2153
2154 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2155 index d3a22be..3a69ad5 100644
2156 --- a/arch/arm/include/asm/smp.h
2157 +++ b/arch/arm/include/asm/smp.h
2158 @@ -107,7 +107,7 @@ struct smp_operations {
2159 int (*cpu_disable)(unsigned int cpu);
2160 #endif
2161 #endif
2162 -};
2163 +} __no_const;
2164
2165 /*
2166 * set platform specific SMP operations
2167 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2168 index cddda1f..ff357f7 100644
2169 --- a/arch/arm/include/asm/thread_info.h
2170 +++ b/arch/arm/include/asm/thread_info.h
2171 @@ -77,9 +77,9 @@ struct thread_info {
2172 .flags = 0, \
2173 .preempt_count = INIT_PREEMPT_COUNT, \
2174 .addr_limit = KERNEL_DS, \
2175 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2176 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2177 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2178 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2179 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2180 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2181 .restart_block = { \
2182 .fn = do_no_restart_syscall, \
2183 }, \
2184 @@ -152,6 +152,12 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2185 #define TIF_SYSCALL_AUDIT 9
2186 #define TIF_SYSCALL_TRACEPOINT 10
2187 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2188 +
2189 +/* within 8 bits of TIF_SYSCALL_TRACE
2190 + * to meet flexible second operand requirements
2191 + */
2192 +#define TIF_GRSEC_SETXID 12
2193 +
2194 #define TIF_USING_IWMMXT 17
2195 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2196 #define TIF_RESTORE_SIGMASK 20
2197 @@ -165,10 +171,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2198 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2199 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2200 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2201 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2202
2203 /* Checks for any syscall work in entry-common.S */
2204 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2205 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2206 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2207
2208 /*
2209 * Change these and you break ASM code in entry-common.S
2210 diff --git a/arch/arm/include/asm/tlbflush.h b/arch/arm/include/asm/tlbflush.h
2211 index 6e924d3..a9f3ddf 100644
2212 --- a/arch/arm/include/asm/tlbflush.h
2213 +++ b/arch/arm/include/asm/tlbflush.h
2214 @@ -430,6 +430,21 @@ static inline void local_flush_tlb_kernel_page(unsigned long kaddr)
2215 }
2216 }
2217
2218 +#ifdef CONFIG_ARM_ERRATA_798181
2219 +static inline void dummy_flush_tlb_a15_erratum(void)
2220 +{
2221 + /*
2222 + * Dummy TLBIMVAIS. Using the unmapped address 0 and ASID 0.
2223 + */
2224 + asm("mcr p15, 0, %0, c8, c3, 1" : : "r" (0));
2225 + dsb();
2226 +}
2227 +#else
2228 +static inline void dummy_flush_tlb_a15_erratum(void)
2229 +{
2230 +}
2231 +#endif
2232 +
2233 /*
2234 * flush_pmd_entry
2235 *
2236 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2237 index 7e1f760..752fcb7 100644
2238 --- a/arch/arm/include/asm/uaccess.h
2239 +++ b/arch/arm/include/asm/uaccess.h
2240 @@ -18,6 +18,7 @@
2241 #include <asm/domain.h>
2242 #include <asm/unified.h>
2243 #include <asm/compiler.h>
2244 +#include <asm/pgtable.h>
2245
2246 #define VERIFY_READ 0
2247 #define VERIFY_WRITE 1
2248 @@ -60,10 +61,34 @@ extern int __put_user_bad(void);
2249 #define USER_DS TASK_SIZE
2250 #define get_fs() (current_thread_info()->addr_limit)
2251
2252 +static inline void pax_open_userland(void)
2253 +{
2254 +
2255 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2256 + if (get_fs() == USER_DS) {
2257 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2258 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2259 + }
2260 +#endif
2261 +
2262 +}
2263 +
2264 +static inline void pax_close_userland(void)
2265 +{
2266 +
2267 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2268 + if (get_fs() == USER_DS) {
2269 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2270 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2271 + }
2272 +#endif
2273 +
2274 +}
2275 +
2276 static inline void set_fs(mm_segment_t fs)
2277 {
2278 current_thread_info()->addr_limit = fs;
2279 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2280 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2281 }
2282
2283 #define segment_eq(a,b) ((a) == (b))
2284 @@ -143,8 +168,12 @@ extern int __get_user_4(void *);
2285
2286 #define get_user(x,p) \
2287 ({ \
2288 + int __e; \
2289 might_fault(); \
2290 - __get_user_check(x,p); \
2291 + pax_open_userland(); \
2292 + __e = __get_user_check(x,p); \
2293 + pax_close_userland(); \
2294 + __e; \
2295 })
2296
2297 extern int __put_user_1(void *, unsigned int);
2298 @@ -188,8 +217,12 @@ extern int __put_user_8(void *, unsigned long long);
2299
2300 #define put_user(x,p) \
2301 ({ \
2302 + int __e; \
2303 might_fault(); \
2304 - __put_user_check(x,p); \
2305 + pax_open_userland(); \
2306 + __e = __put_user_check(x,p); \
2307 + pax_close_userland(); \
2308 + __e; \
2309 })
2310
2311 #else /* CONFIG_MMU */
2312 @@ -230,13 +263,17 @@ static inline void set_fs(mm_segment_t fs)
2313 #define __get_user(x,ptr) \
2314 ({ \
2315 long __gu_err = 0; \
2316 + pax_open_userland(); \
2317 __get_user_err((x),(ptr),__gu_err); \
2318 + pax_close_userland(); \
2319 __gu_err; \
2320 })
2321
2322 #define __get_user_error(x,ptr,err) \
2323 ({ \
2324 + pax_open_userland(); \
2325 __get_user_err((x),(ptr),err); \
2326 + pax_close_userland(); \
2327 (void) 0; \
2328 })
2329
2330 @@ -312,13 +349,17 @@ do { \
2331 #define __put_user(x,ptr) \
2332 ({ \
2333 long __pu_err = 0; \
2334 + pax_open_userland(); \
2335 __put_user_err((x),(ptr),__pu_err); \
2336 + pax_close_userland(); \
2337 __pu_err; \
2338 })
2339
2340 #define __put_user_error(x,ptr,err) \
2341 ({ \
2342 + pax_open_userland(); \
2343 __put_user_err((x),(ptr),err); \
2344 + pax_close_userland(); \
2345 (void) 0; \
2346 })
2347
2348 @@ -418,11 +459,44 @@ do { \
2349
2350
2351 #ifdef CONFIG_MMU
2352 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2353 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2354 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2355 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2356 +
2357 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2358 +{
2359 + unsigned long ret;
2360 +
2361 + check_object_size(to, n, false);
2362 + pax_open_userland();
2363 + ret = ___copy_from_user(to, from, n);
2364 + pax_close_userland();
2365 + return ret;
2366 +}
2367 +
2368 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2369 +{
2370 + unsigned long ret;
2371 +
2372 + check_object_size(from, n, true);
2373 + pax_open_userland();
2374 + ret = ___copy_to_user(to, from, n);
2375 + pax_close_userland();
2376 + return ret;
2377 +}
2378 +
2379 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2380 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2381 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2382 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2383 +
2384 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2385 +{
2386 + unsigned long ret;
2387 + pax_open_userland();
2388 + ret = ___clear_user(addr, n);
2389 + pax_close_userland();
2390 + return ret;
2391 +}
2392 +
2393 #else
2394 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2395 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2396 @@ -431,6 +505,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2397
2398 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2399 {
2400 + if ((long)n < 0)
2401 + return n;
2402 +
2403 if (access_ok(VERIFY_READ, from, n))
2404 n = __copy_from_user(to, from, n);
2405 else /* security hole - plug it */
2406 @@ -440,6 +517,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2407
2408 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2409 {
2410 + if ((long)n < 0)
2411 + return n;
2412 +
2413 if (access_ok(VERIFY_WRITE, to, n))
2414 n = __copy_to_user(to, from, n);
2415 return n;
2416 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2417 index 96ee092..37f1844 100644
2418 --- a/arch/arm/include/uapi/asm/ptrace.h
2419 +++ b/arch/arm/include/uapi/asm/ptrace.h
2420 @@ -73,7 +73,7 @@
2421 * ARMv7 groups of PSR bits
2422 */
2423 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2424 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2425 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2426 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2427 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2428
2429 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2430 index 60d3b73..d27ee09 100644
2431 --- a/arch/arm/kernel/armksyms.c
2432 +++ b/arch/arm/kernel/armksyms.c
2433 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2434 #ifdef CONFIG_MMU
2435 EXPORT_SYMBOL(copy_page);
2436
2437 -EXPORT_SYMBOL(__copy_from_user);
2438 -EXPORT_SYMBOL(__copy_to_user);
2439 -EXPORT_SYMBOL(__clear_user);
2440 +EXPORT_SYMBOL(___copy_from_user);
2441 +EXPORT_SYMBOL(___copy_to_user);
2442 +EXPORT_SYMBOL(___clear_user);
2443
2444 EXPORT_SYMBOL(__get_user_1);
2445 EXPORT_SYMBOL(__get_user_2);
2446 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2447 index 0f82098..3dbd3ee 100644
2448 --- a/arch/arm/kernel/entry-armv.S
2449 +++ b/arch/arm/kernel/entry-armv.S
2450 @@ -47,6 +47,87 @@
2451 9997:
2452 .endm
2453
2454 + .macro pax_enter_kernel
2455 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2456 + @ make aligned space for saved DACR
2457 + sub sp, sp, #8
2458 + @ save regs
2459 + stmdb sp!, {r1, r2}
2460 + @ read DACR from cpu_domain into r1
2461 + mov r2, sp
2462 + @ assume 8K pages, since we have to split the immediate in two
2463 + bic r2, r2, #(0x1fc0)
2464 + bic r2, r2, #(0x3f)
2465 + ldr r1, [r2, #TI_CPU_DOMAIN]
2466 + @ store old DACR on stack
2467 + str r1, [sp, #8]
2468 +#ifdef CONFIG_PAX_KERNEXEC
2469 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2470 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2471 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2472 +#endif
2473 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2474 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2475 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2476 +#endif
2477 + @ write r1 to current_thread_info()->cpu_domain
2478 + str r1, [r2, #TI_CPU_DOMAIN]
2479 + @ write r1 to DACR
2480 + mcr p15, 0, r1, c3, c0, 0
2481 + @ instruction sync
2482 + instr_sync
2483 + @ restore regs
2484 + ldmia sp!, {r1, r2}
2485 +#endif
2486 + .endm
2487 +
2488 + .macro pax_open_userland
2489 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2490 + @ save regs
2491 + stmdb sp!, {r0, r1}
2492 + @ read DACR from cpu_domain into r1
2493 + mov r0, sp
2494 + @ assume 8K pages, since we have to split the immediate in two
2495 + bic r0, r0, #(0x1fc0)
2496 + bic r0, r0, #(0x3f)
2497 + ldr r1, [r0, #TI_CPU_DOMAIN]
2498 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2499 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2500 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2501 + @ write r1 to current_thread_info()->cpu_domain
2502 + str r1, [r0, #TI_CPU_DOMAIN]
2503 + @ write r1 to DACR
2504 + mcr p15, 0, r1, c3, c0, 0
2505 + @ instruction sync
2506 + instr_sync
2507 + @ restore regs
2508 + ldmia sp!, {r0, r1}
2509 +#endif
2510 + .endm
2511 +
2512 + .macro pax_close_userland
2513 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2514 + @ save regs
2515 + stmdb sp!, {r0, r1}
2516 + @ read DACR from cpu_domain into r1
2517 + mov r0, sp
2518 + @ assume 8K pages, since we have to split the immediate in two
2519 + bic r0, r0, #(0x1fc0)
2520 + bic r0, r0, #(0x3f)
2521 + ldr r1, [r0, #TI_CPU_DOMAIN]
2522 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2523 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2524 + @ write r1 to current_thread_info()->cpu_domain
2525 + str r1, [r0, #TI_CPU_DOMAIN]
2526 + @ write r1 to DACR
2527 + mcr p15, 0, r1, c3, c0, 0
2528 + @ instruction sync
2529 + instr_sync
2530 + @ restore regs
2531 + ldmia sp!, {r0, r1}
2532 +#endif
2533 + .endm
2534 +
2535 .macro pabt_helper
2536 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2537 #ifdef MULTI_PABORT
2538 @@ -89,11 +170,15 @@
2539 * Invalid mode handlers
2540 */
2541 .macro inv_entry, reason
2542 +
2543 + pax_enter_kernel
2544 +
2545 sub sp, sp, #S_FRAME_SIZE
2546 ARM( stmib sp, {r1 - lr} )
2547 THUMB( stmia sp, {r0 - r12} )
2548 THUMB( str sp, [sp, #S_SP] )
2549 THUMB( str lr, [sp, #S_LR] )
2550 +
2551 mov r1, #\reason
2552 .endm
2553
2554 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2555 .macro svc_entry, stack_hole=0
2556 UNWIND(.fnstart )
2557 UNWIND(.save {r0 - pc} )
2558 +
2559 + pax_enter_kernel
2560 +
2561 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2562 +
2563 #ifdef CONFIG_THUMB2_KERNEL
2564 SPFIX( str r0, [sp] ) @ temporarily saved
2565 SPFIX( mov r0, sp )
2566 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2567 ldmia r0, {r3 - r5}
2568 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2569 mov r6, #-1 @ "" "" "" ""
2570 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2571 + @ offset sp by 8 as done in pax_enter_kernel
2572 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2573 +#else
2574 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2575 +#endif
2576 SPFIX( addeq r2, r2, #4 )
2577 str r3, [sp, #-4]! @ save the "real" r0 copied
2578 @ from the exception stack
2579 @@ -359,6 +453,9 @@ ENDPROC(__pabt_svc)
2580 .macro usr_entry
2581 UNWIND(.fnstart )
2582 UNWIND(.cantunwind ) @ don't unwind the user space
2583 +
2584 + pax_enter_kernel_user
2585 +
2586 sub sp, sp, #S_FRAME_SIZE
2587 ARM( stmib sp, {r1 - r12} )
2588 THUMB( stmia sp, {r0 - r12} )
2589 @@ -456,7 +553,9 @@ __und_usr:
2590 tst r3, #PSR_T_BIT @ Thumb mode?
2591 bne __und_usr_thumb
2592 sub r4, r2, #4 @ ARM instr at LR - 4
2593 + pax_open_userland
2594 1: ldrt r0, [r4]
2595 + pax_close_userland
2596 #ifdef CONFIG_CPU_ENDIAN_BE8
2597 rev r0, r0 @ little endian instruction
2598 #endif
2599 @@ -491,10 +590,14 @@ __und_usr_thumb:
2600 */
2601 .arch armv6t2
2602 #endif
2603 + pax_open_userland
2604 2: ldrht r5, [r4]
2605 + pax_close_userland
2606 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2607 blo __und_usr_fault_16 @ 16bit undefined instruction
2608 + pax_open_userland
2609 3: ldrht r0, [r2]
2610 + pax_close_userland
2611 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2612 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2613 orr r0, r0, r5, lsl #16
2614 @@ -733,7 +836,7 @@ ENTRY(__switch_to)
2615 THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
2616 THUMB( str sp, [ip], #4 )
2617 THUMB( str lr, [ip], #4 )
2618 -#ifdef CONFIG_CPU_USE_DOMAINS
2619 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2620 ldr r6, [r2, #TI_CPU_DOMAIN]
2621 #endif
2622 set_tls r3, r4, r5
2623 @@ -742,7 +845,7 @@ ENTRY(__switch_to)
2624 ldr r8, =__stack_chk_guard
2625 ldr r7, [r7, #TSK_STACK_CANARY]
2626 #endif
2627 -#ifdef CONFIG_CPU_USE_DOMAINS
2628 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2629 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2630 #endif
2631 mov r5, r0
2632 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2633 index a6c301e..908821b 100644
2634 --- a/arch/arm/kernel/entry-common.S
2635 +++ b/arch/arm/kernel/entry-common.S
2636 @@ -10,18 +10,46 @@
2637
2638 #include <asm/unistd.h>
2639 #include <asm/ftrace.h>
2640 +#include <asm/domain.h>
2641 #include <asm/unwind.h>
2642
2643 +#include "entry-header.S"
2644 +
2645 #ifdef CONFIG_NEED_RET_TO_USER
2646 #include <mach/entry-macro.S>
2647 #else
2648 .macro arch_ret_to_user, tmp1, tmp2
2649 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2650 + @ save regs
2651 + stmdb sp!, {r1, r2}
2652 + @ read DACR from cpu_domain into r1
2653 + mov r2, sp
2654 + @ assume 8K pages, since we have to split the immediate in two
2655 + bic r2, r2, #(0x1fc0)
2656 + bic r2, r2, #(0x3f)
2657 + ldr r1, [r2, #TI_CPU_DOMAIN]
2658 +#ifdef CONFIG_PAX_KERNEXEC
2659 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2660 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2661 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2662 +#endif
2663 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2664 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2665 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2666 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2667 +#endif
2668 + @ write r1 to current_thread_info()->cpu_domain
2669 + str r1, [r2, #TI_CPU_DOMAIN]
2670 + @ write r1 to DACR
2671 + mcr p15, 0, r1, c3, c0, 0
2672 + @ instruction sync
2673 + instr_sync
2674 + @ restore regs
2675 + ldmia sp!, {r1, r2}
2676 +#endif
2677 .endm
2678 #endif
2679
2680 -#include "entry-header.S"
2681 -
2682 -
2683 .align 5
2684 /*
2685 * This is the fast syscall return path. We do as little as
2686 @@ -339,6 +367,7 @@ ENDPROC(ftrace_stub)
2687
2688 .align 5
2689 ENTRY(vector_swi)
2690 +
2691 sub sp, sp, #S_FRAME_SIZE
2692 stmia sp, {r0 - r12} @ Calling r0 - r12
2693 ARM( add r8, sp, #S_PC )
2694 @@ -388,6 +417,12 @@ ENTRY(vector_swi)
2695 ldr scno, [lr, #-4] @ get SWI instruction
2696 #endif
2697
2698 + /*
2699 + * do this here to avoid a performance hit of wrapping the code above
2700 + * that directly dereferences userland to parse the SWI instruction
2701 + */
2702 + pax_enter_kernel_user
2703 +
2704 #ifdef CONFIG_ALIGNMENT_TRAP
2705 ldr ip, __cr_alignment
2706 ldr ip, [ip]
2707 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2708 index 9a8531e..812e287 100644
2709 --- a/arch/arm/kernel/entry-header.S
2710 +++ b/arch/arm/kernel/entry-header.S
2711 @@ -73,9 +73,66 @@
2712 msr cpsr_c, \rtemp @ switch back to the SVC mode
2713 .endm
2714
2715 + .macro pax_enter_kernel_user
2716 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2717 + @ save regs
2718 + stmdb sp!, {r0, r1}
2719 + @ read DACR from cpu_domain into r1
2720 + mov r0, sp
2721 + @ assume 8K pages, since we have to split the immediate in two
2722 + bic r0, r0, #(0x1fc0)
2723 + bic r0, r0, #(0x3f)
2724 + ldr r1, [r0, #TI_CPU_DOMAIN]
2725 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2726 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2727 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2728 +#endif
2729 +#ifdef CONFIG_PAX_KERNEXEC
2730 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2731 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2732 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2733 +#endif
2734 + @ write r1 to current_thread_info()->cpu_domain
2735 + str r1, [r0, #TI_CPU_DOMAIN]
2736 + @ write r1 to DACR
2737 + mcr p15, 0, r1, c3, c0, 0
2738 + @ instruction sync
2739 + instr_sync
2740 + @ restore regs
2741 + ldmia sp!, {r0, r1}
2742 +#endif
2743 + .endm
2744 +
2745 + .macro pax_exit_kernel
2746 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2747 + @ save regs
2748 + stmdb sp!, {r0, r1}
2749 + @ read old DACR from stack into r1
2750 + ldr r1, [sp, #(8 + S_SP)]
2751 + sub r1, r1, #8
2752 + ldr r1, [r1]
2753 +
2754 + @ write r1 to current_thread_info()->cpu_domain
2755 + mov r0, sp
2756 + @ assume 8K pages, since we have to split the immediate in two
2757 + bic r0, r0, #(0x1fc0)
2758 + bic r0, r0, #(0x3f)
2759 + str r1, [r0, #TI_CPU_DOMAIN]
2760 + @ write r1 to DACR
2761 + mcr p15, 0, r1, c3, c0, 0
2762 + @ instruction sync
2763 + instr_sync
2764 + @ restore regs
2765 + ldmia sp!, {r0, r1}
2766 +#endif
2767 + .endm
2768 +
2769 #ifndef CONFIG_THUMB2_KERNEL
2770 .macro svc_exit, rpsr
2771 msr spsr_cxsf, \rpsr
2772 +
2773 + pax_exit_kernel
2774 +
2775 #if defined(CONFIG_CPU_V6)
2776 ldr r0, [sp]
2777 strex r1, r2, [sp] @ clear the exclusive monitor
2778 @@ -121,6 +178,9 @@
2779 .endm
2780 #else /* CONFIG_THUMB2_KERNEL */
2781 .macro svc_exit, rpsr
2782 +
2783 + pax_exit_kernel
2784 +
2785 ldr lr, [sp, #S_SP] @ top of the stack
2786 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2787 clrex @ clear the exclusive monitor
2788 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2789 index 2adda11..7fbe958 100644
2790 --- a/arch/arm/kernel/fiq.c
2791 +++ b/arch/arm/kernel/fiq.c
2792 @@ -82,7 +82,9 @@ void set_fiq_handler(void *start, unsigned int length)
2793 #if defined(CONFIG_CPU_USE_DOMAINS)
2794 memcpy((void *)0xffff001c, start, length);
2795 #else
2796 + pax_open_kernel();
2797 memcpy(vectors_page + 0x1c, start, length);
2798 + pax_close_kernel();
2799 #endif
2800 flush_icache_range(0xffff001c, 0xffff001c + length);
2801 if (!vectors_high())
2802 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2803 index e0eb9a1..caee108 100644
2804 --- a/arch/arm/kernel/head.S
2805 +++ b/arch/arm/kernel/head.S
2806 @@ -52,7 +52,9 @@
2807 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2808
2809 .macro pgtbl, rd, phys
2810 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2811 + mov \rd, #TEXT_OFFSET
2812 + sub \rd, #PG_DIR_SIZE
2813 + add \rd, \rd, \phys
2814 .endm
2815
2816 /*
2817 @@ -267,7 +269,7 @@ __create_page_tables:
2818 addne r6, r6, #1 << SECTION_SHIFT
2819 strne r6, [r3]
2820
2821 -#if defined(CONFIG_LPAE) && defined(CONFIG_CPU_ENDIAN_BE8)
2822 +#if defined(CONFIG_ARM_LPAE) && defined(CONFIG_CPU_ENDIAN_BE8)
2823 sub r4, r4, #4 @ Fixup page table pointer
2824 @ for 64-bit descriptors
2825 #endif
2826 @@ -434,7 +436,7 @@ __enable_mmu:
2827 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2828 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2829 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2830 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2831 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2832 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2833 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2834 #endif
2835 diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
2836 index 5ff2e77..556d030 100644
2837 --- a/arch/arm/kernel/hw_breakpoint.c
2838 +++ b/arch/arm/kernel/hw_breakpoint.c
2839 @@ -1011,7 +1011,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
2840 return NOTIFY_OK;
2841 }
2842
2843 -static struct notifier_block __cpuinitdata dbg_reset_nb = {
2844 +static struct notifier_block dbg_reset_nb = {
2845 .notifier_call = dbg_reset_notify,
2846 };
2847
2848 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2849 index 1e9be5d..03edbc2 100644
2850 --- a/arch/arm/kernel/module.c
2851 +++ b/arch/arm/kernel/module.c
2852 @@ -37,12 +37,37 @@
2853 #endif
2854
2855 #ifdef CONFIG_MMU
2856 -void *module_alloc(unsigned long size)
2857 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2858 {
2859 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2860 + return NULL;
2861 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2862 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2863 + GFP_KERNEL, prot, -1,
2864 __builtin_return_address(0));
2865 }
2866 +
2867 +void *module_alloc(unsigned long size)
2868 +{
2869 +
2870 +#ifdef CONFIG_PAX_KERNEXEC
2871 + return __module_alloc(size, PAGE_KERNEL);
2872 +#else
2873 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2874 +#endif
2875 +
2876 +}
2877 +
2878 +#ifdef CONFIG_PAX_KERNEXEC
2879 +void module_free_exec(struct module *mod, void *module_region)
2880 +{
2881 + module_free(mod, module_region);
2882 +}
2883 +
2884 +void *module_alloc_exec(unsigned long size)
2885 +{
2886 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2887 +}
2888 +#endif
2889 #endif
2890
2891 int
2892 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2893 index 07314af..c46655c 100644
2894 --- a/arch/arm/kernel/patch.c
2895 +++ b/arch/arm/kernel/patch.c
2896 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2897 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2898 int size;
2899
2900 + pax_open_kernel();
2901 if (thumb2 && __opcode_is_thumb16(insn)) {
2902 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2903 size = sizeof(u16);
2904 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2905 *(u32 *)addr = insn;
2906 size = sizeof(u32);
2907 }
2908 + pax_close_kernel();
2909
2910 flush_icache_range((uintptr_t)(addr),
2911 (uintptr_t)(addr) + size);
2912 diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
2913 index 5f66206..dce492f 100644
2914 --- a/arch/arm/kernel/perf_event_cpu.c
2915 +++ b/arch/arm/kernel/perf_event_cpu.c
2916 @@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
2917 return NOTIFY_OK;
2918 }
2919
2920 -static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
2921 +static struct notifier_block cpu_pmu_hotplug_notifier = {
2922 .notifier_call = cpu_pmu_notify,
2923 };
2924
2925 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2926 index c6dec5f..e0fddd1 100644
2927 --- a/arch/arm/kernel/process.c
2928 +++ b/arch/arm/kernel/process.c
2929 @@ -28,7 +28,6 @@
2930 #include <linux/tick.h>
2931 #include <linux/utsname.h>
2932 #include <linux/uaccess.h>
2933 -#include <linux/random.h>
2934 #include <linux/hw_breakpoint.h>
2935 #include <linux/cpuidle.h>
2936 #include <linux/leds.h>
2937 @@ -256,9 +255,10 @@ void machine_power_off(void)
2938 machine_shutdown();
2939 if (pm_power_off)
2940 pm_power_off();
2941 + BUG();
2942 }
2943
2944 -void machine_restart(char *cmd)
2945 +__noreturn void machine_restart(char *cmd)
2946 {
2947 machine_shutdown();
2948
2949 @@ -283,8 +283,8 @@ void __show_regs(struct pt_regs *regs)
2950 init_utsname()->release,
2951 (int)strcspn(init_utsname()->version, " "),
2952 init_utsname()->version);
2953 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2954 - print_symbol("LR is at %s\n", regs->ARM_lr);
2955 + printk("PC is at %pA\n", instruction_pointer(regs));
2956 + printk("LR is at %pA\n", regs->ARM_lr);
2957 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2958 "sp : %08lx ip : %08lx fp : %08lx\n",
2959 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2960 @@ -452,12 +452,6 @@ unsigned long get_wchan(struct task_struct *p)
2961 return 0;
2962 }
2963
2964 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2965 -{
2966 - unsigned long range_end = mm->brk + 0x02000000;
2967 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2968 -}
2969 -
2970 #ifdef CONFIG_MMU
2971 /*
2972 * The vectors page is always readable from user space for the
2973 @@ -470,9 +464,8 @@ static int __init gate_vma_init(void)
2974 {
2975 gate_vma.vm_start = 0xffff0000;
2976 gate_vma.vm_end = 0xffff0000 + PAGE_SIZE;
2977 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2978 - gate_vma.vm_flags = VM_READ | VM_EXEC |
2979 - VM_MAYREAD | VM_MAYEXEC;
2980 + gate_vma.vm_flags = VM_NONE;
2981 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2982 return 0;
2983 }
2984 arch_initcall(gate_vma_init);
2985 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2986 index 03deeff..741ce88 100644
2987 --- a/arch/arm/kernel/ptrace.c
2988 +++ b/arch/arm/kernel/ptrace.c
2989 @@ -937,10 +937,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2990 return current_thread_info()->syscall;
2991 }
2992
2993 +#ifdef CONFIG_GRKERNSEC_SETXID
2994 +extern void gr_delayed_cred_worker(void);
2995 +#endif
2996 +
2997 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2998 {
2999 current_thread_info()->syscall = scno;
3000
3001 +#ifdef CONFIG_GRKERNSEC_SETXID
3002 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
3003 + gr_delayed_cred_worker();
3004 +#endif
3005 +
3006 /* Do the secure computing check first; failures should be fast. */
3007 if (secure_computing(scno) == -1)
3008 return -1;
3009 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
3010 index 3f6cbb2..39305c7 100644
3011 --- a/arch/arm/kernel/setup.c
3012 +++ b/arch/arm/kernel/setup.c
3013 @@ -97,21 +97,23 @@ EXPORT_SYMBOL(system_serial_high);
3014 unsigned int elf_hwcap __read_mostly;
3015 EXPORT_SYMBOL(elf_hwcap);
3016
3017 +pteval_t __supported_pte_mask __read_only;
3018 +pmdval_t __supported_pmd_mask __read_only;
3019
3020 #ifdef MULTI_CPU
3021 -struct processor processor __read_mostly;
3022 +struct processor processor;
3023 #endif
3024 #ifdef MULTI_TLB
3025 -struct cpu_tlb_fns cpu_tlb __read_mostly;
3026 +struct cpu_tlb_fns cpu_tlb __read_only;
3027 #endif
3028 #ifdef MULTI_USER
3029 -struct cpu_user_fns cpu_user __read_mostly;
3030 +struct cpu_user_fns cpu_user __read_only;
3031 #endif
3032 #ifdef MULTI_CACHE
3033 -struct cpu_cache_fns cpu_cache __read_mostly;
3034 +struct cpu_cache_fns cpu_cache __read_only;
3035 #endif
3036 #ifdef CONFIG_OUTER_CACHE
3037 -struct outer_cache_fns outer_cache __read_mostly;
3038 +struct outer_cache_fns outer_cache __read_only;
3039 EXPORT_SYMBOL(outer_cache);
3040 #endif
3041
3042 @@ -236,9 +238,13 @@ static int __get_cpu_architecture(void)
3043 asm("mrc p15, 0, %0, c0, c1, 4"
3044 : "=r" (mmfr0));
3045 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
3046 - (mmfr0 & 0x000000f0) >= 0x00000030)
3047 + (mmfr0 & 0x000000f0) >= 0x00000030) {
3048 cpu_arch = CPU_ARCH_ARMv7;
3049 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3050 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
3051 + __supported_pte_mask |= L_PTE_PXN;
3052 + __supported_pmd_mask |= PMD_PXNTABLE;
3053 + }
3054 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3055 (mmfr0 & 0x000000f0) == 0x00000020)
3056 cpu_arch = CPU_ARCH_ARMv6;
3057 else
3058 @@ -462,7 +468,7 @@ static void __init setup_processor(void)
3059 __cpu_architecture = __get_cpu_architecture();
3060
3061 #ifdef MULTI_CPU
3062 - processor = *list->proc;
3063 + memcpy((void *)&processor, list->proc, sizeof processor);
3064 #endif
3065 #ifdef MULTI_TLB
3066 cpu_tlb = *list->tlb;
3067 @@ -524,7 +530,7 @@ int __init arm_add_memory(phys_addr_t start, phys_addr_t size)
3068 size -= start & ~PAGE_MASK;
3069 bank->start = PAGE_ALIGN(start);
3070
3071 -#ifndef CONFIG_LPAE
3072 +#ifndef CONFIG_ARM_LPAE
3073 if (bank->start + size < bank->start) {
3074 printk(KERN_CRIT "Truncating memory at 0x%08llx to fit in "
3075 "32-bit physical address space\n", (long long)start);
3076 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3077 index 56f72d2..6924200 100644
3078 --- a/arch/arm/kernel/signal.c
3079 +++ b/arch/arm/kernel/signal.c
3080 @@ -433,22 +433,14 @@ setup_return(struct pt_regs *regs, struct k_sigaction *ka,
3081 __put_user(sigreturn_codes[idx+1], rc+1))
3082 return 1;
3083
3084 - if (cpsr & MODE32_BIT) {
3085 - /*
3086 - * 32-bit code can use the new high-page
3087 - * signal return code support.
3088 - */
3089 - retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb;
3090 - } else {
3091 - /*
3092 - * Ensure that the instruction cache sees
3093 - * the return code written onto the stack.
3094 - */
3095 - flush_icache_range((unsigned long)rc,
3096 - (unsigned long)(rc + 2));
3097 + /*
3098 + * Ensure that the instruction cache sees
3099 + * the return code written onto the stack.
3100 + */
3101 + flush_icache_range((unsigned long)rc,
3102 + (unsigned long)(rc + 2));
3103
3104 - retcode = ((unsigned long)rc) + thumb;
3105 - }
3106 + retcode = ((unsigned long)rc) + thumb;
3107 }
3108
3109 regs->ARM_r0 = usig;
3110 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3111 index 58af91c..343ce99 100644
3112 --- a/arch/arm/kernel/smp.c
3113 +++ b/arch/arm/kernel/smp.c
3114 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3115
3116 static DECLARE_COMPLETION(cpu_running);
3117
3118 -static struct smp_operations smp_ops;
3119 +static struct smp_operations smp_ops __read_only;
3120
3121 void __init smp_set_ops(struct smp_operations *ops)
3122 {
3123 diff --git a/arch/arm/kernel/smp_tlb.c b/arch/arm/kernel/smp_tlb.c
3124 index 02c5d2c..e5695ad 100644
3125 --- a/arch/arm/kernel/smp_tlb.c
3126 +++ b/arch/arm/kernel/smp_tlb.c
3127 @@ -12,6 +12,7 @@
3128
3129 #include <asm/smp_plat.h>
3130 #include <asm/tlbflush.h>
3131 +#include <asm/mmu_context.h>
3132
3133 /**********************************************************************/
3134
3135 @@ -64,12 +65,72 @@ static inline void ipi_flush_tlb_kernel_range(void *arg)
3136 local_flush_tlb_kernel_range(ta->ta_start, ta->ta_end);
3137 }
3138
3139 +#ifdef CONFIG_ARM_ERRATA_798181
3140 +static int erratum_a15_798181(void)
3141 +{
3142 + unsigned int midr = read_cpuid_id();
3143 +
3144 + /* Cortex-A15 r0p0..r3p2 affected */
3145 + if ((midr & 0xff0ffff0) != 0x410fc0f0 || midr > 0x413fc0f2)
3146 + return 0;
3147 + return 1;
3148 +}
3149 +#else
3150 +static int erratum_a15_798181(void)
3151 +{
3152 + return 0;
3153 +}
3154 +#endif
3155 +
3156 +static void ipi_flush_tlb_a15_erratum(void *arg)
3157 +{
3158 + dmb();
3159 +}
3160 +
3161 +static void broadcast_tlb_a15_erratum(void)
3162 +{
3163 + if (!erratum_a15_798181())
3164 + return;
3165 +
3166 + dummy_flush_tlb_a15_erratum();
3167 + smp_call_function_many(cpu_online_mask, ipi_flush_tlb_a15_erratum,
3168 + NULL, 1);
3169 +}
3170 +
3171 +static void broadcast_tlb_mm_a15_erratum(struct mm_struct *mm)
3172 +{
3173 + int cpu;
3174 + cpumask_t mask = { CPU_BITS_NONE };
3175 +
3176 + if (!erratum_a15_798181())
3177 + return;
3178 +
3179 + dummy_flush_tlb_a15_erratum();
3180 + for_each_online_cpu(cpu) {
3181 + if (cpu == smp_processor_id())
3182 + continue;
3183 + /*
3184 + * We only need to send an IPI if the other CPUs are running
3185 + * the same ASID as the one being invalidated. There is no
3186 + * need for locking around the active_asids check since the
3187 + * switch_mm() function has at least one dmb() (as required by
3188 + * this workaround) in case a context switch happens on
3189 + * another CPU after the condition below.
3190 + */
3191 + if (atomic64_read(&mm->context.id) ==
3192 + atomic64_read(&per_cpu(active_asids, cpu)))
3193 + cpumask_set_cpu(cpu, &mask);
3194 + }
3195 + smp_call_function_many(&mask, ipi_flush_tlb_a15_erratum, NULL, 1);
3196 +}
3197 +
3198 void flush_tlb_all(void)
3199 {
3200 if (tlb_ops_need_broadcast())
3201 on_each_cpu(ipi_flush_tlb_all, NULL, 1);
3202 else
3203 local_flush_tlb_all();
3204 + broadcast_tlb_a15_erratum();
3205 }
3206
3207 void flush_tlb_mm(struct mm_struct *mm)
3208 @@ -78,6 +139,7 @@ void flush_tlb_mm(struct mm_struct *mm)
3209 on_each_cpu_mask(mm_cpumask(mm), ipi_flush_tlb_mm, mm, 1);
3210 else
3211 local_flush_tlb_mm(mm);
3212 + broadcast_tlb_mm_a15_erratum(mm);
3213 }
3214
3215 void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
3216 @@ -90,6 +152,7 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
3217 &ta, 1);
3218 } else
3219 local_flush_tlb_page(vma, uaddr);
3220 + broadcast_tlb_mm_a15_erratum(vma->vm_mm);
3221 }
3222
3223 void flush_tlb_kernel_page(unsigned long kaddr)
3224 @@ -100,6 +163,7 @@ void flush_tlb_kernel_page(unsigned long kaddr)
3225 on_each_cpu(ipi_flush_tlb_kernel_page, &ta, 1);
3226 } else
3227 local_flush_tlb_kernel_page(kaddr);
3228 + broadcast_tlb_a15_erratum();
3229 }
3230
3231 void flush_tlb_range(struct vm_area_struct *vma,
3232 @@ -114,6 +178,7 @@ void flush_tlb_range(struct vm_area_struct *vma,
3233 &ta, 1);
3234 } else
3235 local_flush_tlb_range(vma, start, end);
3236 + broadcast_tlb_mm_a15_erratum(vma->vm_mm);
3237 }
3238
3239 void flush_tlb_kernel_range(unsigned long start, unsigned long end)
3240 @@ -125,5 +190,6 @@ void flush_tlb_kernel_range(unsigned long start, unsigned long end)
3241 on_each_cpu(ipi_flush_tlb_kernel_range, &ta, 1);
3242 } else
3243 local_flush_tlb_kernel_range(start, end);
3244 + broadcast_tlb_a15_erratum();
3245 }
3246
3247 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3248 index b0179b8..829510e 100644
3249 --- a/arch/arm/kernel/traps.c
3250 +++ b/arch/arm/kernel/traps.c
3251 @@ -57,7 +57,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3252 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3253 {
3254 #ifdef CONFIG_KALLSYMS
3255 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3256 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3257 #else
3258 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3259 #endif
3260 @@ -266,6 +266,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3261 static int die_owner = -1;
3262 static unsigned int die_nest_count;
3263
3264 +extern void gr_handle_kernel_exploit(void);
3265 +
3266 static unsigned long oops_begin(void)
3267 {
3268 int cpu;
3269 @@ -308,6 +310,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3270 panic("Fatal exception in interrupt");
3271 if (panic_on_oops)
3272 panic("Fatal exception");
3273 +
3274 + gr_handle_kernel_exploit();
3275 +
3276 if (signr)
3277 do_exit(signr);
3278 }
3279 @@ -601,7 +606,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3280 * The user helper at 0xffff0fe0 must be used instead.
3281 * (see entry-armv.S for details)
3282 */
3283 + pax_open_kernel();
3284 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3285 + pax_close_kernel();
3286 }
3287 return 0;
3288
3289 @@ -841,13 +848,10 @@ void __init early_trap_init(void *vectors_base)
3290 */
3291 kuser_get_tls_init(vectors);
3292
3293 - /*
3294 - * Copy signal return handlers into the vector page, and
3295 - * set sigreturn to be a pointer to these.
3296 - */
3297 - memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE),
3298 - sigreturn_codes, sizeof(sigreturn_codes));
3299 -
3300 flush_icache_range(vectors, vectors + PAGE_SIZE);
3301 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3302 +
3303 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3304 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3305 +#endif
3306 +
3307 }
3308 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3309 index 11c1785..c67d54c 100644
3310 --- a/arch/arm/kernel/vmlinux.lds.S
3311 +++ b/arch/arm/kernel/vmlinux.lds.S
3312 @@ -8,7 +8,11 @@
3313 #include <asm/thread_info.h>
3314 #include <asm/memory.h>
3315 #include <asm/page.h>
3316 -
3317 +
3318 +#ifdef CONFIG_PAX_KERNEXEC
3319 +#include <asm/pgtable.h>
3320 +#endif
3321 +
3322 #define PROC_INFO \
3323 . = ALIGN(4); \
3324 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3325 @@ -90,6 +94,11 @@ SECTIONS
3326 _text = .;
3327 HEAD_TEXT
3328 }
3329 +
3330 +#ifdef CONFIG_PAX_KERNEXEC
3331 + . = ALIGN(1<<SECTION_SHIFT);
3332 +#endif
3333 +
3334 .text : { /* Real text segment */
3335 _stext = .; /* Text and read-only data */
3336 __exception_text_start = .;
3337 @@ -144,6 +153,10 @@ SECTIONS
3338
3339 _etext = .; /* End of text and rodata section */
3340
3341 +#ifdef CONFIG_PAX_KERNEXEC
3342 + . = ALIGN(1<<SECTION_SHIFT);
3343 +#endif
3344 +
3345 #ifndef CONFIG_XIP_KERNEL
3346 . = ALIGN(PAGE_SIZE);
3347 __init_begin = .;
3348 @@ -203,6 +216,11 @@ SECTIONS
3349 . = PAGE_OFFSET + TEXT_OFFSET;
3350 #else
3351 __init_end = .;
3352 +
3353 +#ifdef CONFIG_PAX_KERNEXEC
3354 + . = ALIGN(1<<SECTION_SHIFT);
3355 +#endif
3356 +
3357 . = ALIGN(THREAD_SIZE);
3358 __data_loc = .;
3359 #endif
3360 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3361 index 14a0d98..7771a7d 100644
3362 --- a/arch/arm/lib/clear_user.S
3363 +++ b/arch/arm/lib/clear_user.S
3364 @@ -12,14 +12,14 @@
3365
3366 .text
3367
3368 -/* Prototype: int __clear_user(void *addr, size_t sz)
3369 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3370 * Purpose : clear some user memory
3371 * Params : addr - user memory address to clear
3372 * : sz - number of bytes to clear
3373 * Returns : number of bytes NOT cleared
3374 */
3375 ENTRY(__clear_user_std)
3376 -WEAK(__clear_user)
3377 +WEAK(___clear_user)
3378 stmfd sp!, {r1, lr}
3379 mov r2, #0
3380 cmp r1, #4
3381 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3382 USER( strnebt r2, [r0])
3383 mov r0, #0
3384 ldmfd sp!, {r1, pc}
3385 -ENDPROC(__clear_user)
3386 +ENDPROC(___clear_user)
3387 ENDPROC(__clear_user_std)
3388
3389 .pushsection .fixup,"ax"
3390 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3391 index 66a477a..bee61d3 100644
3392 --- a/arch/arm/lib/copy_from_user.S
3393 +++ b/arch/arm/lib/copy_from_user.S
3394 @@ -16,7 +16,7 @@
3395 /*
3396 * Prototype:
3397 *
3398 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3399 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3400 *
3401 * Purpose:
3402 *
3403 @@ -84,11 +84,11 @@
3404
3405 .text
3406
3407 -ENTRY(__copy_from_user)
3408 +ENTRY(___copy_from_user)
3409
3410 #include "copy_template.S"
3411
3412 -ENDPROC(__copy_from_user)
3413 +ENDPROC(___copy_from_user)
3414
3415 .pushsection .fixup,"ax"
3416 .align 0
3417 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3418 index 6ee2f67..d1cce76 100644
3419 --- a/arch/arm/lib/copy_page.S
3420 +++ b/arch/arm/lib/copy_page.S
3421 @@ -10,6 +10,7 @@
3422 * ASM optimised string functions
3423 */
3424 #include <linux/linkage.h>
3425 +#include <linux/const.h>
3426 #include <asm/assembler.h>
3427 #include <asm/asm-offsets.h>
3428 #include <asm/cache.h>
3429 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3430 index d066df6..df28194 100644
3431 --- a/arch/arm/lib/copy_to_user.S
3432 +++ b/arch/arm/lib/copy_to_user.S
3433 @@ -16,7 +16,7 @@
3434 /*
3435 * Prototype:
3436 *
3437 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3438 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3439 *
3440 * Purpose:
3441 *
3442 @@ -88,11 +88,11 @@
3443 .text
3444
3445 ENTRY(__copy_to_user_std)
3446 -WEAK(__copy_to_user)
3447 +WEAK(___copy_to_user)
3448
3449 #include "copy_template.S"
3450
3451 -ENDPROC(__copy_to_user)
3452 +ENDPROC(___copy_to_user)
3453 ENDPROC(__copy_to_user_std)
3454
3455 .pushsection .fixup,"ax"
3456 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3457 index 7d08b43..f7ca7ea 100644
3458 --- a/arch/arm/lib/csumpartialcopyuser.S
3459 +++ b/arch/arm/lib/csumpartialcopyuser.S
3460 @@ -57,8 +57,8 @@
3461 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3462 */
3463
3464 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3465 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3466 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3467 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3468
3469 #include "csumpartialcopygeneric.S"
3470
3471 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3472 index 6b93f6a..1aa92d0 100644
3473 --- a/arch/arm/lib/delay.c
3474 +++ b/arch/arm/lib/delay.c
3475 @@ -28,12 +28,15 @@
3476 /*
3477 * Default to the loop-based delay implementation.
3478 */
3479 -struct arm_delay_ops arm_delay_ops = {
3480 +static struct arm_delay_ops arm_loop_delay_ops = {
3481 .delay = __loop_delay,
3482 .const_udelay = __loop_const_udelay,
3483 .udelay = __loop_udelay,
3484 + .const_clock = false,
3485 };
3486
3487 +struct arm_delay_ops *arm_delay_ops __read_only = &arm_loop_delay_ops;
3488 +
3489 static const struct delay_timer *delay_timer;
3490 static bool delay_calibrated;
3491
3492 @@ -67,6 +70,13 @@ static void __timer_udelay(unsigned long usecs)
3493 __timer_const_udelay(usecs * UDELAY_MULT);
3494 }
3495
3496 +static struct arm_delay_ops arm_timer_delay_ops = {
3497 + .delay = __timer_delay,
3498 + .const_udelay = __timer_const_udelay,
3499 + .udelay = __timer_udelay,
3500 + .const_clock = true,
3501 +};
3502 +
3503 void __init register_current_timer_delay(const struct delay_timer *timer)
3504 {
3505 if (!delay_calibrated) {
3506 @@ -74,10 +84,7 @@ void __init register_current_timer_delay(const struct delay_timer *timer)
3507 delay_timer = timer;
3508 lpj_fine = timer->freq / HZ;
3509 loops_per_jiffy = lpj_fine;
3510 - arm_delay_ops.delay = __timer_delay;
3511 - arm_delay_ops.const_udelay = __timer_const_udelay;
3512 - arm_delay_ops.udelay = __timer_udelay;
3513 - arm_delay_ops.const_clock = true;
3514 + arm_delay_ops = &arm_timer_delay_ops;
3515 delay_calibrated = true;
3516 } else {
3517 pr_info("Ignoring duplicate/late registration of read_current_timer delay\n");
3518 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3519 index 025f742..8432b08 100644
3520 --- a/arch/arm/lib/uaccess_with_memcpy.c
3521 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3522 @@ -104,7 +104,7 @@ out:
3523 }
3524
3525 unsigned long
3526 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3527 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3528 {
3529 /*
3530 * This test is stubbed out of the main function above to keep
3531 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3532 index bac21a5..b67ef8e 100644
3533 --- a/arch/arm/mach-kirkwood/common.c
3534 +++ b/arch/arm/mach-kirkwood/common.c
3535 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3536 clk_gate_ops.disable(hw);
3537 }
3538
3539 -static struct clk_ops clk_gate_fn_ops;
3540 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3541 +{
3542 + return clk_gate_ops.is_enabled(hw);
3543 +}
3544 +
3545 +static struct clk_ops clk_gate_fn_ops = {
3546 + .enable = clk_gate_fn_enable,
3547 + .disable = clk_gate_fn_disable,
3548 + .is_enabled = clk_gate_fn_is_enabled,
3549 +};
3550
3551 static struct clk __init *clk_register_gate_fn(struct device *dev,
3552 const char *name,
3553 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3554 gate_fn->fn_en = fn_en;
3555 gate_fn->fn_dis = fn_dis;
3556
3557 - /* ops is the gate ops, but with our enable/disable functions */
3558 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3559 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3560 - clk_gate_fn_ops = clk_gate_ops;
3561 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3562 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3563 - }
3564 -
3565 clk = clk_register(dev, &gate_fn->gate.hw);
3566
3567 if (IS_ERR(clk))
3568 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3569 index 0abb30f..54064da 100644
3570 --- a/arch/arm/mach-omap2/board-n8x0.c
3571 +++ b/arch/arm/mach-omap2/board-n8x0.c
3572 @@ -631,7 +631,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3573 }
3574 #endif
3575
3576 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3577 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3578 .late_init = n8x0_menelaus_late_init,
3579 };
3580
3581 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3582 index 8033cb7..2f7cb62 100644
3583 --- a/arch/arm/mach-omap2/gpmc.c
3584 +++ b/arch/arm/mach-omap2/gpmc.c
3585 @@ -139,7 +139,6 @@ struct omap3_gpmc_regs {
3586 };
3587
3588 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3589 -static struct irq_chip gpmc_irq_chip;
3590 static unsigned gpmc_irq_start;
3591
3592 static struct resource gpmc_mem_root;
3593 @@ -700,6 +699,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3594
3595 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3596
3597 +static struct irq_chip gpmc_irq_chip = {
3598 + .name = "gpmc",
3599 + .irq_startup = gpmc_irq_noop_ret,
3600 + .irq_enable = gpmc_irq_enable,
3601 + .irq_disable = gpmc_irq_disable,
3602 + .irq_shutdown = gpmc_irq_noop,
3603 + .irq_ack = gpmc_irq_noop,
3604 + .irq_mask = gpmc_irq_noop,
3605 + .irq_unmask = gpmc_irq_noop,
3606 +
3607 +};
3608 +
3609 static int gpmc_setup_irq(void)
3610 {
3611 int i;
3612 @@ -714,15 +725,6 @@ static int gpmc_setup_irq(void)
3613 return gpmc_irq_start;
3614 }
3615
3616 - gpmc_irq_chip.name = "gpmc";
3617 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3618 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3619 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3620 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3621 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3622 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3623 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3624 -
3625 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3626 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3627
3628 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3629 index 5d3b4f4..ddba3c0 100644
3630 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3631 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3632 @@ -340,7 +340,7 @@ static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self,
3633 return NOTIFY_OK;
3634 }
3635
3636 -static struct notifier_block __refdata irq_hotplug_notifier = {
3637 +static struct notifier_block irq_hotplug_notifier = {
3638 .notifier_call = irq_cpu_hotplug_notify,
3639 };
3640
3641 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3642 index e065daa..7b1ad9b 100644
3643 --- a/arch/arm/mach-omap2/omap_device.c
3644 +++ b/arch/arm/mach-omap2/omap_device.c
3645 @@ -686,7 +686,7 @@ void omap_device_delete(struct omap_device *od)
3646 * passes along the return value of omap_device_build_ss().
3647 */
3648 struct platform_device __init *omap_device_build(const char *pdev_name, int pdev_id,
3649 - struct omap_hwmod *oh, void *pdata,
3650 + struct omap_hwmod *oh, const void *pdata,
3651 int pdata_len,
3652 struct omap_device_pm_latency *pm_lats,
3653 int pm_lats_cnt, int is_early_device)
3654 @@ -720,7 +720,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name, int pdev
3655 */
3656 struct platform_device __init *omap_device_build_ss(const char *pdev_name, int pdev_id,
3657 struct omap_hwmod **ohs, int oh_cnt,
3658 - void *pdata, int pdata_len,
3659 + const void *pdata, int pdata_len,
3660 struct omap_device_pm_latency *pm_lats,
3661 int pm_lats_cnt, int is_early_device)
3662 {
3663 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3664 index 0933c59..42b8e2d 100644
3665 --- a/arch/arm/mach-omap2/omap_device.h
3666 +++ b/arch/arm/mach-omap2/omap_device.h
3667 @@ -91,14 +91,14 @@ int omap_device_shutdown(struct platform_device *pdev);
3668 /* Core code interface */
3669
3670 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3671 - struct omap_hwmod *oh, void *pdata,
3672 + struct omap_hwmod *oh, const void *pdata,
3673 int pdata_len,
3674 struct omap_device_pm_latency *pm_lats,
3675 int pm_lats_cnt, int is_early_device);
3676
3677 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3678 struct omap_hwmod **oh, int oh_cnt,
3679 - void *pdata, int pdata_len,
3680 + const void *pdata, int pdata_len,
3681 struct omap_device_pm_latency *pm_lats,
3682 int pm_lats_cnt, int is_early_device);
3683
3684 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3685 index 4653efb..8c60bf7 100644
3686 --- a/arch/arm/mach-omap2/omap_hwmod.c
3687 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3688 @@ -189,10 +189,10 @@ struct omap_hwmod_soc_ops {
3689 int (*init_clkdm)(struct omap_hwmod *oh);
3690 void (*update_context_lost)(struct omap_hwmod *oh);
3691 int (*get_context_lost)(struct omap_hwmod *oh);
3692 -};
3693 +} __no_const;
3694
3695 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3696 -static struct omap_hwmod_soc_ops soc_ops;
3697 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3698
3699 /* omap_hwmod_list contains all registered struct omap_hwmods */
3700 static LIST_HEAD(omap_hwmod_list);
3701 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3702 index 7c2b4ed..b2ea51f 100644
3703 --- a/arch/arm/mach-omap2/wd_timer.c
3704 +++ b/arch/arm/mach-omap2/wd_timer.c
3705 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3706 struct omap_hwmod *oh;
3707 char *oh_name = "wd_timer2";
3708 char *dev_name = "omap_wdt";
3709 - struct omap_wd_timer_platform_data pdata;
3710 + static struct omap_wd_timer_platform_data pdata = {
3711 + .read_reset_sources = prm_read_reset_sources
3712 + };
3713
3714 if (!cpu_class_is_omap2() || of_have_populated_dt())
3715 return 0;
3716 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3717 return -EINVAL;
3718 }
3719
3720 - pdata.read_reset_sources = prm_read_reset_sources;
3721 -
3722 pdev = omap_device_build(dev_name, id, oh, &pdata,
3723 sizeof(struct omap_wd_timer_platform_data),
3724 NULL, 0, 0);
3725 diff --git a/arch/arm/mach-ux500/include/mach/setup.h b/arch/arm/mach-ux500/include/mach/setup.h
3726 index 6be4c4d..32ac32a 100644
3727 --- a/arch/arm/mach-ux500/include/mach/setup.h
3728 +++ b/arch/arm/mach-ux500/include/mach/setup.h
3729 @@ -38,13 +38,6 @@ extern struct sys_timer ux500_timer;
3730 .type = MT_DEVICE, \
3731 }
3732
3733 -#define __MEM_DEV_DESC(x, sz) { \
3734 - .virtual = IO_ADDRESS(x), \
3735 - .pfn = __phys_to_pfn(x), \
3736 - .length = sz, \
3737 - .type = MT_MEMORY, \
3738 -}
3739 -
3740 extern struct smp_operations ux500_smp_ops;
3741 extern void ux500_cpu_die(unsigned int cpu);
3742
3743 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3744 index 3fd629d..8b1aca9 100644
3745 --- a/arch/arm/mm/Kconfig
3746 +++ b/arch/arm/mm/Kconfig
3747 @@ -425,7 +425,7 @@ config CPU_32v5
3748
3749 config CPU_32v6
3750 bool
3751 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3752 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC
3753 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3754
3755 config CPU_32v6K
3756 @@ -577,6 +577,7 @@ config CPU_CP15_MPU
3757
3758 config CPU_USE_DOMAINS
3759 bool
3760 + depends on !ARM_LPAE && !PAX_KERNEXEC
3761 help
3762 This option enables or disables the use of domain switching
3763 via the set_fs() function.
3764 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3765 index db26e2e..ee44569 100644
3766 --- a/arch/arm/mm/alignment.c
3767 +++ b/arch/arm/mm/alignment.c
3768 @@ -211,10 +211,12 @@ union offset_union {
3769 #define __get16_unaligned_check(ins,val,addr) \
3770 do { \
3771 unsigned int err = 0, v, a = addr; \
3772 + pax_open_userland(); \
3773 __get8_unaligned_check(ins,v,a,err); \
3774 val = v << ((BE) ? 8 : 0); \
3775 __get8_unaligned_check(ins,v,a,err); \
3776 val |= v << ((BE) ? 0 : 8); \
3777 + pax_close_userland(); \
3778 if (err) \
3779 goto fault; \
3780 } while (0)
3781 @@ -228,6 +230,7 @@ union offset_union {
3782 #define __get32_unaligned_check(ins,val,addr) \
3783 do { \
3784 unsigned int err = 0, v, a = addr; \
3785 + pax_open_userland(); \
3786 __get8_unaligned_check(ins,v,a,err); \
3787 val = v << ((BE) ? 24 : 0); \
3788 __get8_unaligned_check(ins,v,a,err); \
3789 @@ -236,6 +239,7 @@ union offset_union {
3790 val |= v << ((BE) ? 8 : 16); \
3791 __get8_unaligned_check(ins,v,a,err); \
3792 val |= v << ((BE) ? 0 : 24); \
3793 + pax_close_userland(); \
3794 if (err) \
3795 goto fault; \
3796 } while (0)
3797 @@ -249,6 +253,7 @@ union offset_union {
3798 #define __put16_unaligned_check(ins,val,addr) \
3799 do { \
3800 unsigned int err = 0, v = val, a = addr; \
3801 + pax_open_userland(); \
3802 __asm__( FIRST_BYTE_16 \
3803 ARM( "1: "ins" %1, [%2], #1\n" ) \
3804 THUMB( "1: "ins" %1, [%2]\n" ) \
3805 @@ -268,6 +273,7 @@ union offset_union {
3806 " .popsection\n" \
3807 : "=r" (err), "=&r" (v), "=&r" (a) \
3808 : "0" (err), "1" (v), "2" (a)); \
3809 + pax_close_userland(); \
3810 if (err) \
3811 goto fault; \
3812 } while (0)
3813 @@ -281,6 +287,7 @@ union offset_union {
3814 #define __put32_unaligned_check(ins,val,addr) \
3815 do { \
3816 unsigned int err = 0, v = val, a = addr; \
3817 + pax_open_userland(); \
3818 __asm__( FIRST_BYTE_32 \
3819 ARM( "1: "ins" %1, [%2], #1\n" ) \
3820 THUMB( "1: "ins" %1, [%2]\n" ) \
3821 @@ -310,6 +317,7 @@ union offset_union {
3822 " .popsection\n" \
3823 : "=r" (err), "=&r" (v), "=&r" (a) \
3824 : "0" (err), "1" (v), "2" (a)); \
3825 + pax_close_userland(); \
3826 if (err) \
3827 goto fault; \
3828 } while (0)
3829 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3830 index d07df17..59d5493 100644
3831 --- a/arch/arm/mm/context.c
3832 +++ b/arch/arm/mm/context.c
3833 @@ -45,7 +45,7 @@ static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3834 static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3835 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3836
3837 -static DEFINE_PER_CPU(atomic64_t, active_asids);
3838 +DEFINE_PER_CPU(atomic64_t, active_asids);
3839 static DEFINE_PER_CPU(u64, reserved_asids);
3840 static cpumask_t tlb_flush_pending;
3841
3842 @@ -209,8 +209,10 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3843 atomic64_set(&mm->context.id, asid);
3844 }
3845
3846 - if (cpumask_test_and_clear_cpu(cpu, &tlb_flush_pending))
3847 + if (cpumask_test_and_clear_cpu(cpu, &tlb_flush_pending)) {
3848 local_flush_tlb_all();
3849 + dummy_flush_tlb_a15_erratum();
3850 + }
3851
3852 atomic64_set(&per_cpu(active_asids, cpu), asid);
3853 cpumask_set_cpu(cpu, mm_cpumask(mm));
3854 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3855 index 5dbf13f..1a60561 100644
3856 --- a/arch/arm/mm/fault.c
3857 +++ b/arch/arm/mm/fault.c
3858 @@ -25,6 +25,7 @@
3859 #include <asm/system_misc.h>
3860 #include <asm/system_info.h>
3861 #include <asm/tlbflush.h>
3862 +#include <asm/sections.h>
3863
3864 #include "fault.h"
3865
3866 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3867 if (fixup_exception(regs))
3868 return;
3869
3870 +#ifdef CONFIG_PAX_KERNEXEC
3871 + if ((fsr & FSR_WRITE) &&
3872 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3873 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3874 + {
3875 + if (current->signal->curr_ip)
3876 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3877 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3878 + else
3879 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3880 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3881 + }
3882 +#endif
3883 +
3884 /*
3885 * No handler, we'll have to terminate things with extreme prejudice.
3886 */
3887 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3888 }
3889 #endif
3890
3891 +#ifdef CONFIG_PAX_PAGEEXEC
3892 + if (fsr & FSR_LNX_PF) {
3893 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3894 + do_group_exit(SIGKILL);
3895 + }
3896 +#endif
3897 +
3898 tsk->thread.address = addr;
3899 tsk->thread.error_code = fsr;
3900 tsk->thread.trap_no = 14;
3901 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3902 }
3903 #endif /* CONFIG_MMU */
3904
3905 +#ifdef CONFIG_PAX_PAGEEXEC
3906 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3907 +{
3908 + long i;
3909 +
3910 + printk(KERN_ERR "PAX: bytes at PC: ");
3911 + for (i = 0; i < 20; i++) {
3912 + unsigned char c;
3913 + if (get_user(c, (__force unsigned char __user *)pc+i))
3914 + printk(KERN_CONT "?? ");
3915 + else
3916 + printk(KERN_CONT "%02x ", c);
3917 + }
3918 + printk("\n");
3919 +
3920 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3921 + for (i = -1; i < 20; i++) {
3922 + unsigned long c;
3923 + if (get_user(c, (__force unsigned long __user *)sp+i))
3924 + printk(KERN_CONT "???????? ");
3925 + else
3926 + printk(KERN_CONT "%08lx ", c);
3927 + }
3928 + printk("\n");
3929 +}
3930 +#endif
3931 +
3932 /*
3933 * First Level Translation Fault Handler
3934 *
3935 @@ -543,9 +592,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3936 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3937 struct siginfo info;
3938
3939 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3940 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3941 + if (current->signal->curr_ip)
3942 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3943 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3944 + else
3945 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3946 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3947 + goto die;
3948 + }
3949 +#endif
3950 +
3951 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3952 return;
3953
3954 +die:
3955 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3956 inf->name, fsr, addr);
3957
3958 @@ -575,9 +637,49 @@ do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3959 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3960 struct siginfo info;
3961
3962 + if (user_mode(regs)) {
3963 + if (addr == 0xffff0fe0UL) {
3964 + /*
3965 + * PaX: __kuser_get_tls emulation
3966 + */
3967 + regs->ARM_r0 = current_thread_info()->tp_value;
3968 + regs->ARM_pc = regs->ARM_lr;
3969 + return;
3970 + }
3971 + }
3972 +
3973 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3974 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3975 + if (current->signal->curr_ip)
3976 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3977 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3978 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3979 + else
3980 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3981 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3982 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3983 + goto die;
3984 + }
3985 +#endif
3986 +
3987 +#ifdef CONFIG_PAX_REFCOUNT
3988 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3989 + unsigned int bkpt;
3990 +
3991 + if (!probe_kernel_address((unsigned int *)addr, bkpt) && bkpt == 0xe12f1073) {
3992 + current->thread.error_code = ifsr;
3993 + current->thread.trap_no = 0;
3994 + pax_report_refcount_overflow(regs);
3995 + fixup_exception(regs);
3996 + return;
3997 + }
3998 + }
3999 +#endif
4000 +
4001 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
4002 return;
4003
4004 +die:
4005 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
4006 inf->name, ifsr, addr);
4007
4008 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
4009 index cf08bdf..772656c 100644
4010 --- a/arch/arm/mm/fault.h
4011 +++ b/arch/arm/mm/fault.h
4012 @@ -3,6 +3,7 @@
4013
4014 /*
4015 * Fault status register encodings. We steal bit 31 for our own purposes.
4016 + * Set when the FSR value is from an instruction fault.
4017 */
4018 #define FSR_LNX_PF (1 << 31)
4019 #define FSR_WRITE (1 << 11)
4020 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
4021 }
4022 #endif
4023
4024 +/* valid for LPAE and !LPAE */
4025 +static inline int is_xn_fault(unsigned int fsr)
4026 +{
4027 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
4028 +}
4029 +
4030 +static inline int is_domain_fault(unsigned int fsr)
4031 +{
4032 + return ((fsr_fs(fsr) & 0xD) == 0x9);
4033 +}
4034 +
4035 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4036 unsigned long search_exception_table(unsigned long addr);
4037
4038 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4039 index ad722f1..763fdd3 100644
4040 --- a/arch/arm/mm/init.c
4041 +++ b/arch/arm/mm/init.c
4042 @@ -30,6 +30,8 @@
4043 #include <asm/setup.h>
4044 #include <asm/tlb.h>
4045 #include <asm/fixmap.h>
4046 +#include <asm/system_info.h>
4047 +#include <asm/cp15.h>
4048
4049 #include <asm/mach/arch.h>
4050 #include <asm/mach/map.h>
4051 @@ -736,7 +738,46 @@ void free_initmem(void)
4052 {
4053 #ifdef CONFIG_HAVE_TCM
4054 extern char __tcm_start, __tcm_end;
4055 +#endif
4056
4057 +#ifdef CONFIG_PAX_KERNEXEC
4058 + unsigned long addr;
4059 + pgd_t *pgd;
4060 + pud_t *pud;
4061 + pmd_t *pmd;
4062 + int cpu_arch = cpu_architecture();
4063 + unsigned int cr = get_cr();
4064 +
4065 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4066 + /* make pages tables, etc before .text NX */
4067 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4068 + pgd = pgd_offset_k(addr);
4069 + pud = pud_offset(pgd, addr);
4070 + pmd = pmd_offset(pud, addr);
4071 + __section_update(pmd, addr, PMD_SECT_XN);
4072 + }
4073 + /* make init NX */
4074 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4075 + pgd = pgd_offset_k(addr);
4076 + pud = pud_offset(pgd, addr);
4077 + pmd = pmd_offset(pud, addr);
4078 + __section_update(pmd, addr, PMD_SECT_XN);
4079 + }
4080 + /* make kernel code/rodata RX */
4081 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4082 + pgd = pgd_offset_k(addr);
4083 + pud = pud_offset(pgd, addr);
4084 + pmd = pmd_offset(pud, addr);
4085 +#ifdef CONFIG_ARM_LPAE
4086 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4087 +#else
4088 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4089 +#endif
4090 + }
4091 + }
4092 +#endif
4093 +
4094 +#ifdef CONFIG_HAVE_TCM
4095 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4096 totalram_pages += free_area(__phys_to_pfn(__pa(&__tcm_start)),
4097 __phys_to_pfn(__pa(&__tcm_end)),
4098 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4099 index 88fd86c..7a224ce 100644
4100 --- a/arch/arm/mm/ioremap.c
4101 +++ b/arch/arm/mm/ioremap.c
4102 @@ -335,9 +335,9 @@ __arm_ioremap_exec(unsigned long phys_addr, size_t size, bool cached)
4103 unsigned int mtype;
4104
4105 if (cached)
4106 - mtype = MT_MEMORY;
4107 + mtype = MT_MEMORY_RX;
4108 else
4109 - mtype = MT_MEMORY_NONCACHED;
4110 + mtype = MT_MEMORY_NONCACHED_RX;
4111
4112 return __arm_ioremap_caller(phys_addr, size, mtype,
4113 __builtin_return_address(0));
4114 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4115 index 10062ce..aa96dd7 100644
4116 --- a/arch/arm/mm/mmap.c
4117 +++ b/arch/arm/mm/mmap.c
4118 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4119 struct vm_area_struct *vma;
4120 int do_align = 0;
4121 int aliasing = cache_is_vipt_aliasing();
4122 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4123 struct vm_unmapped_area_info info;
4124
4125 /*
4126 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4127 if (len > TASK_SIZE)
4128 return -ENOMEM;
4129
4130 +#ifdef CONFIG_PAX_RANDMMAP
4131 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4132 +#endif
4133 +
4134 if (addr) {
4135 if (do_align)
4136 addr = COLOUR_ALIGN(addr, pgoff);
4137 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4138 addr = PAGE_ALIGN(addr);
4139
4140 vma = find_vma(mm, addr);
4141 - if (TASK_SIZE - len >= addr &&
4142 - (!vma || addr + len <= vma->vm_start))
4143 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4144 return addr;
4145 }
4146
4147 @@ -112,6 +116,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4148 unsigned long addr = addr0;
4149 int do_align = 0;
4150 int aliasing = cache_is_vipt_aliasing();
4151 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4152 struct vm_unmapped_area_info info;
4153
4154 /*
4155 @@ -132,6 +137,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4156 return addr;
4157 }
4158
4159 +#ifdef CONFIG_PAX_RANDMMAP
4160 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4161 +#endif
4162 +
4163 /* requesting a specific address */
4164 if (addr) {
4165 if (do_align)
4166 @@ -139,8 +148,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4167 else
4168 addr = PAGE_ALIGN(addr);
4169 vma = find_vma(mm, addr);
4170 - if (TASK_SIZE - len >= addr &&
4171 - (!vma || addr + len <= vma->vm_start))
4172 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4173 return addr;
4174 }
4175
4176 @@ -162,6 +170,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4177 VM_BUG_ON(addr != -ENOMEM);
4178 info.flags = 0;
4179 info.low_limit = mm->mmap_base;
4180 +
4181 +#ifdef CONFIG_PAX_RANDMMAP
4182 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4183 + info.low_limit += mm->delta_mmap;
4184 +#endif
4185 +
4186 info.high_limit = TASK_SIZE;
4187 addr = vm_unmapped_area(&info);
4188 }
4189 @@ -173,6 +187,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4190 {
4191 unsigned long random_factor = 0UL;
4192
4193 +#ifdef CONFIG_PAX_RANDMMAP
4194 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4195 +#endif
4196 +
4197 /* 8 bits of randomness in 20 address space bits */
4198 if ((current->flags & PF_RANDOMIZE) &&
4199 !(current->personality & ADDR_NO_RANDOMIZE))
4200 @@ -180,10 +198,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4201
4202 if (mmap_is_legacy()) {
4203 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4204 +
4205 +#ifdef CONFIG_PAX_RANDMMAP
4206 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4207 + mm->mmap_base += mm->delta_mmap;
4208 +#endif
4209 +
4210 mm->get_unmapped_area = arch_get_unmapped_area;
4211 mm->unmap_area = arch_unmap_area;
4212 } else {
4213 mm->mmap_base = mmap_base(random_factor);
4214 +
4215 +#ifdef CONFIG_PAX_RANDMMAP
4216 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4217 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4218 +#endif
4219 +
4220 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4221 mm->unmap_area = arch_unmap_area_topdown;
4222 }
4223 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4224 index ce328c7..35b88dc 100644
4225 --- a/arch/arm/mm/mmu.c
4226 +++ b/arch/arm/mm/mmu.c
4227 @@ -35,6 +35,23 @@
4228
4229 #include "mm.h"
4230
4231 +
4232 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4233 +void modify_domain(unsigned int dom, unsigned int type)
4234 +{
4235 + struct thread_info *thread = current_thread_info();
4236 + unsigned int domain = thread->cpu_domain;
4237 + /*
4238 + * DOMAIN_MANAGER might be defined to some other value,
4239 + * use the arch-defined constant
4240 + */
4241 + domain &= ~domain_val(dom, 3);
4242 + thread->cpu_domain = domain | domain_val(dom, type);
4243 + set_domain(thread->cpu_domain);
4244 +}
4245 +EXPORT_SYMBOL(modify_domain);
4246 +#endif
4247 +
4248 /*
4249 * empty_zero_page is a special page that is used for
4250 * zero-initialized data and COW.
4251 @@ -195,10 +212,18 @@ void adjust_cr(unsigned long mask, unsigned long set)
4252 }
4253 #endif
4254
4255 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4256 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4257 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4258
4259 -static struct mem_type mem_types[] = {
4260 +#ifdef CONFIG_PAX_KERNEXEC
4261 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4262 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4263 +#else
4264 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4265 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4266 +#endif
4267 +
4268 +static struct mem_type mem_types[] __read_only = {
4269 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4270 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4271 L_PTE_SHARED,
4272 @@ -227,16 +252,16 @@ static struct mem_type mem_types[] = {
4273 [MT_UNCACHED] = {
4274 .prot_pte = PROT_PTE_DEVICE,
4275 .prot_l1 = PMD_TYPE_TABLE,
4276 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4277 + .prot_sect = PROT_SECT_DEVICE,
4278 .domain = DOMAIN_IO,
4279 },
4280 [MT_CACHECLEAN] = {
4281 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4282 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4283 .domain = DOMAIN_KERNEL,
4284 },
4285 #ifndef CONFIG_ARM_LPAE
4286 [MT_MINICLEAN] = {
4287 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4288 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4289 .domain = DOMAIN_KERNEL,
4290 },
4291 #endif
4292 @@ -244,36 +269,54 @@ static struct mem_type mem_types[] = {
4293 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4294 L_PTE_RDONLY,
4295 .prot_l1 = PMD_TYPE_TABLE,
4296 - .domain = DOMAIN_USER,
4297 + .domain = DOMAIN_VECTORS,
4298 },
4299 [MT_HIGH_VECTORS] = {
4300 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4301 - L_PTE_USER | L_PTE_RDONLY,
4302 + L_PTE_RDONLY,
4303 .prot_l1 = PMD_TYPE_TABLE,
4304 - .domain = DOMAIN_USER,
4305 + .domain = DOMAIN_VECTORS,
4306 },
4307 - [MT_MEMORY] = {
4308 + [MT_MEMORY_RWX] = {
4309 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4310 .prot_l1 = PMD_TYPE_TABLE,
4311 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4312 .domain = DOMAIN_KERNEL,
4313 },
4314 + [MT_MEMORY_RW] = {
4315 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4316 + .prot_l1 = PMD_TYPE_TABLE,
4317 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4318 + .domain = DOMAIN_KERNEL,
4319 + },
4320 + [MT_MEMORY_RX] = {
4321 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4322 + .prot_l1 = PMD_TYPE_TABLE,
4323 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4324 + .domain = DOMAIN_KERNEL,
4325 + },
4326 [MT_ROM] = {
4327 - .prot_sect = PMD_TYPE_SECT,
4328 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4329 .domain = DOMAIN_KERNEL,
4330 },
4331 - [MT_MEMORY_NONCACHED] = {
4332 + [MT_MEMORY_NONCACHED_RW] = {
4333 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4334 L_PTE_MT_BUFFERABLE,
4335 .prot_l1 = PMD_TYPE_TABLE,
4336 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4337 .domain = DOMAIN_KERNEL,
4338 },
4339 + [MT_MEMORY_NONCACHED_RX] = {
4340 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4341 + L_PTE_MT_BUFFERABLE,
4342 + .prot_l1 = PMD_TYPE_TABLE,
4343 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4344 + .domain = DOMAIN_KERNEL,
4345 + },
4346 [MT_MEMORY_DTCM] = {
4347 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4348 - L_PTE_XN,
4349 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4350 .prot_l1 = PMD_TYPE_TABLE,
4351 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4352 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4353 .domain = DOMAIN_KERNEL,
4354 },
4355 [MT_MEMORY_ITCM] = {
4356 @@ -283,10 +326,10 @@ static struct mem_type mem_types[] = {
4357 },
4358 [MT_MEMORY_SO] = {
4359 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4360 - L_PTE_MT_UNCACHED | L_PTE_XN,
4361 + L_PTE_MT_UNCACHED,
4362 .prot_l1 = PMD_TYPE_TABLE,
4363 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4364 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4365 + PMD_SECT_UNCACHED,
4366 .domain = DOMAIN_KERNEL,
4367 },
4368 [MT_MEMORY_DMA_READY] = {
4369 @@ -371,9 +414,35 @@ static void __init build_mem_type_table(void)
4370 * to prevent speculative instruction fetches.
4371 */
4372 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4373 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4374 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4375 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4376 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4377 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4378 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4379 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4380 +
4381 + /* Mark other regions on ARMv6+ as execute-never */
4382 +
4383 +#ifdef CONFIG_PAX_KERNEXEC
4384 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4385 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4386 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4387 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4388 +#ifndef CONFIG_ARM_LPAE
4389 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4390 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4391 +#endif
4392 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4393 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4394 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4395 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4396 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4397 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4398 +#endif
4399 +
4400 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4401 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4402 }
4403 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4404 /*
4405 @@ -432,6 +501,9 @@ static void __init build_mem_type_table(void)
4406 * from SVC mode and no access from userspace.
4407 */
4408 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4409 +#ifdef CONFIG_PAX_KERNEXEC
4410 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4411 +#endif
4412 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4413 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4414 #endif
4415 @@ -448,11 +520,17 @@ static void __init build_mem_type_table(void)
4416 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4417 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4418 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4419 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4420 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4421 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4422 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4423 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4424 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4425 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4426 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4427 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4428 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4429 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4430 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4431 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4432 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4433 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4434 }
4435 }
4436
4437 @@ -463,15 +541,20 @@ static void __init build_mem_type_table(void)
4438 if (cpu_arch >= CPU_ARCH_ARMv6) {
4439 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4440 /* Non-cacheable Normal is XCB = 001 */
4441 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4442 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4443 + PMD_SECT_BUFFERED;
4444 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4445 PMD_SECT_BUFFERED;
4446 } else {
4447 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4448 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4449 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4450 + PMD_SECT_TEX(1);
4451 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4452 PMD_SECT_TEX(1);
4453 }
4454 } else {
4455 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4456 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4457 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4458 }
4459
4460 #ifdef CONFIG_ARM_LPAE
4461 @@ -487,6 +570,8 @@ static void __init build_mem_type_table(void)
4462 vecs_pgprot |= PTE_EXT_AF;
4463 #endif
4464
4465 + user_pgprot |= __supported_pte_mask;
4466 +
4467 for (i = 0; i < 16; i++) {
4468 pteval_t v = pgprot_val(protection_map[i]);
4469 protection_map[i] = __pgprot(v | user_pgprot);
4470 @@ -501,10 +586,15 @@ static void __init build_mem_type_table(void)
4471
4472 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4473 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4474 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4475 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4476 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4477 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4478 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4479 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4480 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4481 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4482 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4483 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4484 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4485 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4486 mem_types[MT_ROM].prot_sect |= cp->pmd;
4487
4488 switch (cp->pmd) {
4489 @@ -1105,18 +1195,15 @@ void __init arm_mm_memblock_reserve(void)
4490 * called function. This means you can't use any function or debugging
4491 * method which may touch any device, otherwise the kernel _will_ crash.
4492 */
4493 +
4494 +static char vectors[PAGE_SIZE] __read_only __aligned(PAGE_SIZE);
4495 +
4496 static void __init devicemaps_init(struct machine_desc *mdesc)
4497 {
4498 struct map_desc map;
4499 unsigned long addr;
4500 - void *vectors;
4501
4502 - /*
4503 - * Allocate the vector page early.
4504 - */
4505 - vectors = early_alloc(PAGE_SIZE);
4506 -
4507 - early_trap_init(vectors);
4508 + early_trap_init(&vectors);
4509
4510 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4511 pmd_clear(pmd_off_k(addr));
4512 @@ -1156,7 +1243,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4513 * location (0xffff0000). If we aren't using high-vectors, also
4514 * create a mapping at the low-vectors virtual address.
4515 */
4516 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4517 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4518 map.virtual = 0xffff0000;
4519 map.length = PAGE_SIZE;
4520 map.type = MT_HIGH_VECTORS;
4521 @@ -1214,8 +1301,39 @@ static void __init map_lowmem(void)
4522 map.pfn = __phys_to_pfn(start);
4523 map.virtual = __phys_to_virt(start);
4524 map.length = end - start;
4525 - map.type = MT_MEMORY;
4526
4527 +#ifdef CONFIG_PAX_KERNEXEC
4528 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4529 + struct map_desc kernel;
4530 + struct map_desc initmap;
4531 +
4532 + /* when freeing initmem we will make this RW */
4533 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4534 + initmap.virtual = (unsigned long)__init_begin;
4535 + initmap.length = _sdata - __init_begin;
4536 + initmap.type = MT_MEMORY_RWX;
4537 + create_mapping(&initmap);
4538 +
4539 + /* when freeing initmem we will make this RX */
4540 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4541 + kernel.virtual = (unsigned long)_stext;
4542 + kernel.length = __init_begin - _stext;
4543 + kernel.type = MT_MEMORY_RWX;
4544 + create_mapping(&kernel);
4545 +
4546 + if (map.virtual < (unsigned long)_stext) {
4547 + map.length = (unsigned long)_stext - map.virtual;
4548 + map.type = MT_MEMORY_RWX;
4549 + create_mapping(&map);
4550 + }
4551 +
4552 + map.pfn = __phys_to_pfn(__pa(_sdata));
4553 + map.virtual = (unsigned long)_sdata;
4554 + map.length = end - __pa(_sdata);
4555 + }
4556 +#endif
4557 +
4558 + map.type = MT_MEMORY_RW;
4559 create_mapping(&map);
4560 }
4561 }
4562 diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
4563 index 6d98c13..3cfb174 100644
4564 --- a/arch/arm/mm/proc-v7-2level.S
4565 +++ b/arch/arm/mm/proc-v7-2level.S
4566 @@ -99,6 +99,9 @@ ENTRY(cpu_v7_set_pte_ext)
4567 tst r1, #L_PTE_XN
4568 orrne r3, r3, #PTE_EXT_XN
4569
4570 + tst r1, #L_PTE_PXN
4571 + orrne r3, r3, #PTE_EXT_PXN
4572 +
4573 tst r1, #L_PTE_YOUNG
4574 tstne r1, #L_PTE_VALID
4575 #ifndef CONFIG_CPU_USE_DOMAINS
4576 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4577 index a5bc92d..0bb4730 100644
4578 --- a/arch/arm/plat-omap/sram.c
4579 +++ b/arch/arm/plat-omap/sram.c
4580 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4581 * Looks like we need to preserve some bootloader code at the
4582 * beginning of SRAM for jumping to flash for reboot to work...
4583 */
4584 + pax_open_kernel();
4585 memset_io(omap_sram_base + omap_sram_skip, 0,
4586 omap_sram_size - omap_sram_skip);
4587 + pax_close_kernel();
4588 }
4589 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4590 index f5144cd..71f6d1f 100644
4591 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4592 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4593 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4594 int (*started)(unsigned ch);
4595 int (*flush)(unsigned ch);
4596 int (*stop)(unsigned ch);
4597 -};
4598 +} __no_const;
4599
4600 extern void *samsung_dmadev_get_ops(void);
4601 extern void *s3c_dma_get_ops(void);
4602 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4603 index 0c3ba9f..95722b3 100644
4604 --- a/arch/arm64/kernel/debug-monitors.c
4605 +++ b/arch/arm64/kernel/debug-monitors.c
4606 @@ -151,7 +151,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4607 return NOTIFY_OK;
4608 }
4609
4610 -static struct notifier_block __cpuinitdata os_lock_nb = {
4611 +static struct notifier_block os_lock_nb = {
4612 .notifier_call = os_lock_notify,
4613 };
4614
4615 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4616 index 5ab825c..96aaec8 100644
4617 --- a/arch/arm64/kernel/hw_breakpoint.c
4618 +++ b/arch/arm64/kernel/hw_breakpoint.c
4619 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4620 return NOTIFY_OK;
4621 }
4622
4623 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4624 +static struct notifier_block hw_breakpoint_reset_nb = {
4625 .notifier_call = hw_breakpoint_reset_notify,
4626 };
4627
4628 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4629 index c3a58a1..78fbf54 100644
4630 --- a/arch/avr32/include/asm/cache.h
4631 +++ b/arch/avr32/include/asm/cache.h
4632 @@ -1,8 +1,10 @@
4633 #ifndef __ASM_AVR32_CACHE_H
4634 #define __ASM_AVR32_CACHE_H
4635
4636 +#include <linux/const.h>
4637 +
4638 #define L1_CACHE_SHIFT 5
4639 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4640 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4641
4642 /*
4643 * Memory returned by kmalloc() may be used for DMA, so we must make
4644 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4645 index e2c3287..6c4f98c 100644
4646 --- a/arch/avr32/include/asm/elf.h
4647 +++ b/arch/avr32/include/asm/elf.h
4648 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4649 the loader. We need to make sure that it is out of the way of the program
4650 that it will "exec", and that there is sufficient room for the brk. */
4651
4652 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4653 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4654
4655 +#ifdef CONFIG_PAX_ASLR
4656 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4657 +
4658 +#define PAX_DELTA_MMAP_LEN 15
4659 +#define PAX_DELTA_STACK_LEN 15
4660 +#endif
4661
4662 /* This yields a mask that user programs can use to figure out what
4663 instruction set this CPU supports. This could be done in user space,
4664 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4665 index 479330b..53717a8 100644
4666 --- a/arch/avr32/include/asm/kmap_types.h
4667 +++ b/arch/avr32/include/asm/kmap_types.h
4668 @@ -2,9 +2,9 @@
4669 #define __ASM_AVR32_KMAP_TYPES_H
4670
4671 #ifdef CONFIG_DEBUG_HIGHMEM
4672 -# define KM_TYPE_NR 29
4673 +# define KM_TYPE_NR 30
4674 #else
4675 -# define KM_TYPE_NR 14
4676 +# define KM_TYPE_NR 15
4677 #endif
4678
4679 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4680 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4681 index b2f2d2d..d1c85cb 100644
4682 --- a/arch/avr32/mm/fault.c
4683 +++ b/arch/avr32/mm/fault.c
4684 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4685
4686 int exception_trace = 1;
4687
4688 +#ifdef CONFIG_PAX_PAGEEXEC
4689 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4690 +{
4691 + unsigned long i;
4692 +
4693 + printk(KERN_ERR "PAX: bytes at PC: ");
4694 + for (i = 0; i < 20; i++) {
4695 + unsigned char c;
4696 + if (get_user(c, (unsigned char *)pc+i))
4697 + printk(KERN_CONT "???????? ");
4698 + else
4699 + printk(KERN_CONT "%02x ", c);
4700 + }
4701 + printk("\n");
4702 +}
4703 +#endif
4704 +
4705 /*
4706 * This routine handles page faults. It determines the address and the
4707 * problem, and then passes it off to one of the appropriate routines.
4708 @@ -174,6 +191,16 @@ bad_area:
4709 up_read(&mm->mmap_sem);
4710
4711 if (user_mode(regs)) {
4712 +
4713 +#ifdef CONFIG_PAX_PAGEEXEC
4714 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4715 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4716 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4717 + do_group_exit(SIGKILL);
4718 + }
4719 + }
4720 +#endif
4721 +
4722 if (exception_trace && printk_ratelimit())
4723 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4724 "sp %08lx ecr %lu\n",
4725 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4726 index 568885a..f8008df 100644
4727 --- a/arch/blackfin/include/asm/cache.h
4728 +++ b/arch/blackfin/include/asm/cache.h
4729 @@ -7,6 +7,7 @@
4730 #ifndef __ARCH_BLACKFIN_CACHE_H
4731 #define __ARCH_BLACKFIN_CACHE_H
4732
4733 +#include <linux/const.h>
4734 #include <linux/linkage.h> /* for asmlinkage */
4735
4736 /*
4737 @@ -14,7 +15,7 @@
4738 * Blackfin loads 32 bytes for cache
4739 */
4740 #define L1_CACHE_SHIFT 5
4741 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4742 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4743 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4744
4745 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4746 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4747 index aea2718..3639a60 100644
4748 --- a/arch/cris/include/arch-v10/arch/cache.h
4749 +++ b/arch/cris/include/arch-v10/arch/cache.h
4750 @@ -1,8 +1,9 @@
4751 #ifndef _ASM_ARCH_CACHE_H
4752 #define _ASM_ARCH_CACHE_H
4753
4754 +#include <linux/const.h>
4755 /* Etrax 100LX have 32-byte cache-lines. */
4756 -#define L1_CACHE_BYTES 32
4757 #define L1_CACHE_SHIFT 5
4758 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4759
4760 #endif /* _ASM_ARCH_CACHE_H */
4761 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4762 index 7caf25d..ee65ac5 100644
4763 --- a/arch/cris/include/arch-v32/arch/cache.h
4764 +++ b/arch/cris/include/arch-v32/arch/cache.h
4765 @@ -1,11 +1,12 @@
4766 #ifndef _ASM_CRIS_ARCH_CACHE_H
4767 #define _ASM_CRIS_ARCH_CACHE_H
4768
4769 +#include <linux/const.h>
4770 #include <arch/hwregs/dma.h>
4771
4772 /* A cache-line is 32 bytes. */
4773 -#define L1_CACHE_BYTES 32
4774 #define L1_CACHE_SHIFT 5
4775 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4776
4777 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4778
4779 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4780 index b86329d..6709906 100644
4781 --- a/arch/frv/include/asm/atomic.h
4782 +++ b/arch/frv/include/asm/atomic.h
4783 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4784 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4785 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4786
4787 +#define atomic64_read_unchecked(v) atomic64_read(v)
4788 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4789 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4790 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4791 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4792 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4793 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4794 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4795 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4796 +
4797 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4798 {
4799 int c, old;
4800 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4801 index 2797163..c2a401d 100644
4802 --- a/arch/frv/include/asm/cache.h
4803 +++ b/arch/frv/include/asm/cache.h
4804 @@ -12,10 +12,11 @@
4805 #ifndef __ASM_CACHE_H
4806 #define __ASM_CACHE_H
4807
4808 +#include <linux/const.h>
4809
4810 /* bytes per L1 cache line */
4811 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4812 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4813 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4814
4815 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4816 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4817 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4818 index 43901f2..0d8b865 100644
4819 --- a/arch/frv/include/asm/kmap_types.h
4820 +++ b/arch/frv/include/asm/kmap_types.h
4821 @@ -2,6 +2,6 @@
4822 #ifndef _ASM_KMAP_TYPES_H
4823 #define _ASM_KMAP_TYPES_H
4824
4825 -#define KM_TYPE_NR 17
4826 +#define KM_TYPE_NR 18
4827
4828 #endif
4829 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4830 index 385fd30..3aaf4fe 100644
4831 --- a/arch/frv/mm/elf-fdpic.c
4832 +++ b/arch/frv/mm/elf-fdpic.c
4833 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4834 {
4835 struct vm_area_struct *vma;
4836 unsigned long limit;
4837 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4838
4839 if (len > TASK_SIZE)
4840 return -ENOMEM;
4841 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4842 if (addr) {
4843 addr = PAGE_ALIGN(addr);
4844 vma = find_vma(current->mm, addr);
4845 - if (TASK_SIZE - len >= addr &&
4846 - (!vma || addr + len <= vma->vm_start))
4847 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4848 goto success;
4849 }
4850
4851 @@ -89,7 +89,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4852 for (; vma; vma = vma->vm_next) {
4853 if (addr > limit)
4854 break;
4855 - if (addr + len <= vma->vm_start)
4856 + if (check_heap_stack_gap(vma, addr, len, offset))
4857 goto success;
4858 addr = vma->vm_end;
4859 }
4860 @@ -104,7 +104,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4861 for (; vma; vma = vma->vm_next) {
4862 if (addr > limit)
4863 break;
4864 - if (addr + len <= vma->vm_start)
4865 + if (check_heap_stack_gap(vma, addr, len, offset))
4866 goto success;
4867 addr = vma->vm_end;
4868 }
4869 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4870 index f4ca594..adc72fd6 100644
4871 --- a/arch/hexagon/include/asm/cache.h
4872 +++ b/arch/hexagon/include/asm/cache.h
4873 @@ -21,9 +21,11 @@
4874 #ifndef __ASM_CACHE_H
4875 #define __ASM_CACHE_H
4876
4877 +#include <linux/const.h>
4878 +
4879 /* Bytes per L1 cache line */
4880 -#define L1_CACHE_SHIFT (5)
4881 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4882 +#define L1_CACHE_SHIFT 5
4883 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4884
4885 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4886 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4887 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4888 index 6e6fe18..a6ae668 100644
4889 --- a/arch/ia64/include/asm/atomic.h
4890 +++ b/arch/ia64/include/asm/atomic.h
4891 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4892 #define atomic64_inc(v) atomic64_add(1, (v))
4893 #define atomic64_dec(v) atomic64_sub(1, (v))
4894
4895 +#define atomic64_read_unchecked(v) atomic64_read(v)
4896 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4897 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4898 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4899 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4900 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4901 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4902 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4903 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4904 +
4905 /* Atomic operations are already serializing */
4906 #define smp_mb__before_atomic_dec() barrier()
4907 #define smp_mb__after_atomic_dec() barrier()
4908 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4909 index 988254a..e1ee885 100644
4910 --- a/arch/ia64/include/asm/cache.h
4911 +++ b/arch/ia64/include/asm/cache.h
4912 @@ -1,6 +1,7 @@
4913 #ifndef _ASM_IA64_CACHE_H
4914 #define _ASM_IA64_CACHE_H
4915
4916 +#include <linux/const.h>
4917
4918 /*
4919 * Copyright (C) 1998-2000 Hewlett-Packard Co
4920 @@ -9,7 +10,7 @@
4921
4922 /* Bytes per L1 (data) cache line. */
4923 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4924 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4925 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4926
4927 #ifdef CONFIG_SMP
4928 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4929 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4930 index b5298eb..67c6e62 100644
4931 --- a/arch/ia64/include/asm/elf.h
4932 +++ b/arch/ia64/include/asm/elf.h
4933 @@ -42,6 +42,13 @@
4934 */
4935 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4936
4937 +#ifdef CONFIG_PAX_ASLR
4938 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4939 +
4940 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4941 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4942 +#endif
4943 +
4944 #define PT_IA_64_UNWIND 0x70000001
4945
4946 /* IA-64 relocations: */
4947 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4948 index 96a8d92..617a1cf 100644
4949 --- a/arch/ia64/include/asm/pgalloc.h
4950 +++ b/arch/ia64/include/asm/pgalloc.h
4951 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4952 pgd_val(*pgd_entry) = __pa(pud);
4953 }
4954
4955 +static inline void
4956 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4957 +{
4958 + pgd_populate(mm, pgd_entry, pud);
4959 +}
4960 +
4961 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4962 {
4963 return quicklist_alloc(0, GFP_KERNEL, NULL);
4964 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4965 pud_val(*pud_entry) = __pa(pmd);
4966 }
4967
4968 +static inline void
4969 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4970 +{
4971 + pud_populate(mm, pud_entry, pmd);
4972 +}
4973 +
4974 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4975 {
4976 return quicklist_alloc(0, GFP_KERNEL, NULL);
4977 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4978 index 815810c..d60bd4c 100644
4979 --- a/arch/ia64/include/asm/pgtable.h
4980 +++ b/arch/ia64/include/asm/pgtable.h
4981 @@ -12,7 +12,7 @@
4982 * David Mosberger-Tang <davidm@hpl.hp.com>
4983 */
4984
4985 -
4986 +#include <linux/const.h>
4987 #include <asm/mman.h>
4988 #include <asm/page.h>
4989 #include <asm/processor.h>
4990 @@ -142,6 +142,17 @@
4991 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4992 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4993 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4994 +
4995 +#ifdef CONFIG_PAX_PAGEEXEC
4996 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4997 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4998 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4999 +#else
5000 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
5001 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
5002 +# define PAGE_COPY_NOEXEC PAGE_COPY
5003 +#endif
5004 +
5005 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
5006 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
5007 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
5008 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
5009 index 54ff557..70c88b7 100644
5010 --- a/arch/ia64/include/asm/spinlock.h
5011 +++ b/arch/ia64/include/asm/spinlock.h
5012 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
5013 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
5014
5015 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
5016 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
5017 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
5018 }
5019
5020 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
5021 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
5022 index 449c8c0..18965fb 100644
5023 --- a/arch/ia64/include/asm/uaccess.h
5024 +++ b/arch/ia64/include/asm/uaccess.h
5025 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
5026 static inline unsigned long
5027 __copy_to_user (void __user *to, const void *from, unsigned long count)
5028 {
5029 + if (count > INT_MAX)
5030 + return count;
5031 +
5032 + if (!__builtin_constant_p(count))
5033 + check_object_size(from, count, true);
5034 +
5035 return __copy_user(to, (__force void __user *) from, count);
5036 }
5037
5038 static inline unsigned long
5039 __copy_from_user (void *to, const void __user *from, unsigned long count)
5040 {
5041 + if (count > INT_MAX)
5042 + return count;
5043 +
5044 + if (!__builtin_constant_p(count))
5045 + check_object_size(to, count, false);
5046 +
5047 return __copy_user((__force void __user *) to, from, count);
5048 }
5049
5050 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5051 ({ \
5052 void __user *__cu_to = (to); \
5053 const void *__cu_from = (from); \
5054 - long __cu_len = (n); \
5055 + unsigned long __cu_len = (n); \
5056 \
5057 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
5058 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
5059 + if (!__builtin_constant_p(n)) \
5060 + check_object_size(__cu_from, __cu_len, true); \
5061 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5062 + } \
5063 __cu_len; \
5064 })
5065
5066 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5067 ({ \
5068 void *__cu_to = (to); \
5069 const void __user *__cu_from = (from); \
5070 - long __cu_len = (n); \
5071 + unsigned long __cu_len = (n); \
5072 \
5073 __chk_user_ptr(__cu_from); \
5074 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
5075 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5076 + if (!__builtin_constant_p(n)) \
5077 + check_object_size(__cu_to, __cu_len, false); \
5078 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5079 + } \
5080 __cu_len; \
5081 })
5082
5083 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
5084 index 2d67317..07d8bfa 100644
5085 --- a/arch/ia64/kernel/err_inject.c
5086 +++ b/arch/ia64/kernel/err_inject.c
5087 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
5088 return NOTIFY_OK;
5089 }
5090
5091 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
5092 +static struct notifier_block err_inject_cpu_notifier =
5093 {
5094 .notifier_call = err_inject_cpu_callback,
5095 };
5096 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
5097 index 65bf9cd..794f06b 100644
5098 --- a/arch/ia64/kernel/mca.c
5099 +++ b/arch/ia64/kernel/mca.c
5100 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
5101 return NOTIFY_OK;
5102 }
5103
5104 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
5105 +static struct notifier_block mca_cpu_notifier = {
5106 .notifier_call = mca_cpu_callback
5107 };
5108
5109 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5110 index 24603be..948052d 100644
5111 --- a/arch/ia64/kernel/module.c
5112 +++ b/arch/ia64/kernel/module.c
5113 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5114 void
5115 module_free (struct module *mod, void *module_region)
5116 {
5117 - if (mod && mod->arch.init_unw_table &&
5118 - module_region == mod->module_init) {
5119 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5120 unw_remove_unwind_table(mod->arch.init_unw_table);
5121 mod->arch.init_unw_table = NULL;
5122 }
5123 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5124 }
5125
5126 static inline int
5127 +in_init_rx (const struct module *mod, uint64_t addr)
5128 +{
5129 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5130 +}
5131 +
5132 +static inline int
5133 +in_init_rw (const struct module *mod, uint64_t addr)
5134 +{
5135 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5136 +}
5137 +
5138 +static inline int
5139 in_init (const struct module *mod, uint64_t addr)
5140 {
5141 - return addr - (uint64_t) mod->module_init < mod->init_size;
5142 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5143 +}
5144 +
5145 +static inline int
5146 +in_core_rx (const struct module *mod, uint64_t addr)
5147 +{
5148 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5149 +}
5150 +
5151 +static inline int
5152 +in_core_rw (const struct module *mod, uint64_t addr)
5153 +{
5154 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5155 }
5156
5157 static inline int
5158 in_core (const struct module *mod, uint64_t addr)
5159 {
5160 - return addr - (uint64_t) mod->module_core < mod->core_size;
5161 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5162 }
5163
5164 static inline int
5165 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5166 break;
5167
5168 case RV_BDREL:
5169 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5170 + if (in_init_rx(mod, val))
5171 + val -= (uint64_t) mod->module_init_rx;
5172 + else if (in_init_rw(mod, val))
5173 + val -= (uint64_t) mod->module_init_rw;
5174 + else if (in_core_rx(mod, val))
5175 + val -= (uint64_t) mod->module_core_rx;
5176 + else if (in_core_rw(mod, val))
5177 + val -= (uint64_t) mod->module_core_rw;
5178 break;
5179
5180 case RV_LTV:
5181 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5182 * addresses have been selected...
5183 */
5184 uint64_t gp;
5185 - if (mod->core_size > MAX_LTOFF)
5186 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5187 /*
5188 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5189 * at the end of the module.
5190 */
5191 - gp = mod->core_size - MAX_LTOFF / 2;
5192 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5193 else
5194 - gp = mod->core_size / 2;
5195 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5196 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5197 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5198 mod->arch.gp = gp;
5199 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5200 }
5201 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5202 index 77597e5..189dd62f 100644
5203 --- a/arch/ia64/kernel/palinfo.c
5204 +++ b/arch/ia64/kernel/palinfo.c
5205 @@ -977,7 +977,7 @@ create_palinfo_proc_entries(unsigned int cpu)
5206 struct proc_dir_entry **pdir;
5207 struct proc_dir_entry *cpu_dir;
5208 int j;
5209 - char cpustr[sizeof(CPUSTR)];
5210 + char cpustr[3+4+1];
5211
5212
5213 /*
5214 @@ -1045,7 +1045,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
5215 return NOTIFY_OK;
5216 }
5217
5218 -static struct notifier_block __refdata palinfo_cpu_notifier =
5219 +static struct notifier_block palinfo_cpu_notifier =
5220 {
5221 .notifier_call = palinfo_cpu_callback,
5222 .priority = 0,
5223 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
5224 index 79802e5..1a89ec5 100644
5225 --- a/arch/ia64/kernel/salinfo.c
5226 +++ b/arch/ia64/kernel/salinfo.c
5227 @@ -616,7 +616,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
5228 return NOTIFY_OK;
5229 }
5230
5231 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
5232 +static struct notifier_block salinfo_cpu_notifier =
5233 {
5234 .notifier_call = salinfo_cpu_callback,
5235 .priority = 0,
5236 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5237 index d9439ef..d0cac6b 100644
5238 --- a/arch/ia64/kernel/sys_ia64.c
5239 +++ b/arch/ia64/kernel/sys_ia64.c
5240 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5241 unsigned long start_addr, align_mask = PAGE_SIZE - 1;
5242 struct mm_struct *mm = current->mm;
5243 struct vm_area_struct *vma;
5244 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5245
5246 if (len > RGN_MAP_LIMIT)
5247 return -ENOMEM;
5248 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5249 if (REGION_NUMBER(addr) == RGN_HPAGE)
5250 addr = 0;
5251 #endif
5252 +
5253 +#ifdef CONFIG_PAX_RANDMMAP
5254 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5255 + addr = mm->free_area_cache;
5256 + else
5257 +#endif
5258 +
5259 if (!addr)
5260 addr = mm->free_area_cache;
5261
5262 @@ -61,14 +69,14 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5263 for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
5264 /* At this point: (!vma || addr < vma->vm_end). */
5265 if (TASK_SIZE - len < addr || RGN_MAP_LIMIT - len < REGION_OFFSET(addr)) {
5266 - if (start_addr != TASK_UNMAPPED_BASE) {
5267 + if (start_addr != mm->mmap_base) {
5268 /* Start a new search --- just in case we missed some holes. */
5269 - addr = TASK_UNMAPPED_BASE;
5270 + addr = mm->mmap_base;
5271 goto full_search;
5272 }
5273 return -ENOMEM;
5274 }
5275 - if (!vma || addr + len <= vma->vm_start) {
5276 + if (check_heap_stack_gap(vma, addr, len, offset)) {
5277 /* Remember the address where we stopped this search: */
5278 mm->free_area_cache = addr + len;
5279 return addr;
5280 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
5281 index dc00b2c..cce53c2 100644
5282 --- a/arch/ia64/kernel/topology.c
5283 +++ b/arch/ia64/kernel/topology.c
5284 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
5285 return NOTIFY_OK;
5286 }
5287
5288 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
5289 +static struct notifier_block cache_cpu_notifier =
5290 {
5291 .notifier_call = cache_cpu_callback
5292 };
5293 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5294 index 0ccb28f..8992469 100644
5295 --- a/arch/ia64/kernel/vmlinux.lds.S
5296 +++ b/arch/ia64/kernel/vmlinux.lds.S
5297 @@ -198,7 +198,7 @@ SECTIONS {
5298 /* Per-cpu data: */
5299 . = ALIGN(PERCPU_PAGE_SIZE);
5300 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5301 - __phys_per_cpu_start = __per_cpu_load;
5302 + __phys_per_cpu_start = per_cpu_load;
5303 /*
5304 * ensure percpu data fits
5305 * into percpu page size
5306 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5307 index 6cf0341..d352594 100644
5308 --- a/arch/ia64/mm/fault.c
5309 +++ b/arch/ia64/mm/fault.c
5310 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5311 return pte_present(pte);
5312 }
5313
5314 +#ifdef CONFIG_PAX_PAGEEXEC
5315 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5316 +{
5317 + unsigned long i;
5318 +
5319 + printk(KERN_ERR "PAX: bytes at PC: ");
5320 + for (i = 0; i < 8; i++) {
5321 + unsigned int c;
5322 + if (get_user(c, (unsigned int *)pc+i))
5323 + printk(KERN_CONT "???????? ");
5324 + else
5325 + printk(KERN_CONT "%08x ", c);
5326 + }
5327 + printk("\n");
5328 +}
5329 +#endif
5330 +
5331 # define VM_READ_BIT 0
5332 # define VM_WRITE_BIT 1
5333 # define VM_EXEC_BIT 2
5334 @@ -149,8 +166,21 @@ retry:
5335 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5336 goto bad_area;
5337
5338 - if ((vma->vm_flags & mask) != mask)
5339 + if ((vma->vm_flags & mask) != mask) {
5340 +
5341 +#ifdef CONFIG_PAX_PAGEEXEC
5342 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5343 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5344 + goto bad_area;
5345 +
5346 + up_read(&mm->mmap_sem);
5347 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5348 + do_group_exit(SIGKILL);
5349 + }
5350 +#endif
5351 +
5352 goto bad_area;
5353 + }
5354
5355 /*
5356 * If for any reason at all we couldn't handle the fault, make
5357 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5358 index 5ca674b..127c3cb 100644
5359 --- a/arch/ia64/mm/hugetlbpage.c
5360 +++ b/arch/ia64/mm/hugetlbpage.c
5361 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5362 unsigned long pgoff, unsigned long flags)
5363 {
5364 struct vm_area_struct *vmm;
5365 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5366
5367 if (len > RGN_MAP_LIMIT)
5368 return -ENOMEM;
5369 @@ -171,7 +172,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5370 /* At this point: (!vmm || addr < vmm->vm_end). */
5371 if (REGION_OFFSET(addr) + len > RGN_MAP_LIMIT)
5372 return -ENOMEM;
5373 - if (!vmm || (addr + len) <= vmm->vm_start)
5374 + if (check_heap_stack_gap(vmm, addr, len, offset))
5375 return addr;
5376 addr = ALIGN(vmm->vm_end, HPAGE_SIZE);
5377 }
5378 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5379 index b755ea9..b9a969e 100644
5380 --- a/arch/ia64/mm/init.c
5381 +++ b/arch/ia64/mm/init.c
5382 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5383 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5384 vma->vm_end = vma->vm_start + PAGE_SIZE;
5385 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5386 +
5387 +#ifdef CONFIG_PAX_PAGEEXEC
5388 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5389 + vma->vm_flags &= ~VM_EXEC;
5390 +
5391 +#ifdef CONFIG_PAX_MPROTECT
5392 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5393 + vma->vm_flags &= ~VM_MAYEXEC;
5394 +#endif
5395 +
5396 + }
5397 +#endif
5398 +
5399 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5400 down_write(&current->mm->mmap_sem);
5401 if (insert_vm_struct(current->mm, vma)) {
5402 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5403 index 40b3ee9..8c2c112 100644
5404 --- a/arch/m32r/include/asm/cache.h
5405 +++ b/arch/m32r/include/asm/cache.h
5406 @@ -1,8 +1,10 @@
5407 #ifndef _ASM_M32R_CACHE_H
5408 #define _ASM_M32R_CACHE_H
5409
5410 +#include <linux/const.h>
5411 +
5412 /* L1 cache line size */
5413 #define L1_CACHE_SHIFT 4
5414 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5415 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5416
5417 #endif /* _ASM_M32R_CACHE_H */
5418 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5419 index 82abd15..d95ae5d 100644
5420 --- a/arch/m32r/lib/usercopy.c
5421 +++ b/arch/m32r/lib/usercopy.c
5422 @@ -14,6 +14,9 @@
5423 unsigned long
5424 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5425 {
5426 + if ((long)n < 0)
5427 + return n;
5428 +
5429 prefetch(from);
5430 if (access_ok(VERIFY_WRITE, to, n))
5431 __copy_user(to,from,n);
5432 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5433 unsigned long
5434 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5435 {
5436 + if ((long)n < 0)
5437 + return n;
5438 +
5439 prefetchw(to);
5440 if (access_ok(VERIFY_READ, from, n))
5441 __copy_user_zeroing(to,from,n);
5442 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5443 index 0395c51..5f26031 100644
5444 --- a/arch/m68k/include/asm/cache.h
5445 +++ b/arch/m68k/include/asm/cache.h
5446 @@ -4,9 +4,11 @@
5447 #ifndef __ARCH_M68K_CACHE_H
5448 #define __ARCH_M68K_CACHE_H
5449
5450 +#include <linux/const.h>
5451 +
5452 /* bytes per L1 cache line */
5453 #define L1_CACHE_SHIFT 4
5454 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5455 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5456
5457 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5458
5459 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5460 index 4efe96a..60e8699 100644
5461 --- a/arch/microblaze/include/asm/cache.h
5462 +++ b/arch/microblaze/include/asm/cache.h
5463 @@ -13,11 +13,12 @@
5464 #ifndef _ASM_MICROBLAZE_CACHE_H
5465 #define _ASM_MICROBLAZE_CACHE_H
5466
5467 +#include <linux/const.h>
5468 #include <asm/registers.h>
5469
5470 #define L1_CACHE_SHIFT 5
5471 /* word-granular cache in microblaze */
5472 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5473 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5474
5475 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5476
5477 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5478 index 01cc6ba..bcb7a5d 100644
5479 --- a/arch/mips/include/asm/atomic.h
5480 +++ b/arch/mips/include/asm/atomic.h
5481 @@ -21,6 +21,10 @@
5482 #include <asm/cmpxchg.h>
5483 #include <asm/war.h>
5484
5485 +#ifdef CONFIG_GENERIC_ATOMIC64
5486 +#include <asm-generic/atomic64.h>
5487 +#endif
5488 +
5489 #define ATOMIC_INIT(i) { (i) }
5490
5491 /*
5492 @@ -759,6 +763,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5493 */
5494 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
5495
5496 +#define atomic64_read_unchecked(v) atomic64_read(v)
5497 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5498 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5499 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5500 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5501 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5502 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5503 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5504 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5505 +
5506 #endif /* CONFIG_64BIT */
5507
5508 /*
5509 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
5510 index b4db69f..8f3b093 100644
5511 --- a/arch/mips/include/asm/cache.h
5512 +++ b/arch/mips/include/asm/cache.h
5513 @@ -9,10 +9,11 @@
5514 #ifndef _ASM_CACHE_H
5515 #define _ASM_CACHE_H
5516
5517 +#include <linux/const.h>
5518 #include <kmalloc.h>
5519
5520 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
5521 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5522 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5523
5524 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5525 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5526 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
5527 index 455c0ac..ad65fbe 100644
5528 --- a/arch/mips/include/asm/elf.h
5529 +++ b/arch/mips/include/asm/elf.h
5530 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
5531 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5532 #endif
5533
5534 +#ifdef CONFIG_PAX_ASLR
5535 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5536 +
5537 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5538 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5539 +#endif
5540 +
5541 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
5542 struct linux_binprm;
5543 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
5544 int uses_interp);
5545
5546 -struct mm_struct;
5547 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
5548 -#define arch_randomize_brk arch_randomize_brk
5549 -
5550 #endif /* _ASM_ELF_H */
5551 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
5552 index c1f6afa..38cc6e9 100644
5553 --- a/arch/mips/include/asm/exec.h
5554 +++ b/arch/mips/include/asm/exec.h
5555 @@ -12,6 +12,6 @@
5556 #ifndef _ASM_EXEC_H
5557 #define _ASM_EXEC_H
5558
5559 -extern unsigned long arch_align_stack(unsigned long sp);
5560 +#define arch_align_stack(x) ((x) & ~0xfUL)
5561
5562 #endif /* _ASM_EXEC_H */
5563 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
5564 index dbaec94..6a14935 100644
5565 --- a/arch/mips/include/asm/page.h
5566 +++ b/arch/mips/include/asm/page.h
5567 @@ -96,7 +96,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
5568 #ifdef CONFIG_CPU_MIPS32
5569 typedef struct { unsigned long pte_low, pte_high; } pte_t;
5570 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
5571 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
5572 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
5573 #else
5574 typedef struct { unsigned long long pte; } pte_t;
5575 #define pte_val(x) ((x).pte)
5576 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
5577 index 881d18b..cea38bc 100644
5578 --- a/arch/mips/include/asm/pgalloc.h
5579 +++ b/arch/mips/include/asm/pgalloc.h
5580 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5581 {
5582 set_pud(pud, __pud((unsigned long)pmd));
5583 }
5584 +
5585 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5586 +{
5587 + pud_populate(mm, pud, pmd);
5588 +}
5589 #endif
5590
5591 /*
5592 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
5593 index b2050b9..d71bb1b 100644
5594 --- a/arch/mips/include/asm/thread_info.h
5595 +++ b/arch/mips/include/asm/thread_info.h
5596 @@ -111,6 +111,8 @@ register struct thread_info *__current_thread_info __asm__("$28");
5597 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
5598 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
5599 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
5600 +/* li takes a 32bit immediate */
5601 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
5602 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
5603
5604 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
5605 @@ -126,15 +128,18 @@ register struct thread_info *__current_thread_info __asm__("$28");
5606 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
5607 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
5608 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
5609 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5610 +
5611 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5612
5613 /* work to do in syscall_trace_leave() */
5614 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
5615 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5616
5617 /* work to do on interrupt/exception return */
5618 #define _TIF_WORK_MASK \
5619 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
5620 /* work to do on any return to u-space */
5621 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
5622 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
5623
5624 #endif /* __KERNEL__ */
5625
5626 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
5627 index 9fdd8bc..4bd7f1a 100644
5628 --- a/arch/mips/kernel/binfmt_elfn32.c
5629 +++ b/arch/mips/kernel/binfmt_elfn32.c
5630 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5631 #undef ELF_ET_DYN_BASE
5632 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5633
5634 +#ifdef CONFIG_PAX_ASLR
5635 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5636 +
5637 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5638 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5639 +#endif
5640 +
5641 #include <asm/processor.h>
5642 #include <linux/module.h>
5643 #include <linux/elfcore.h>
5644 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
5645 index ff44823..97f8906 100644
5646 --- a/arch/mips/kernel/binfmt_elfo32.c
5647 +++ b/arch/mips/kernel/binfmt_elfo32.c
5648 @@ -52,6 +52,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5649 #undef ELF_ET_DYN_BASE
5650 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5651
5652 +#ifdef CONFIG_PAX_ASLR
5653 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5654 +
5655 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5656 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5657 +#endif
5658 +
5659 #include <asm/processor.h>
5660
5661 /*
5662 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
5663 index a11c6f9..be5e164 100644
5664 --- a/arch/mips/kernel/process.c
5665 +++ b/arch/mips/kernel/process.c
5666 @@ -460,15 +460,3 @@ unsigned long get_wchan(struct task_struct *task)
5667 out:
5668 return pc;
5669 }
5670 -
5671 -/*
5672 - * Don't forget that the stack pointer must be aligned on a 8 bytes
5673 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
5674 - */
5675 -unsigned long arch_align_stack(unsigned long sp)
5676 -{
5677 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
5678 - sp -= get_random_int() & ~PAGE_MASK;
5679 -
5680 - return sp & ALMASK;
5681 -}
5682 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
5683 index 4812c6d..2069554 100644
5684 --- a/arch/mips/kernel/ptrace.c
5685 +++ b/arch/mips/kernel/ptrace.c
5686 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
5687 return arch;
5688 }
5689
5690 +#ifdef CONFIG_GRKERNSEC_SETXID
5691 +extern void gr_delayed_cred_worker(void);
5692 +#endif
5693 +
5694 /*
5695 * Notification of system call entry/exit
5696 * - triggered by current->work.syscall_trace
5697 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
5698 /* do the secure computing check first */
5699 secure_computing_strict(regs->regs[2]);
5700
5701 +#ifdef CONFIG_GRKERNSEC_SETXID
5702 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5703 + gr_delayed_cred_worker();
5704 +#endif
5705 +
5706 if (!(current->ptrace & PT_PTRACED))
5707 goto out;
5708
5709 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
5710 index d20a4bc..7096ae5 100644
5711 --- a/arch/mips/kernel/scall32-o32.S
5712 +++ b/arch/mips/kernel/scall32-o32.S
5713 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5714
5715 stack_done:
5716 lw t0, TI_FLAGS($28) # syscall tracing enabled?
5717 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5718 + li t1, _TIF_SYSCALL_WORK
5719 and t0, t1
5720 bnez t0, syscall_trace_entry # -> yes
5721
5722 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
5723 index b64f642..0fe6eab 100644
5724 --- a/arch/mips/kernel/scall64-64.S
5725 +++ b/arch/mips/kernel/scall64-64.S
5726 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
5727
5728 sd a3, PT_R26(sp) # save a3 for syscall restarting
5729
5730 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5731 + li t1, _TIF_SYSCALL_WORK
5732 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5733 and t0, t1, t0
5734 bnez t0, syscall_trace_entry
5735 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
5736 index c29ac19..c592d05 100644
5737 --- a/arch/mips/kernel/scall64-n32.S
5738 +++ b/arch/mips/kernel/scall64-n32.S
5739 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
5740
5741 sd a3, PT_R26(sp) # save a3 for syscall restarting
5742
5743 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5744 + li t1, _TIF_SYSCALL_WORK
5745 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5746 and t0, t1, t0
5747 bnez t0, n32_syscall_trace_entry
5748 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
5749 index cf3e75e..72e93fe 100644
5750 --- a/arch/mips/kernel/scall64-o32.S
5751 +++ b/arch/mips/kernel/scall64-o32.S
5752 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5753 PTR 4b, bad_stack
5754 .previous
5755
5756 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5757 + li t1, _TIF_SYSCALL_WORK
5758 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5759 and t0, t1, t0
5760 bnez t0, trace_a_syscall
5761 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
5762 index ddcec1e..c7f983e 100644
5763 --- a/arch/mips/mm/fault.c
5764 +++ b/arch/mips/mm/fault.c
5765 @@ -27,6 +27,23 @@
5766 #include <asm/highmem.h> /* For VMALLOC_END */
5767 #include <linux/kdebug.h>
5768
5769 +#ifdef CONFIG_PAX_PAGEEXEC
5770 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5771 +{
5772 + unsigned long i;
5773 +
5774 + printk(KERN_ERR "PAX: bytes at PC: ");
5775 + for (i = 0; i < 5; i++) {
5776 + unsigned int c;
5777 + if (get_user(c, (unsigned int *)pc+i))
5778 + printk(KERN_CONT "???????? ");
5779 + else
5780 + printk(KERN_CONT "%08x ", c);
5781 + }
5782 + printk("\n");
5783 +}
5784 +#endif
5785 +
5786 /*
5787 * This routine handles page faults. It determines the address,
5788 * and the problem, and then passes it off to one of the appropriate
5789 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
5790 index 7e5fe27..479a219 100644
5791 --- a/arch/mips/mm/mmap.c
5792 +++ b/arch/mips/mm/mmap.c
5793 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5794 struct vm_area_struct *vma;
5795 unsigned long addr = addr0;
5796 int do_color_align;
5797 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5798 struct vm_unmapped_area_info info;
5799
5800 if (unlikely(len > TASK_SIZE))
5801 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5802 do_color_align = 1;
5803
5804 /* requesting a specific address */
5805 +
5806 +#ifdef CONFIG_PAX_RANDMMAP
5807 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
5808 +#endif
5809 +
5810 if (addr) {
5811 if (do_color_align)
5812 addr = COLOUR_ALIGN(addr, pgoff);
5813 @@ -91,8 +97,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5814 addr = PAGE_ALIGN(addr);
5815
5816 vma = find_vma(mm, addr);
5817 - if (TASK_SIZE - len >= addr &&
5818 - (!vma || addr + len <= vma->vm_start))
5819 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
5820 return addr;
5821 }
5822
5823 @@ -146,6 +151,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5824 {
5825 unsigned long random_factor = 0UL;
5826
5827 +#ifdef CONFIG_PAX_RANDMMAP
5828 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5829 +#endif
5830 +
5831 if (current->flags & PF_RANDOMIZE) {
5832 random_factor = get_random_int();
5833 random_factor = random_factor << PAGE_SHIFT;
5834 @@ -157,42 +166,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5835
5836 if (mmap_is_legacy()) {
5837 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5838 +
5839 +#ifdef CONFIG_PAX_RANDMMAP
5840 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5841 + mm->mmap_base += mm->delta_mmap;
5842 +#endif
5843 +
5844 mm->get_unmapped_area = arch_get_unmapped_area;
5845 mm->unmap_area = arch_unmap_area;
5846 } else {
5847 mm->mmap_base = mmap_base(random_factor);
5848 +
5849 +#ifdef CONFIG_PAX_RANDMMAP
5850 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5851 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5852 +#endif
5853 +
5854 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5855 mm->unmap_area = arch_unmap_area_topdown;
5856 }
5857 }
5858
5859 -static inline unsigned long brk_rnd(void)
5860 -{
5861 - unsigned long rnd = get_random_int();
5862 -
5863 - rnd = rnd << PAGE_SHIFT;
5864 - /* 8MB for 32bit, 256MB for 64bit */
5865 - if (TASK_IS_32BIT_ADDR)
5866 - rnd = rnd & 0x7ffffful;
5867 - else
5868 - rnd = rnd & 0xffffffful;
5869 -
5870 - return rnd;
5871 -}
5872 -
5873 -unsigned long arch_randomize_brk(struct mm_struct *mm)
5874 -{
5875 - unsigned long base = mm->brk;
5876 - unsigned long ret;
5877 -
5878 - ret = PAGE_ALIGN(base + brk_rnd());
5879 -
5880 - if (ret < mm->brk)
5881 - return mm->brk;
5882 -
5883 - return ret;
5884 -}
5885 -
5886 int __virt_addr_valid(const volatile void *kaddr)
5887 {
5888 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
5889 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5890 index 967d144..db12197 100644
5891 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
5892 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5893 @@ -11,12 +11,14 @@
5894 #ifndef _ASM_PROC_CACHE_H
5895 #define _ASM_PROC_CACHE_H
5896
5897 +#include <linux/const.h>
5898 +
5899 /* L1 cache */
5900
5901 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5902 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
5903 -#define L1_CACHE_BYTES 16 /* bytes per entry */
5904 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
5905 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5906 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
5907
5908 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5909 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5910 index bcb5df2..84fabd2 100644
5911 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5912 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5913 @@ -16,13 +16,15 @@
5914 #ifndef _ASM_PROC_CACHE_H
5915 #define _ASM_PROC_CACHE_H
5916
5917 +#include <linux/const.h>
5918 +
5919 /*
5920 * L1 cache
5921 */
5922 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5923 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
5924 -#define L1_CACHE_BYTES 32 /* bytes per entry */
5925 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
5926 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5927 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
5928
5929 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5930 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
5931 index 4ce7a01..449202a 100644
5932 --- a/arch/openrisc/include/asm/cache.h
5933 +++ b/arch/openrisc/include/asm/cache.h
5934 @@ -19,11 +19,13 @@
5935 #ifndef __ASM_OPENRISC_CACHE_H
5936 #define __ASM_OPENRISC_CACHE_H
5937
5938 +#include <linux/const.h>
5939 +
5940 /* FIXME: How can we replace these with values from the CPU...
5941 * they shouldn't be hard-coded!
5942 */
5943
5944 -#define L1_CACHE_BYTES 16
5945 #define L1_CACHE_SHIFT 4
5946 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5947
5948 #endif /* __ASM_OPENRISC_CACHE_H */
5949 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
5950 index af9cf30..2aae9b2 100644
5951 --- a/arch/parisc/include/asm/atomic.h
5952 +++ b/arch/parisc/include/asm/atomic.h
5953 @@ -229,6 +229,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5954
5955 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
5956
5957 +#define atomic64_read_unchecked(v) atomic64_read(v)
5958 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5959 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5960 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5961 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5962 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5963 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5964 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5965 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5966 +
5967 #endif /* !CONFIG_64BIT */
5968
5969
5970 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
5971 index 47f11c7..3420df2 100644
5972 --- a/arch/parisc/include/asm/cache.h
5973 +++ b/arch/parisc/include/asm/cache.h
5974 @@ -5,6 +5,7 @@
5975 #ifndef __ARCH_PARISC_CACHE_H
5976 #define __ARCH_PARISC_CACHE_H
5977
5978 +#include <linux/const.h>
5979
5980 /*
5981 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
5982 @@ -15,13 +16,13 @@
5983 * just ruin performance.
5984 */
5985 #ifdef CONFIG_PA20
5986 -#define L1_CACHE_BYTES 64
5987 #define L1_CACHE_SHIFT 6
5988 #else
5989 -#define L1_CACHE_BYTES 32
5990 #define L1_CACHE_SHIFT 5
5991 #endif
5992
5993 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5994 +
5995 #ifndef __ASSEMBLY__
5996
5997 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5998 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
5999 index 19f6cb1..6c78cf2 100644
6000 --- a/arch/parisc/include/asm/elf.h
6001 +++ b/arch/parisc/include/asm/elf.h
6002 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
6003
6004 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
6005
6006 +#ifdef CONFIG_PAX_ASLR
6007 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
6008 +
6009 +#define PAX_DELTA_MMAP_LEN 16
6010 +#define PAX_DELTA_STACK_LEN 16
6011 +#endif
6012 +
6013 /* This yields a mask that user programs can use to figure out what
6014 instruction set this CPU supports. This could be done in user space,
6015 but it's not easy, and we've already done it here. */
6016 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
6017 index fc987a1..6e068ef 100644
6018 --- a/arch/parisc/include/asm/pgalloc.h
6019 +++ b/arch/parisc/include/asm/pgalloc.h
6020 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
6021 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
6022 }
6023
6024 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
6025 +{
6026 + pgd_populate(mm, pgd, pmd);
6027 +}
6028 +
6029 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
6030 {
6031 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
6032 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
6033 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
6034 #define pmd_free(mm, x) do { } while (0)
6035 #define pgd_populate(mm, pmd, pte) BUG()
6036 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
6037
6038 #endif
6039
6040 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
6041 index 7df49fa..38b62bf 100644
6042 --- a/arch/parisc/include/asm/pgtable.h
6043 +++ b/arch/parisc/include/asm/pgtable.h
6044 @@ -218,6 +218,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
6045 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
6046 #define PAGE_COPY PAGE_EXECREAD
6047 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
6048 +
6049 +#ifdef CONFIG_PAX_PAGEEXEC
6050 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
6051 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
6052 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
6053 +#else
6054 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
6055 +# define PAGE_COPY_NOEXEC PAGE_COPY
6056 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
6057 +#endif
6058 +
6059 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
6060 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
6061 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
6062 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
6063 index 4ba2c93..f5e3974 100644
6064 --- a/arch/parisc/include/asm/uaccess.h
6065 +++ b/arch/parisc/include/asm/uaccess.h
6066 @@ -251,10 +251,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
6067 const void __user *from,
6068 unsigned long n)
6069 {
6070 - int sz = __compiletime_object_size(to);
6071 + size_t sz = __compiletime_object_size(to);
6072 int ret = -EFAULT;
6073
6074 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
6075 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
6076 ret = __copy_from_user(to, from, n);
6077 else
6078 copy_from_user_overflow();
6079 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
6080 index 2a625fb..9908930 100644
6081 --- a/arch/parisc/kernel/module.c
6082 +++ b/arch/parisc/kernel/module.c
6083 @@ -98,16 +98,38 @@
6084
6085 /* three functions to determine where in the module core
6086 * or init pieces the location is */
6087 +static inline int in_init_rx(struct module *me, void *loc)
6088 +{
6089 + return (loc >= me->module_init_rx &&
6090 + loc < (me->module_init_rx + me->init_size_rx));
6091 +}
6092 +
6093 +static inline int in_init_rw(struct module *me, void *loc)
6094 +{
6095 + return (loc >= me->module_init_rw &&
6096 + loc < (me->module_init_rw + me->init_size_rw));
6097 +}
6098 +
6099 static inline int in_init(struct module *me, void *loc)
6100 {
6101 - return (loc >= me->module_init &&
6102 - loc <= (me->module_init + me->init_size));
6103 + return in_init_rx(me, loc) || in_init_rw(me, loc);
6104 +}
6105 +
6106 +static inline int in_core_rx(struct module *me, void *loc)
6107 +{
6108 + return (loc >= me->module_core_rx &&
6109 + loc < (me->module_core_rx + me->core_size_rx));
6110 +}
6111 +
6112 +static inline int in_core_rw(struct module *me, void *loc)
6113 +{
6114 + return (loc >= me->module_core_rw &&
6115 + loc < (me->module_core_rw + me->core_size_rw));
6116 }
6117
6118 static inline int in_core(struct module *me, void *loc)
6119 {
6120 - return (loc >= me->module_core &&
6121 - loc <= (me->module_core + me->core_size));
6122 + return in_core_rx(me, loc) || in_core_rw(me, loc);
6123 }
6124
6125 static inline int in_local(struct module *me, void *loc)
6126 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
6127 }
6128
6129 /* align things a bit */
6130 - me->core_size = ALIGN(me->core_size, 16);
6131 - me->arch.got_offset = me->core_size;
6132 - me->core_size += gots * sizeof(struct got_entry);
6133 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
6134 + me->arch.got_offset = me->core_size_rw;
6135 + me->core_size_rw += gots * sizeof(struct got_entry);
6136
6137 - me->core_size = ALIGN(me->core_size, 16);
6138 - me->arch.fdesc_offset = me->core_size;
6139 - me->core_size += fdescs * sizeof(Elf_Fdesc);
6140 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
6141 + me->arch.fdesc_offset = me->core_size_rw;
6142 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
6143
6144 me->arch.got_max = gots;
6145 me->arch.fdesc_max = fdescs;
6146 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
6147
6148 BUG_ON(value == 0);
6149
6150 - got = me->module_core + me->arch.got_offset;
6151 + got = me->module_core_rw + me->arch.got_offset;
6152 for (i = 0; got[i].addr; i++)
6153 if (got[i].addr == value)
6154 goto out;
6155 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
6156 #ifdef CONFIG_64BIT
6157 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
6158 {
6159 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
6160 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
6161
6162 if (!value) {
6163 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
6164 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
6165
6166 /* Create new one */
6167 fdesc->addr = value;
6168 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
6169 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
6170 return (Elf_Addr)fdesc;
6171 }
6172 #endif /* CONFIG_64BIT */
6173 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
6174
6175 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
6176 end = table + sechdrs[me->arch.unwind_section].sh_size;
6177 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
6178 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
6179
6180 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
6181 me->arch.unwind_section, table, end, gp);
6182 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
6183 index f76c108..92bad82 100644
6184 --- a/arch/parisc/kernel/sys_parisc.c
6185 +++ b/arch/parisc/kernel/sys_parisc.c
6186 @@ -33,9 +33,11 @@
6187 #include <linux/utsname.h>
6188 #include <linux/personality.h>
6189
6190 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
6191 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
6192 + unsigned long flags)
6193 {
6194 struct vm_area_struct *vma;
6195 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
6196
6197 addr = PAGE_ALIGN(addr);
6198
6199 @@ -43,7 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
6200 /* At this point: (!vma || addr < vma->vm_end). */
6201 if (TASK_SIZE - len < addr)
6202 return -ENOMEM;
6203 - if (!vma || addr + len <= vma->vm_start)
6204 + if (check_heap_stack_gap(vma, addr, len, offset))
6205 return addr;
6206 addr = vma->vm_end;
6207 }
6208 @@ -67,11 +69,12 @@ static int get_offset(struct address_space *mapping)
6209 return offset & 0x3FF000;
6210 }
6211
6212 -static unsigned long get_shared_area(struct address_space *mapping,
6213 - unsigned long addr, unsigned long len, unsigned long pgoff)
6214 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
6215 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
6216 {
6217 struct vm_area_struct *vma;
6218 int offset = mapping ? get_offset(mapping) : 0;
6219 + unsigned long rand_offset = gr_rand_threadstack_offset(current->mm, filp, flags);
6220
6221 offset = (offset + (pgoff << PAGE_SHIFT)) & 0x3FF000;
6222
6223 @@ -81,7 +84,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
6224 /* At this point: (!vma || addr < vma->vm_end). */
6225 if (TASK_SIZE - len < addr)
6226 return -ENOMEM;
6227 - if (!vma || addr + len <= vma->vm_start)
6228 + if (check_heap_stack_gap(vma, addr, len, rand_offset))
6229 return addr;
6230 addr = DCACHE_ALIGN(vma->vm_end - offset) + offset;
6231 if (addr < vma->vm_end) /* handle wraparound */
6232 @@ -100,14 +103,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
6233 if (flags & MAP_FIXED)
6234 return addr;
6235 if (!addr)
6236 - addr = TASK_UNMAPPED_BASE;
6237 + addr = current->mm->mmap_base;
6238
6239 if (filp) {
6240 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
6241 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
6242 } else if(flags & MAP_SHARED) {
6243 - addr = get_shared_area(NULL, addr, len, pgoff);
6244 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
6245 } else {
6246 - addr = get_unshared_area(addr, len);
6247 + addr = get_unshared_area(filp, addr, len, flags);
6248 }
6249 return addr;
6250 }
6251 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
6252 index 45ba99f..8e22c33 100644
6253 --- a/arch/parisc/kernel/traps.c
6254 +++ b/arch/parisc/kernel/traps.c
6255 @@ -732,9 +732,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
6256
6257 down_read(&current->mm->mmap_sem);
6258 vma = find_vma(current->mm,regs->iaoq[0]);
6259 - if (vma && (regs->iaoq[0] >= vma->vm_start)
6260 - && (vma->vm_flags & VM_EXEC)) {
6261 -
6262 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
6263 fault_address = regs->iaoq[0];
6264 fault_space = regs->iasq[0];
6265
6266 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
6267 index 18162ce..94de376 100644
6268 --- a/arch/parisc/mm/fault.c
6269 +++ b/arch/parisc/mm/fault.c
6270 @@ -15,6 +15,7 @@
6271 #include <linux/sched.h>
6272 #include <linux/interrupt.h>
6273 #include <linux/module.h>
6274 +#include <linux/unistd.h>
6275
6276 #include <asm/uaccess.h>
6277 #include <asm/traps.h>
6278 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
6279 static unsigned long
6280 parisc_acctyp(unsigned long code, unsigned int inst)
6281 {
6282 - if (code == 6 || code == 16)
6283 + if (code == 6 || code == 7 || code == 16)
6284 return VM_EXEC;
6285
6286 switch (inst & 0xf0000000) {
6287 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
6288 }
6289 #endif
6290
6291 +#ifdef CONFIG_PAX_PAGEEXEC
6292 +/*
6293 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
6294 + *
6295 + * returns 1 when task should be killed
6296 + * 2 when rt_sigreturn trampoline was detected
6297 + * 3 when unpatched PLT trampoline was detected
6298 + */
6299 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6300 +{
6301 +
6302 +#ifdef CONFIG_PAX_EMUPLT
6303 + int err;
6304 +
6305 + do { /* PaX: unpatched PLT emulation */
6306 + unsigned int bl, depwi;
6307 +
6308 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
6309 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
6310 +
6311 + if (err)
6312 + break;
6313 +
6314 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
6315 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
6316 +
6317 + err = get_user(ldw, (unsigned int *)addr);
6318 + err |= get_user(bv, (unsigned int *)(addr+4));
6319 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6320 +
6321 + if (err)
6322 + break;
6323 +
6324 + if (ldw == 0x0E801096U &&
6325 + bv == 0xEAC0C000U &&
6326 + ldw2 == 0x0E881095U)
6327 + {
6328 + unsigned int resolver, map;
6329 +
6330 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6331 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6332 + if (err)
6333 + break;
6334 +
6335 + regs->gr[20] = instruction_pointer(regs)+8;
6336 + regs->gr[21] = map;
6337 + regs->gr[22] = resolver;
6338 + regs->iaoq[0] = resolver | 3UL;
6339 + regs->iaoq[1] = regs->iaoq[0] + 4;
6340 + return 3;
6341 + }
6342 + }
6343 + } while (0);
6344 +#endif
6345 +
6346 +#ifdef CONFIG_PAX_EMUTRAMP
6347 +
6348 +#ifndef CONFIG_PAX_EMUSIGRT
6349 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6350 + return 1;
6351 +#endif
6352 +
6353 + do { /* PaX: rt_sigreturn emulation */
6354 + unsigned int ldi1, ldi2, bel, nop;
6355 +
6356 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6357 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6358 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6359 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6360 +
6361 + if (err)
6362 + break;
6363 +
6364 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6365 + ldi2 == 0x3414015AU &&
6366 + bel == 0xE4008200U &&
6367 + nop == 0x08000240U)
6368 + {
6369 + regs->gr[25] = (ldi1 & 2) >> 1;
6370 + regs->gr[20] = __NR_rt_sigreturn;
6371 + regs->gr[31] = regs->iaoq[1] + 16;
6372 + regs->sr[0] = regs->iasq[1];
6373 + regs->iaoq[0] = 0x100UL;
6374 + regs->iaoq[1] = regs->iaoq[0] + 4;
6375 + regs->iasq[0] = regs->sr[2];
6376 + regs->iasq[1] = regs->sr[2];
6377 + return 2;
6378 + }
6379 + } while (0);
6380 +#endif
6381 +
6382 + return 1;
6383 +}
6384 +
6385 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6386 +{
6387 + unsigned long i;
6388 +
6389 + printk(KERN_ERR "PAX: bytes at PC: ");
6390 + for (i = 0; i < 5; i++) {
6391 + unsigned int c;
6392 + if (get_user(c, (unsigned int *)pc+i))
6393 + printk(KERN_CONT "???????? ");
6394 + else
6395 + printk(KERN_CONT "%08x ", c);
6396 + }
6397 + printk("\n");
6398 +}
6399 +#endif
6400 +
6401 int fixup_exception(struct pt_regs *regs)
6402 {
6403 const struct exception_table_entry *fix;
6404 @@ -192,8 +303,33 @@ good_area:
6405
6406 acc_type = parisc_acctyp(code,regs->iir);
6407
6408 - if ((vma->vm_flags & acc_type) != acc_type)
6409 + if ((vma->vm_flags & acc_type) != acc_type) {
6410 +
6411 +#ifdef CONFIG_PAX_PAGEEXEC
6412 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6413 + (address & ~3UL) == instruction_pointer(regs))
6414 + {
6415 + up_read(&mm->mmap_sem);
6416 + switch (pax_handle_fetch_fault(regs)) {
6417 +
6418 +#ifdef CONFIG_PAX_EMUPLT
6419 + case 3:
6420 + return;
6421 +#endif
6422 +
6423 +#ifdef CONFIG_PAX_EMUTRAMP
6424 + case 2:
6425 + return;
6426 +#endif
6427 +
6428 + }
6429 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6430 + do_group_exit(SIGKILL);
6431 + }
6432 +#endif
6433 +
6434 goto bad_area;
6435 + }
6436
6437 /*
6438 * If for any reason at all we couldn't handle the fault, make
6439 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6440 index e3b1d41..8e81edf 100644
6441 --- a/arch/powerpc/include/asm/atomic.h
6442 +++ b/arch/powerpc/include/asm/atomic.h
6443 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6444 return t1;
6445 }
6446
6447 +#define atomic64_read_unchecked(v) atomic64_read(v)
6448 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6449 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6450 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6451 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6452 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6453 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6454 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6455 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6456 +
6457 #endif /* __powerpc64__ */
6458
6459 #endif /* __KERNEL__ */
6460 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6461 index 9e495c9..b6878e5 100644
6462 --- a/arch/powerpc/include/asm/cache.h
6463 +++ b/arch/powerpc/include/asm/cache.h
6464 @@ -3,6 +3,7 @@
6465
6466 #ifdef __KERNEL__
6467
6468 +#include <linux/const.h>
6469
6470 /* bytes per L1 cache line */
6471 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6472 @@ -22,7 +23,7 @@
6473 #define L1_CACHE_SHIFT 7
6474 #endif
6475
6476 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6477 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6478
6479 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6480
6481 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6482 index 6abf0a1..459d0f1 100644
6483 --- a/arch/powerpc/include/asm/elf.h
6484 +++ b/arch/powerpc/include/asm/elf.h
6485 @@ -28,8 +28,19 @@
6486 the loader. We need to make sure that it is out of the way of the program
6487 that it will "exec", and that there is sufficient room for the brk. */
6488
6489 -extern unsigned long randomize_et_dyn(unsigned long base);
6490 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6491 +#define ELF_ET_DYN_BASE (0x20000000)
6492 +
6493 +#ifdef CONFIG_PAX_ASLR
6494 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6495 +
6496 +#ifdef __powerpc64__
6497 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6498 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6499 +#else
6500 +#define PAX_DELTA_MMAP_LEN 15
6501 +#define PAX_DELTA_STACK_LEN 15
6502 +#endif
6503 +#endif
6504
6505 /*
6506 * Our registers are always unsigned longs, whether we're a 32 bit
6507 @@ -124,10 +135,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6508 (0x7ff >> (PAGE_SHIFT - 12)) : \
6509 (0x3ffff >> (PAGE_SHIFT - 12)))
6510
6511 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6512 -#define arch_randomize_brk arch_randomize_brk
6513 -
6514 -
6515 #ifdef CONFIG_SPU_BASE
6516 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6517 #define NT_SPU 1
6518 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6519 index 8196e9c..d83a9f3 100644
6520 --- a/arch/powerpc/include/asm/exec.h
6521 +++ b/arch/powerpc/include/asm/exec.h
6522 @@ -4,6 +4,6 @@
6523 #ifndef _ASM_POWERPC_EXEC_H
6524 #define _ASM_POWERPC_EXEC_H
6525
6526 -extern unsigned long arch_align_stack(unsigned long sp);
6527 +#define arch_align_stack(x) ((x) & ~0xfUL)
6528
6529 #endif /* _ASM_POWERPC_EXEC_H */
6530 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6531 index 5acabbd..7ea14fa 100644
6532 --- a/arch/powerpc/include/asm/kmap_types.h
6533 +++ b/arch/powerpc/include/asm/kmap_types.h
6534 @@ -10,7 +10,7 @@
6535 * 2 of the License, or (at your option) any later version.
6536 */
6537
6538 -#define KM_TYPE_NR 16
6539 +#define KM_TYPE_NR 17
6540
6541 #endif /* __KERNEL__ */
6542 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6543 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6544 index 8565c25..2865190 100644
6545 --- a/arch/powerpc/include/asm/mman.h
6546 +++ b/arch/powerpc/include/asm/mman.h
6547 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6548 }
6549 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6550
6551 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6552 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6553 {
6554 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6555 }
6556 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6557 index f072e97..b436dee 100644
6558 --- a/arch/powerpc/include/asm/page.h
6559 +++ b/arch/powerpc/include/asm/page.h
6560 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6561 * and needs to be executable. This means the whole heap ends
6562 * up being executable.
6563 */
6564 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6565 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6566 +#define VM_DATA_DEFAULT_FLAGS32 \
6567 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6568 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6569
6570 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6571 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6572 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6573 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6574 #endif
6575
6576 +#define ktla_ktva(addr) (addr)
6577 +#define ktva_ktla(addr) (addr)
6578 +
6579 /*
6580 * Use the top bit of the higher-level page table entries to indicate whether
6581 * the entries we point to contain hugepages. This works because we know that
6582 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6583 index cd915d6..c10cee8 100644
6584 --- a/arch/powerpc/include/asm/page_64.h
6585 +++ b/arch/powerpc/include/asm/page_64.h
6586 @@ -154,15 +154,18 @@ do { \
6587 * stack by default, so in the absence of a PT_GNU_STACK program header
6588 * we turn execute permission off.
6589 */
6590 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6591 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6592 +#define VM_STACK_DEFAULT_FLAGS32 \
6593 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6594 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6595
6596 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6597 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6598
6599 +#ifndef CONFIG_PAX_PAGEEXEC
6600 #define VM_STACK_DEFAULT_FLAGS \
6601 (is_32bit_task() ? \
6602 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6603 +#endif
6604
6605 #include <asm-generic/getorder.h>
6606
6607 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6608 index 292725c..f87ae14 100644
6609 --- a/arch/powerpc/include/asm/pgalloc-64.h
6610 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6611 @@ -50,6 +50,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6612 #ifndef CONFIG_PPC_64K_PAGES
6613
6614 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6615 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6616
6617 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6618 {
6619 @@ -67,6 +68,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6620 pud_set(pud, (unsigned long)pmd);
6621 }
6622
6623 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6624 +{
6625 + pud_populate(mm, pud, pmd);
6626 +}
6627 +
6628 #define pmd_populate(mm, pmd, pte_page) \
6629 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6630 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6631 @@ -76,6 +82,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6632 #else /* CONFIG_PPC_64K_PAGES */
6633
6634 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6635 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6636
6637 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6638 pte_t *pte)
6639 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6640 index a9cbd3b..3b67efa 100644
6641 --- a/arch/powerpc/include/asm/pgtable.h
6642 +++ b/arch/powerpc/include/asm/pgtable.h
6643 @@ -2,6 +2,7 @@
6644 #define _ASM_POWERPC_PGTABLE_H
6645 #ifdef __KERNEL__
6646
6647 +#include <linux/const.h>
6648 #ifndef __ASSEMBLY__
6649 #include <asm/processor.h> /* For TASK_SIZE */
6650 #include <asm/mmu.h>
6651 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6652 index 4aad413..85d86bf 100644
6653 --- a/arch/powerpc/include/asm/pte-hash32.h
6654 +++ b/arch/powerpc/include/asm/pte-hash32.h
6655 @@ -21,6 +21,7 @@
6656 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6657 #define _PAGE_USER 0x004 /* usermode access allowed */
6658 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6659 +#define _PAGE_EXEC _PAGE_GUARDED
6660 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6661 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6662 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6663 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6664 index 3d5c9dc..62f8414 100644
6665 --- a/arch/powerpc/include/asm/reg.h
6666 +++ b/arch/powerpc/include/asm/reg.h
6667 @@ -215,6 +215,7 @@
6668 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6669 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6670 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6671 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6672 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6673 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6674 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6675 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6676 index 406b7b9..af63426 100644
6677 --- a/arch/powerpc/include/asm/thread_info.h
6678 +++ b/arch/powerpc/include/asm/thread_info.h
6679 @@ -97,7 +97,6 @@ static inline struct thread_info *current_thread_info(void)
6680 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6681 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6682 #define TIF_SINGLESTEP 8 /* singlestepping active */
6683 -#define TIF_MEMDIE 9 /* is terminating due to OOM killer */
6684 #define TIF_SECCOMP 10 /* secure computing */
6685 #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
6686 #define TIF_NOERROR 12 /* Force successful syscall return */
6687 @@ -106,6 +105,9 @@ static inline struct thread_info *current_thread_info(void)
6688 #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
6689 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6690 for stack store? */
6691 +#define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6692 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6693 +#define TIF_GRSEC_SETXID 9 /* update credentials on syscall entry/exit */
6694
6695 /* as above, but as bit values */
6696 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6697 @@ -124,8 +126,10 @@ static inline struct thread_info *current_thread_info(void)
6698 #define _TIF_UPROBE (1<<TIF_UPROBE)
6699 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6700 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6701 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6702 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6703 - _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
6704 + _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6705 + _TIF_GRSEC_SETXID)
6706
6707 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6708 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6709 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6710 index 4db4959..aba5c41 100644
6711 --- a/arch/powerpc/include/asm/uaccess.h
6712 +++ b/arch/powerpc/include/asm/uaccess.h
6713 @@ -318,52 +318,6 @@ do { \
6714 extern unsigned long __copy_tofrom_user(void __user *to,
6715 const void __user *from, unsigned long size);
6716
6717 -#ifndef __powerpc64__
6718 -
6719 -static inline unsigned long copy_from_user(void *to,
6720 - const void __user *from, unsigned long n)
6721 -{
6722 - unsigned long over;
6723 -
6724 - if (access_ok(VERIFY_READ, from, n))
6725 - return __copy_tofrom_user((__force void __user *)to, from, n);
6726 - if ((unsigned long)from < TASK_SIZE) {
6727 - over = (unsigned long)from + n - TASK_SIZE;
6728 - return __copy_tofrom_user((__force void __user *)to, from,
6729 - n - over) + over;
6730 - }
6731 - return n;
6732 -}
6733 -
6734 -static inline unsigned long copy_to_user(void __user *to,
6735 - const void *from, unsigned long n)
6736 -{
6737 - unsigned long over;
6738 -
6739 - if (access_ok(VERIFY_WRITE, to, n))
6740 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6741 - if ((unsigned long)to < TASK_SIZE) {
6742 - over = (unsigned long)to + n - TASK_SIZE;
6743 - return __copy_tofrom_user(to, (__force void __user *)from,
6744 - n - over) + over;
6745 - }
6746 - return n;
6747 -}
6748 -
6749 -#else /* __powerpc64__ */
6750 -
6751 -#define __copy_in_user(to, from, size) \
6752 - __copy_tofrom_user((to), (from), (size))
6753 -
6754 -extern unsigned long copy_from_user(void *to, const void __user *from,
6755 - unsigned long n);
6756 -extern unsigned long copy_to_user(void __user *to, const void *from,
6757 - unsigned long n);
6758 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6759 - unsigned long n);
6760 -
6761 -#endif /* __powerpc64__ */
6762 -
6763 static inline unsigned long __copy_from_user_inatomic(void *to,
6764 const void __user *from, unsigned long n)
6765 {
6766 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6767 if (ret == 0)
6768 return 0;
6769 }
6770 +
6771 + if (!__builtin_constant_p(n))
6772 + check_object_size(to, n, false);
6773 +
6774 return __copy_tofrom_user((__force void __user *)to, from, n);
6775 }
6776
6777 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6778 if (ret == 0)
6779 return 0;
6780 }
6781 +
6782 + if (!__builtin_constant_p(n))
6783 + check_object_size(from, n, true);
6784 +
6785 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6786 }
6787
6788 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6789 return __copy_to_user_inatomic(to, from, size);
6790 }
6791
6792 +#ifndef __powerpc64__
6793 +
6794 +static inline unsigned long __must_check copy_from_user(void *to,
6795 + const void __user *from, unsigned long n)
6796 +{
6797 + unsigned long over;
6798 +
6799 + if ((long)n < 0)
6800 + return n;
6801 +
6802 + if (access_ok(VERIFY_READ, from, n)) {
6803 + if (!__builtin_constant_p(n))
6804 + check_object_size(to, n, false);
6805 + return __copy_tofrom_user((__force void __user *)to, from, n);
6806 + }
6807 + if ((unsigned long)from < TASK_SIZE) {
6808 + over = (unsigned long)from + n - TASK_SIZE;
6809 + if (!__builtin_constant_p(n - over))
6810 + check_object_size(to, n - over, false);
6811 + return __copy_tofrom_user((__force void __user *)to, from,
6812 + n - over) + over;
6813 + }
6814 + return n;
6815 +}
6816 +
6817 +static inline unsigned long __must_check copy_to_user(void __user *to,
6818 + const void *from, unsigned long n)
6819 +{
6820 + unsigned long over;
6821 +
6822 + if ((long)n < 0)
6823 + return n;
6824 +
6825 + if (access_ok(VERIFY_WRITE, to, n)) {
6826 + if (!__builtin_constant_p(n))
6827 + check_object_size(from, n, true);
6828 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6829 + }
6830 + if ((unsigned long)to < TASK_SIZE) {
6831 + over = (unsigned long)to + n - TASK_SIZE;
6832 + if (!__builtin_constant_p(n))
6833 + check_object_size(from, n - over, true);
6834 + return __copy_tofrom_user(to, (__force void __user *)from,
6835 + n - over) + over;
6836 + }
6837 + return n;
6838 +}
6839 +
6840 +#else /* __powerpc64__ */
6841 +
6842 +#define __copy_in_user(to, from, size) \
6843 + __copy_tofrom_user((to), (from), (size))
6844 +
6845 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6846 +{
6847 + if ((long)n < 0 || n > INT_MAX)
6848 + return n;
6849 +
6850 + if (!__builtin_constant_p(n))
6851 + check_object_size(to, n, false);
6852 +
6853 + if (likely(access_ok(VERIFY_READ, from, n)))
6854 + n = __copy_from_user(to, from, n);
6855 + else
6856 + memset(to, 0, n);
6857 + return n;
6858 +}
6859 +
6860 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6861 +{
6862 + if ((long)n < 0 || n > INT_MAX)
6863 + return n;
6864 +
6865 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6866 + if (!__builtin_constant_p(n))
6867 + check_object_size(from, n, true);
6868 + n = __copy_to_user(to, from, n);
6869 + }
6870 + return n;
6871 +}
6872 +
6873 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6874 + unsigned long n);
6875 +
6876 +#endif /* __powerpc64__ */
6877 +
6878 extern unsigned long __clear_user(void __user *addr, unsigned long size);
6879
6880 static inline unsigned long clear_user(void __user *addr, unsigned long size)
6881 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
6882 index 4684e33..acc4d19e 100644
6883 --- a/arch/powerpc/kernel/exceptions-64e.S
6884 +++ b/arch/powerpc/kernel/exceptions-64e.S
6885 @@ -715,6 +715,7 @@ storage_fault_common:
6886 std r14,_DAR(r1)
6887 std r15,_DSISR(r1)
6888 addi r3,r1,STACK_FRAME_OVERHEAD
6889 + bl .save_nvgprs
6890 mr r4,r14
6891 mr r5,r15
6892 ld r14,PACA_EXGEN+EX_R14(r13)
6893 @@ -723,8 +724,7 @@ storage_fault_common:
6894 cmpdi r3,0
6895 bne- 1f
6896 b .ret_from_except_lite
6897 -1: bl .save_nvgprs
6898 - mr r5,r3
6899 +1: mr r5,r3
6900 addi r3,r1,STACK_FRAME_OVERHEAD
6901 ld r4,_DAR(r1)
6902 bl .bad_page_fault
6903 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
6904 index 3684cbd..bc89eab 100644
6905 --- a/arch/powerpc/kernel/exceptions-64s.S
6906 +++ b/arch/powerpc/kernel/exceptions-64s.S
6907 @@ -1206,10 +1206,10 @@ handle_page_fault:
6908 11: ld r4,_DAR(r1)
6909 ld r5,_DSISR(r1)
6910 addi r3,r1,STACK_FRAME_OVERHEAD
6911 + bl .save_nvgprs
6912 bl .do_page_fault
6913 cmpdi r3,0
6914 beq+ 12f
6915 - bl .save_nvgprs
6916 mr r5,r3
6917 addi r3,r1,STACK_FRAME_OVERHEAD
6918 lwz r4,_DAR(r1)
6919 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
6920 index 2e3200c..72095ce 100644
6921 --- a/arch/powerpc/kernel/module_32.c
6922 +++ b/arch/powerpc/kernel/module_32.c
6923 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
6924 me->arch.core_plt_section = i;
6925 }
6926 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
6927 - printk("Module doesn't contain .plt or .init.plt sections.\n");
6928 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
6929 return -ENOEXEC;
6930 }
6931
6932 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
6933
6934 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
6935 /* Init, or core PLT? */
6936 - if (location >= mod->module_core
6937 - && location < mod->module_core + mod->core_size)
6938 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
6939 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
6940 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
6941 - else
6942 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
6943 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
6944 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
6945 + else {
6946 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
6947 + return ~0UL;
6948 + }
6949
6950 /* Find this entry, or if that fails, the next avail. entry */
6951 while (entry->jump[0]) {
6952 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
6953 index 8143067..21ae55b 100644
6954 --- a/arch/powerpc/kernel/process.c
6955 +++ b/arch/powerpc/kernel/process.c
6956 @@ -680,8 +680,8 @@ void show_regs(struct pt_regs * regs)
6957 * Lookup NIP late so we have the best change of getting the
6958 * above info out without failing
6959 */
6960 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
6961 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
6962 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
6963 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
6964 #endif
6965 show_stack(current, (unsigned long *) regs->gpr[1]);
6966 if (!user_mode(regs))
6967 @@ -1129,10 +1129,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6968 newsp = stack[0];
6969 ip = stack[STACK_FRAME_LR_SAVE];
6970 if (!firstframe || ip != lr) {
6971 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
6972 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
6973 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
6974 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
6975 - printk(" (%pS)",
6976 + printk(" (%pA)",
6977 (void *)current->ret_stack[curr_frame].ret);
6978 curr_frame--;
6979 }
6980 @@ -1152,7 +1152,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6981 struct pt_regs *regs = (struct pt_regs *)
6982 (sp + STACK_FRAME_OVERHEAD);
6983 lr = regs->link;
6984 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
6985 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
6986 regs->trap, (void *)regs->nip, (void *)lr);
6987 firstframe = 1;
6988 }
6989 @@ -1194,58 +1194,3 @@ void __ppc64_runlatch_off(void)
6990 mtspr(SPRN_CTRLT, ctrl);
6991 }
6992 #endif /* CONFIG_PPC64 */
6993 -
6994 -unsigned long arch_align_stack(unsigned long sp)
6995 -{
6996 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6997 - sp -= get_random_int() & ~PAGE_MASK;
6998 - return sp & ~0xf;
6999 -}
7000 -
7001 -static inline unsigned long brk_rnd(void)
7002 -{
7003 - unsigned long rnd = 0;
7004 -
7005 - /* 8MB for 32bit, 1GB for 64bit */
7006 - if (is_32bit_task())
7007 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
7008 - else
7009 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
7010 -
7011 - return rnd << PAGE_SHIFT;
7012 -}
7013 -
7014 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7015 -{
7016 - unsigned long base = mm->brk;
7017 - unsigned long ret;
7018 -
7019 -#ifdef CONFIG_PPC_STD_MMU_64
7020 - /*
7021 - * If we are using 1TB segments and we are allowed to randomise
7022 - * the heap, we can put it above 1TB so it is backed by a 1TB
7023 - * segment. Otherwise the heap will be in the bottom 1TB
7024 - * which always uses 256MB segments and this may result in a
7025 - * performance penalty.
7026 - */
7027 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
7028 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
7029 -#endif
7030 -
7031 - ret = PAGE_ALIGN(base + brk_rnd());
7032 -
7033 - if (ret < mm->brk)
7034 - return mm->brk;
7035 -
7036 - return ret;
7037 -}
7038 -
7039 -unsigned long randomize_et_dyn(unsigned long base)
7040 -{
7041 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7042 -
7043 - if (ret < base)
7044 - return base;
7045 -
7046 - return ret;
7047 -}
7048 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
7049 index c497000..8fde506 100644
7050 --- a/arch/powerpc/kernel/ptrace.c
7051 +++ b/arch/powerpc/kernel/ptrace.c
7052 @@ -1737,6 +1737,10 @@ long arch_ptrace(struct task_struct *child, long request,
7053 return ret;
7054 }
7055
7056 +#ifdef CONFIG_GRKERNSEC_SETXID
7057 +extern void gr_delayed_cred_worker(void);
7058 +#endif
7059 +
7060 /*
7061 * We must return the syscall number to actually look up in the table.
7062 * This can be -1L to skip running any syscall at all.
7063 @@ -1747,6 +1751,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
7064
7065 secure_computing_strict(regs->gpr[0]);
7066
7067 +#ifdef CONFIG_GRKERNSEC_SETXID
7068 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
7069 + gr_delayed_cred_worker();
7070 +#endif
7071 +
7072 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
7073 tracehook_report_syscall_entry(regs))
7074 /*
7075 @@ -1781,6 +1790,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
7076 {
7077 int step;
7078
7079 +#ifdef CONFIG_GRKERNSEC_SETXID
7080 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
7081 + gr_delayed_cred_worker();
7082 +#endif
7083 +
7084 audit_syscall_exit(regs);
7085
7086 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
7087 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
7088 index 804e323..79181c1 100644
7089 --- a/arch/powerpc/kernel/signal_32.c
7090 +++ b/arch/powerpc/kernel/signal_32.c
7091 @@ -851,7 +851,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
7092 /* Save user registers on the stack */
7093 frame = &rt_sf->uc.uc_mcontext;
7094 addr = frame;
7095 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
7096 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
7097 if (save_user_regs(regs, frame, 0, 1))
7098 goto badframe;
7099 regs->link = current->mm->context.vdso_base + vdso32_rt_sigtramp;
7100 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
7101 index 1ca045d..139c3f7 100644
7102 --- a/arch/powerpc/kernel/signal_64.c
7103 +++ b/arch/powerpc/kernel/signal_64.c
7104 @@ -430,7 +430,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
7105 current->thread.fpscr.val = 0;
7106
7107 /* Set up to return from userspace. */
7108 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
7109 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
7110 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
7111 } else {
7112 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
7113 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
7114 index 3ce1f86..c30e629 100644
7115 --- a/arch/powerpc/kernel/sysfs.c
7116 +++ b/arch/powerpc/kernel/sysfs.c
7117 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
7118 return NOTIFY_OK;
7119 }
7120
7121 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
7122 +static struct notifier_block sysfs_cpu_nb = {
7123 .notifier_call = sysfs_cpu_notify,
7124 };
7125
7126 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
7127 index 3251840..3f7c77a 100644
7128 --- a/arch/powerpc/kernel/traps.c
7129 +++ b/arch/powerpc/kernel/traps.c
7130 @@ -133,6 +133,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
7131 return flags;
7132 }
7133
7134 +extern void gr_handle_kernel_exploit(void);
7135 +
7136 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
7137 int signr)
7138 {
7139 @@ -182,6 +184,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
7140 panic("Fatal exception in interrupt");
7141 if (panic_on_oops)
7142 panic("Fatal exception");
7143 +
7144 + gr_handle_kernel_exploit();
7145 +
7146 do_exit(signr);
7147 }
7148
7149 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
7150 index 1b2076f..835e4be 100644
7151 --- a/arch/powerpc/kernel/vdso.c
7152 +++ b/arch/powerpc/kernel/vdso.c
7153 @@ -34,6 +34,7 @@
7154 #include <asm/firmware.h>
7155 #include <asm/vdso.h>
7156 #include <asm/vdso_datapage.h>
7157 +#include <asm/mman.h>
7158
7159 #include "setup.h"
7160
7161 @@ -218,7 +219,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
7162 vdso_base = VDSO32_MBASE;
7163 #endif
7164
7165 - current->mm->context.vdso_base = 0;
7166 + current->mm->context.vdso_base = ~0UL;
7167
7168 /* vDSO has a problem and was disabled, just don't "enable" it for the
7169 * process
7170 @@ -238,7 +239,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
7171 vdso_base = get_unmapped_area(NULL, vdso_base,
7172 (vdso_pages << PAGE_SHIFT) +
7173 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
7174 - 0, 0);
7175 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
7176 if (IS_ERR_VALUE(vdso_base)) {
7177 rc = vdso_base;
7178 goto fail_mmapsem;
7179 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
7180 index 5eea6f3..5d10396 100644
7181 --- a/arch/powerpc/lib/usercopy_64.c
7182 +++ b/arch/powerpc/lib/usercopy_64.c
7183 @@ -9,22 +9,6 @@
7184 #include <linux/module.h>
7185 #include <asm/uaccess.h>
7186
7187 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
7188 -{
7189 - if (likely(access_ok(VERIFY_READ, from, n)))
7190 - n = __copy_from_user(to, from, n);
7191 - else
7192 - memset(to, 0, n);
7193 - return n;
7194 -}
7195 -
7196 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
7197 -{
7198 - if (likely(access_ok(VERIFY_WRITE, to, n)))
7199 - n = __copy_to_user(to, from, n);
7200 - return n;
7201 -}
7202 -
7203 unsigned long copy_in_user(void __user *to, const void __user *from,
7204 unsigned long n)
7205 {
7206 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
7207 return n;
7208 }
7209
7210 -EXPORT_SYMBOL(copy_from_user);
7211 -EXPORT_SYMBOL(copy_to_user);
7212 EXPORT_SYMBOL(copy_in_user);
7213
7214 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
7215 index 3a8489a..6a63b3b 100644
7216 --- a/arch/powerpc/mm/fault.c
7217 +++ b/arch/powerpc/mm/fault.c
7218 @@ -32,6 +32,10 @@
7219 #include <linux/perf_event.h>
7220 #include <linux/magic.h>
7221 #include <linux/ratelimit.h>
7222 +#include <linux/slab.h>
7223 +#include <linux/pagemap.h>
7224 +#include <linux/compiler.h>
7225 +#include <linux/unistd.h>
7226
7227 #include <asm/firmware.h>
7228 #include <asm/page.h>
7229 @@ -68,6 +72,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
7230 }
7231 #endif
7232
7233 +#ifdef CONFIG_PAX_PAGEEXEC
7234 +/*
7235 + * PaX: decide what to do with offenders (regs->nip = fault address)
7236 + *
7237 + * returns 1 when task should be killed
7238 + */
7239 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7240 +{
7241 + return 1;
7242 +}
7243 +
7244 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7245 +{
7246 + unsigned long i;
7247 +
7248 + printk(KERN_ERR "PAX: bytes at PC: ");
7249 + for (i = 0; i < 5; i++) {
7250 + unsigned int c;
7251 + if (get_user(c, (unsigned int __user *)pc+i))
7252 + printk(KERN_CONT "???????? ");
7253 + else
7254 + printk(KERN_CONT "%08x ", c);
7255 + }
7256 + printk("\n");
7257 +}
7258 +#endif
7259 +
7260 /*
7261 * Check whether the instruction at regs->nip is a store using
7262 * an update addressing form which will update r1.
7263 @@ -213,7 +244,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
7264 * indicate errors in DSISR but can validly be set in SRR1.
7265 */
7266 if (trap == 0x400)
7267 - error_code &= 0x48200000;
7268 + error_code &= 0x58200000;
7269 else
7270 is_write = error_code & DSISR_ISSTORE;
7271 #else
7272 @@ -364,7 +395,7 @@ good_area:
7273 * "undefined". Of those that can be set, this is the only
7274 * one which seems bad.
7275 */
7276 - if (error_code & 0x10000000)
7277 + if (error_code & DSISR_GUARDED)
7278 /* Guarded storage error. */
7279 goto bad_area;
7280 #endif /* CONFIG_8xx */
7281 @@ -379,7 +410,7 @@ good_area:
7282 * processors use the same I/D cache coherency mechanism
7283 * as embedded.
7284 */
7285 - if (error_code & DSISR_PROTFAULT)
7286 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
7287 goto bad_area;
7288 #endif /* CONFIG_PPC_STD_MMU */
7289
7290 @@ -462,6 +493,23 @@ bad_area:
7291 bad_area_nosemaphore:
7292 /* User mode accesses cause a SIGSEGV */
7293 if (user_mode(regs)) {
7294 +
7295 +#ifdef CONFIG_PAX_PAGEEXEC
7296 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
7297 +#ifdef CONFIG_PPC_STD_MMU
7298 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
7299 +#else
7300 + if (is_exec && regs->nip == address) {
7301 +#endif
7302 + switch (pax_handle_fetch_fault(regs)) {
7303 + }
7304 +
7305 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7306 + do_group_exit(SIGKILL);
7307 + }
7308 + }
7309 +#endif
7310 +
7311 _exception(SIGSEGV, regs, code, address);
7312 return 0;
7313 }
7314 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7315 index 67a42ed..cd463e0 100644
7316 --- a/arch/powerpc/mm/mmap_64.c
7317 +++ b/arch/powerpc/mm/mmap_64.c
7318 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7319 {
7320 unsigned long rnd = 0;
7321
7322 +#ifdef CONFIG_PAX_RANDMMAP
7323 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7324 +#endif
7325 +
7326 if (current->flags & PF_RANDOMIZE) {
7327 /* 8MB for 32bit, 1GB for 64bit */
7328 if (is_32bit_task())
7329 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7330 */
7331 if (mmap_is_legacy()) {
7332 mm->mmap_base = TASK_UNMAPPED_BASE;
7333 +
7334 +#ifdef CONFIG_PAX_RANDMMAP
7335 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7336 + mm->mmap_base += mm->delta_mmap;
7337 +#endif
7338 +
7339 mm->get_unmapped_area = arch_get_unmapped_area;
7340 mm->unmap_area = arch_unmap_area;
7341 } else {
7342 mm->mmap_base = mmap_base();
7343 +
7344 +#ifdef CONFIG_PAX_RANDMMAP
7345 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7346 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7347 +#endif
7348 +
7349 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7350 mm->unmap_area = arch_unmap_area_topdown;
7351 }
7352 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7353 index e779642..e5bb889 100644
7354 --- a/arch/powerpc/mm/mmu_context_nohash.c
7355 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7356 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7357 return NOTIFY_OK;
7358 }
7359
7360 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7361 +static struct notifier_block mmu_context_cpu_nb = {
7362 .notifier_call = mmu_context_cpu_notify,
7363 };
7364
7365 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7366 index bba87ca..c346a33 100644
7367 --- a/arch/powerpc/mm/numa.c
7368 +++ b/arch/powerpc/mm/numa.c
7369 @@ -932,7 +932,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7370 return ret;
7371 }
7372
7373 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7374 +static struct notifier_block ppc64_numa_nb = {
7375 .notifier_call = cpu_numa_callback,
7376 .priority = 1 /* Must run before sched domains notifier. */
7377 };
7378 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7379 index cf9dada..241529f 100644
7380 --- a/arch/powerpc/mm/slice.c
7381 +++ b/arch/powerpc/mm/slice.c
7382 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7383 if ((mm->task_size - len) < addr)
7384 return 0;
7385 vma = find_vma(mm, addr);
7386 - return (!vma || (addr + len) <= vma->vm_start);
7387 + return check_heap_stack_gap(vma, addr, len, 0);
7388 }
7389
7390 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7391 @@ -272,7 +272,7 @@ full_search:
7392 addr = _ALIGN_UP(addr + 1, 1ul << SLICE_HIGH_SHIFT);
7393 continue;
7394 }
7395 - if (!vma || addr + len <= vma->vm_start) {
7396 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7397 /*
7398 * Remember the place where we stopped the search:
7399 */
7400 @@ -329,10 +329,14 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7401 }
7402 }
7403
7404 - addr = mm->mmap_base;
7405 - while (addr > len) {
7406 + if (mm->mmap_base < len)
7407 + addr = -ENOMEM;
7408 + else
7409 + addr = mm->mmap_base - len;
7410 +
7411 + while (!IS_ERR_VALUE(addr)) {
7412 /* Go down by chunk size */
7413 - addr = _ALIGN_DOWN(addr - len, 1ul << pshift);
7414 + addr = _ALIGN_DOWN(addr, 1ul << pshift);
7415
7416 /* Check for hit with different page size */
7417 mask = slice_range_to_mask(addr, len);
7418 @@ -352,7 +356,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7419 * return with success:
7420 */
7421 vma = find_vma(mm, addr);
7422 - if (!vma || (addr + len) <= vma->vm_start) {
7423 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7424 /* remember the address as a hint for next time */
7425 if (use_cache)
7426 mm->free_area_cache = addr;
7427 @@ -364,7 +368,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7428 mm->cached_hole_size = vma->vm_start - addr;
7429
7430 /* try just below the current vma->vm_start */
7431 - addr = vma->vm_start;
7432 + addr = skip_heap_stack_gap(vma, len, 0);
7433 }
7434
7435 /*
7436 @@ -442,6 +446,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7437 if (fixed && addr > (mm->task_size - len))
7438 return -EINVAL;
7439
7440 +#ifdef CONFIG_PAX_RANDMMAP
7441 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7442 + addr = 0;
7443 +#endif
7444 +
7445 /* If hint, make sure it matches our alignment restrictions */
7446 if (!fixed && addr) {
7447 addr = _ALIGN_UP(addr, 1ul << pshift);
7448 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
7449 index 0cfece4..2f1a0e5 100644
7450 --- a/arch/powerpc/platforms/cell/spufs/file.c
7451 +++ b/arch/powerpc/platforms/cell/spufs/file.c
7452 @@ -281,9 +281,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
7453 return VM_FAULT_NOPAGE;
7454 }
7455
7456 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
7457 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
7458 unsigned long address,
7459 - void *buf, int len, int write)
7460 + void *buf, size_t len, int write)
7461 {
7462 struct spu_context *ctx = vma->vm_file->private_data;
7463 unsigned long offset = address - vma->vm_start;
7464 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7465 index bdb738a..49c9f95 100644
7466 --- a/arch/powerpc/platforms/powermac/smp.c
7467 +++ b/arch/powerpc/platforms/powermac/smp.c
7468 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7469 return NOTIFY_OK;
7470 }
7471
7472 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7473 +static struct notifier_block smp_core99_cpu_nb = {
7474 .notifier_call = smp_core99_cpu_notify,
7475 };
7476 #endif /* CONFIG_HOTPLUG_CPU */
7477 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7478 index c797832..ce575c8 100644
7479 --- a/arch/s390/include/asm/atomic.h
7480 +++ b/arch/s390/include/asm/atomic.h
7481 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7482 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7483 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7484
7485 +#define atomic64_read_unchecked(v) atomic64_read(v)
7486 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7487 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7488 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7489 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7490 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7491 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7492 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7493 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7494 +
7495 #define smp_mb__before_atomic_dec() smp_mb()
7496 #define smp_mb__after_atomic_dec() smp_mb()
7497 #define smp_mb__before_atomic_inc() smp_mb()
7498 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7499 index 4d7ccac..d03d0ad 100644
7500 --- a/arch/s390/include/asm/cache.h
7501 +++ b/arch/s390/include/asm/cache.h
7502 @@ -9,8 +9,10 @@
7503 #ifndef __ARCH_S390_CACHE_H
7504 #define __ARCH_S390_CACHE_H
7505
7506 -#define L1_CACHE_BYTES 256
7507 +#include <linux/const.h>
7508 +
7509 #define L1_CACHE_SHIFT 8
7510 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7511 #define NET_SKB_PAD 32
7512
7513 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7514 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7515 index 178ff96..8c93bd1 100644
7516 --- a/arch/s390/include/asm/elf.h
7517 +++ b/arch/s390/include/asm/elf.h
7518 @@ -160,8 +160,14 @@ extern unsigned int vdso_enabled;
7519 the loader. We need to make sure that it is out of the way of the program
7520 that it will "exec", and that there is sufficient room for the brk. */
7521
7522 -extern unsigned long randomize_et_dyn(unsigned long base);
7523 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7524 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7525 +
7526 +#ifdef CONFIG_PAX_ASLR
7527 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7528 +
7529 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7530 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7531 +#endif
7532
7533 /* This yields a mask that user programs can use to figure out what
7534 instruction set this CPU supports. */
7535 @@ -210,9 +216,6 @@ struct linux_binprm;
7536 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7537 int arch_setup_additional_pages(struct linux_binprm *, int);
7538
7539 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7540 -#define arch_randomize_brk arch_randomize_brk
7541 -
7542 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7543
7544 #endif
7545 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7546 index c4a93d6..4d2a9b4 100644
7547 --- a/arch/s390/include/asm/exec.h
7548 +++ b/arch/s390/include/asm/exec.h
7549 @@ -7,6 +7,6 @@
7550 #ifndef __ASM_EXEC_H
7551 #define __ASM_EXEC_H
7552
7553 -extern unsigned long arch_align_stack(unsigned long sp);
7554 +#define arch_align_stack(x) ((x) & ~0xfUL)
7555
7556 #endif /* __ASM_EXEC_H */
7557 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7558 index 34268df..ea97318 100644
7559 --- a/arch/s390/include/asm/uaccess.h
7560 +++ b/arch/s390/include/asm/uaccess.h
7561 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7562 copy_to_user(void __user *to, const void *from, unsigned long n)
7563 {
7564 might_fault();
7565 +
7566 + if ((long)n < 0)
7567 + return n;
7568 +
7569 if (access_ok(VERIFY_WRITE, to, n))
7570 n = __copy_to_user(to, from, n);
7571 return n;
7572 @@ -277,6 +281,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7573 static inline unsigned long __must_check
7574 __copy_from_user(void *to, const void __user *from, unsigned long n)
7575 {
7576 + if ((long)n < 0)
7577 + return n;
7578 +
7579 if (__builtin_constant_p(n) && (n <= 256))
7580 return uaccess.copy_from_user_small(n, from, to);
7581 else
7582 @@ -308,10 +315,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7583 static inline unsigned long __must_check
7584 copy_from_user(void *to, const void __user *from, unsigned long n)
7585 {
7586 - unsigned int sz = __compiletime_object_size(to);
7587 + size_t sz = __compiletime_object_size(to);
7588
7589 might_fault();
7590 - if (unlikely(sz != -1 && sz < n)) {
7591 +
7592 + if ((long)n < 0)
7593 + return n;
7594 +
7595 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7596 copy_from_user_overflow();
7597 return n;
7598 }
7599 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7600 index 4610dea..cf0af21 100644
7601 --- a/arch/s390/kernel/module.c
7602 +++ b/arch/s390/kernel/module.c
7603 @@ -171,11 +171,11 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7604
7605 /* Increase core size by size of got & plt and set start
7606 offsets for got and plt. */
7607 - me->core_size = ALIGN(me->core_size, 4);
7608 - me->arch.got_offset = me->core_size;
7609 - me->core_size += me->arch.got_size;
7610 - me->arch.plt_offset = me->core_size;
7611 - me->core_size += me->arch.plt_size;
7612 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7613 + me->arch.got_offset = me->core_size_rw;
7614 + me->core_size_rw += me->arch.got_size;
7615 + me->arch.plt_offset = me->core_size_rx;
7616 + me->core_size_rx += me->arch.plt_size;
7617 return 0;
7618 }
7619
7620 @@ -252,7 +252,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7621 if (info->got_initialized == 0) {
7622 Elf_Addr *gotent;
7623
7624 - gotent = me->module_core + me->arch.got_offset +
7625 + gotent = me->module_core_rw + me->arch.got_offset +
7626 info->got_offset;
7627 *gotent = val;
7628 info->got_initialized = 1;
7629 @@ -276,7 +276,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7630 else if (r_type == R_390_GOTENT ||
7631 r_type == R_390_GOTPLTENT)
7632 *(unsigned int *) loc =
7633 - (val + (Elf_Addr) me->module_core - loc) >> 1;
7634 + (val + (Elf_Addr) me->module_core_rw - loc) >> 1;
7635 else if (r_type == R_390_GOT64 ||
7636 r_type == R_390_GOTPLT64)
7637 *(unsigned long *) loc = val;
7638 @@ -290,7 +290,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7639 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7640 if (info->plt_initialized == 0) {
7641 unsigned int *ip;
7642 - ip = me->module_core + me->arch.plt_offset +
7643 + ip = me->module_core_rx + me->arch.plt_offset +
7644 info->plt_offset;
7645 #ifndef CONFIG_64BIT
7646 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7647 @@ -315,7 +315,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7648 val - loc + 0xffffUL < 0x1ffffeUL) ||
7649 (r_type == R_390_PLT32DBL &&
7650 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7651 - val = (Elf_Addr) me->module_core +
7652 + val = (Elf_Addr) me->module_core_rx +
7653 me->arch.plt_offset +
7654 info->plt_offset;
7655 val += rela->r_addend - loc;
7656 @@ -337,7 +337,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7657 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7658 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7659 val = val + rela->r_addend -
7660 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7661 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7662 if (r_type == R_390_GOTOFF16)
7663 *(unsigned short *) loc = val;
7664 else if (r_type == R_390_GOTOFF32)
7665 @@ -347,7 +347,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7666 break;
7667 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7668 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7669 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7670 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7671 rela->r_addend - loc;
7672 if (r_type == R_390_GOTPC)
7673 *(unsigned int *) loc = val;
7674 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7675 index 536d645..4a5bd9e 100644
7676 --- a/arch/s390/kernel/process.c
7677 +++ b/arch/s390/kernel/process.c
7678 @@ -250,39 +250,3 @@ unsigned long get_wchan(struct task_struct *p)
7679 }
7680 return 0;
7681 }
7682 -
7683 -unsigned long arch_align_stack(unsigned long sp)
7684 -{
7685 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7686 - sp -= get_random_int() & ~PAGE_MASK;
7687 - return sp & ~0xf;
7688 -}
7689 -
7690 -static inline unsigned long brk_rnd(void)
7691 -{
7692 - /* 8MB for 32bit, 1GB for 64bit */
7693 - if (is_32bit_task())
7694 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7695 - else
7696 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7697 -}
7698 -
7699 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7700 -{
7701 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7702 -
7703 - if (ret < mm->brk)
7704 - return mm->brk;
7705 - return ret;
7706 -}
7707 -
7708 -unsigned long randomize_et_dyn(unsigned long base)
7709 -{
7710 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7711 -
7712 - if (!(current->flags & PF_RANDOMIZE))
7713 - return base;
7714 - if (ret < base)
7715 - return base;
7716 - return ret;
7717 -}
7718 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7719 index c59a5ef..3fae59c 100644
7720 --- a/arch/s390/mm/mmap.c
7721 +++ b/arch/s390/mm/mmap.c
7722 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7723 */
7724 if (mmap_is_legacy()) {
7725 mm->mmap_base = TASK_UNMAPPED_BASE;
7726 +
7727 +#ifdef CONFIG_PAX_RANDMMAP
7728 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7729 + mm->mmap_base += mm->delta_mmap;
7730 +#endif
7731 +
7732 mm->get_unmapped_area = arch_get_unmapped_area;
7733 mm->unmap_area = arch_unmap_area;
7734 } else {
7735 mm->mmap_base = mmap_base();
7736 +
7737 +#ifdef CONFIG_PAX_RANDMMAP
7738 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7739 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7740 +#endif
7741 +
7742 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7743 mm->unmap_area = arch_unmap_area_topdown;
7744 }
7745 @@ -172,10 +184,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7746 */
7747 if (mmap_is_legacy()) {
7748 mm->mmap_base = TASK_UNMAPPED_BASE;
7749 +
7750 +#ifdef CONFIG_PAX_RANDMMAP
7751 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7752 + mm->mmap_base += mm->delta_mmap;
7753 +#endif
7754 +
7755 mm->get_unmapped_area = s390_get_unmapped_area;
7756 mm->unmap_area = arch_unmap_area;
7757 } else {
7758 mm->mmap_base = mmap_base();
7759 +
7760 +#ifdef CONFIG_PAX_RANDMMAP
7761 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7762 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7763 +#endif
7764 +
7765 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7766 mm->unmap_area = arch_unmap_area_topdown;
7767 }
7768 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7769 index ae3d59f..f65f075 100644
7770 --- a/arch/score/include/asm/cache.h
7771 +++ b/arch/score/include/asm/cache.h
7772 @@ -1,7 +1,9 @@
7773 #ifndef _ASM_SCORE_CACHE_H
7774 #define _ASM_SCORE_CACHE_H
7775
7776 +#include <linux/const.h>
7777 +
7778 #define L1_CACHE_SHIFT 4
7779 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7780 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7781
7782 #endif /* _ASM_SCORE_CACHE_H */
7783 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7784 index f9f3cd5..58ff438 100644
7785 --- a/arch/score/include/asm/exec.h
7786 +++ b/arch/score/include/asm/exec.h
7787 @@ -1,6 +1,6 @@
7788 #ifndef _ASM_SCORE_EXEC_H
7789 #define _ASM_SCORE_EXEC_H
7790
7791 -extern unsigned long arch_align_stack(unsigned long sp);
7792 +#define arch_align_stack(x) (x)
7793
7794 #endif /* _ASM_SCORE_EXEC_H */
7795 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7796 index 7956846..5f37677 100644
7797 --- a/arch/score/kernel/process.c
7798 +++ b/arch/score/kernel/process.c
7799 @@ -134,8 +134,3 @@ unsigned long get_wchan(struct task_struct *task)
7800
7801 return task_pt_regs(task)->cp0_epc;
7802 }
7803 -
7804 -unsigned long arch_align_stack(unsigned long sp)
7805 -{
7806 - return sp;
7807 -}
7808 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7809 index ef9e555..331bd29 100644
7810 --- a/arch/sh/include/asm/cache.h
7811 +++ b/arch/sh/include/asm/cache.h
7812 @@ -9,10 +9,11 @@
7813 #define __ASM_SH_CACHE_H
7814 #ifdef __KERNEL__
7815
7816 +#include <linux/const.h>
7817 #include <linux/init.h>
7818 #include <cpu/cache.h>
7819
7820 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7821 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7822
7823 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7824
7825 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7826 index 03f2b55..b027032 100644
7827 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7828 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7829 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7830 return NOTIFY_OK;
7831 }
7832
7833 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7834 +static struct notifier_block shx3_cpu_notifier = {
7835 .notifier_call = shx3_cpu_callback,
7836 };
7837
7838 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7839 index 6777177..cb5e44f 100644
7840 --- a/arch/sh/mm/mmap.c
7841 +++ b/arch/sh/mm/mmap.c
7842 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7843 struct mm_struct *mm = current->mm;
7844 struct vm_area_struct *vma;
7845 int do_colour_align;
7846 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7847 struct vm_unmapped_area_info info;
7848
7849 if (flags & MAP_FIXED) {
7850 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7851 if (filp || (flags & MAP_SHARED))
7852 do_colour_align = 1;
7853
7854 +#ifdef CONFIG_PAX_RANDMMAP
7855 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7856 +#endif
7857 +
7858 if (addr) {
7859 if (do_colour_align)
7860 addr = COLOUR_ALIGN(addr, pgoff);
7861 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7862 addr = PAGE_ALIGN(addr);
7863
7864 vma = find_vma(mm, addr);
7865 - if (TASK_SIZE - len >= addr &&
7866 - (!vma || addr + len <= vma->vm_start))
7867 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7868 return addr;
7869 }
7870
7871 info.flags = 0;
7872 info.length = len;
7873 - info.low_limit = TASK_UNMAPPED_BASE;
7874 + info.low_limit = mm->mmap_base;
7875 info.high_limit = TASK_SIZE;
7876 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
7877 info.align_offset = pgoff << PAGE_SHIFT;
7878 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7879 struct mm_struct *mm = current->mm;
7880 unsigned long addr = addr0;
7881 int do_colour_align;
7882 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7883 struct vm_unmapped_area_info info;
7884
7885 if (flags & MAP_FIXED) {
7886 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7887 if (filp || (flags & MAP_SHARED))
7888 do_colour_align = 1;
7889
7890 +#ifdef CONFIG_PAX_RANDMMAP
7891 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7892 +#endif
7893 +
7894 /* requesting a specific address */
7895 if (addr) {
7896 if (do_colour_align)
7897 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7898 addr = PAGE_ALIGN(addr);
7899
7900 vma = find_vma(mm, addr);
7901 - if (TASK_SIZE - len >= addr &&
7902 - (!vma || addr + len <= vma->vm_start))
7903 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7904 return addr;
7905 }
7906
7907 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7908 VM_BUG_ON(addr != -ENOMEM);
7909 info.flags = 0;
7910 info.low_limit = TASK_UNMAPPED_BASE;
7911 +
7912 +#ifdef CONFIG_PAX_RANDMMAP
7913 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7914 + info.low_limit += mm->delta_mmap;
7915 +#endif
7916 +
7917 info.high_limit = TASK_SIZE;
7918 addr = vm_unmapped_area(&info);
7919 }
7920 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
7921 index be56a24..443328f 100644
7922 --- a/arch/sparc/include/asm/atomic_64.h
7923 +++ b/arch/sparc/include/asm/atomic_64.h
7924 @@ -14,18 +14,40 @@
7925 #define ATOMIC64_INIT(i) { (i) }
7926
7927 #define atomic_read(v) (*(volatile int *)&(v)->counter)
7928 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
7929 +{
7930 + return v->counter;
7931 +}
7932 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
7933 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
7934 +{
7935 + return v->counter;
7936 +}
7937
7938 #define atomic_set(v, i) (((v)->counter) = i)
7939 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
7940 +{
7941 + v->counter = i;
7942 +}
7943 #define atomic64_set(v, i) (((v)->counter) = i)
7944 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
7945 +{
7946 + v->counter = i;
7947 +}
7948
7949 extern void atomic_add(int, atomic_t *);
7950 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
7951 extern void atomic64_add(long, atomic64_t *);
7952 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
7953 extern void atomic_sub(int, atomic_t *);
7954 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
7955 extern void atomic64_sub(long, atomic64_t *);
7956 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
7957
7958 extern int atomic_add_ret(int, atomic_t *);
7959 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
7960 extern long atomic64_add_ret(long, atomic64_t *);
7961 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
7962 extern int atomic_sub_ret(int, atomic_t *);
7963 extern long atomic64_sub_ret(long, atomic64_t *);
7964
7965 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7966 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
7967
7968 #define atomic_inc_return(v) atomic_add_ret(1, v)
7969 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
7970 +{
7971 + return atomic_add_ret_unchecked(1, v);
7972 +}
7973 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
7974 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
7975 +{
7976 + return atomic64_add_ret_unchecked(1, v);
7977 +}
7978
7979 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
7980 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
7981
7982 #define atomic_add_return(i, v) atomic_add_ret(i, v)
7983 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
7984 +{
7985 + return atomic_add_ret_unchecked(i, v);
7986 +}
7987 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
7988 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
7989 +{
7990 + return atomic64_add_ret_unchecked(i, v);
7991 +}
7992
7993 /*
7994 * atomic_inc_and_test - increment and test
7995 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7996 * other cases.
7997 */
7998 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
7999 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8000 +{
8001 + return atomic_inc_return_unchecked(v) == 0;
8002 +}
8003 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8004
8005 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
8006 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8007 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
8008
8009 #define atomic_inc(v) atomic_add(1, v)
8010 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8011 +{
8012 + atomic_add_unchecked(1, v);
8013 +}
8014 #define atomic64_inc(v) atomic64_add(1, v)
8015 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8016 +{
8017 + atomic64_add_unchecked(1, v);
8018 +}
8019
8020 #define atomic_dec(v) atomic_sub(1, v)
8021 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
8022 +{
8023 + atomic_sub_unchecked(1, v);
8024 +}
8025 #define atomic64_dec(v) atomic64_sub(1, v)
8026 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
8027 +{
8028 + atomic64_sub_unchecked(1, v);
8029 +}
8030
8031 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
8032 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
8033
8034 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8035 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8036 +{
8037 + return cmpxchg(&v->counter, old, new);
8038 +}
8039 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8040 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8041 +{
8042 + return xchg(&v->counter, new);
8043 +}
8044
8045 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8046 {
8047 - int c, old;
8048 + int c, old, new;
8049 c = atomic_read(v);
8050 for (;;) {
8051 - if (unlikely(c == (u)))
8052 + if (unlikely(c == u))
8053 break;
8054 - old = atomic_cmpxchg((v), c, c + (a));
8055 +
8056 + asm volatile("addcc %2, %0, %0\n"
8057 +
8058 +#ifdef CONFIG_PAX_REFCOUNT
8059 + "tvs %%icc, 6\n"
8060 +#endif
8061 +
8062 + : "=r" (new)
8063 + : "0" (c), "ir" (a)
8064 + : "cc");
8065 +
8066 + old = atomic_cmpxchg(v, c, new);
8067 if (likely(old == c))
8068 break;
8069 c = old;
8070 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8071 #define atomic64_cmpxchg(v, o, n) \
8072 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
8073 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
8074 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
8075 +{
8076 + return xchg(&v->counter, new);
8077 +}
8078
8079 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
8080 {
8081 - long c, old;
8082 + long c, old, new;
8083 c = atomic64_read(v);
8084 for (;;) {
8085 - if (unlikely(c == (u)))
8086 + if (unlikely(c == u))
8087 break;
8088 - old = atomic64_cmpxchg((v), c, c + (a));
8089 +
8090 + asm volatile("addcc %2, %0, %0\n"
8091 +
8092 +#ifdef CONFIG_PAX_REFCOUNT
8093 + "tvs %%xcc, 6\n"
8094 +#endif
8095 +
8096 + : "=r" (new)
8097 + : "0" (c), "ir" (a)
8098 + : "cc");
8099 +
8100 + old = atomic64_cmpxchg(v, c, new);
8101 if (likely(old == c))
8102 break;
8103 c = old;
8104 }
8105 - return c != (u);
8106 + return c != u;
8107 }
8108
8109 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8110 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
8111 index 5bb6991..5c2132e 100644
8112 --- a/arch/sparc/include/asm/cache.h
8113 +++ b/arch/sparc/include/asm/cache.h
8114 @@ -7,10 +7,12 @@
8115 #ifndef _SPARC_CACHE_H
8116 #define _SPARC_CACHE_H
8117
8118 +#include <linux/const.h>
8119 +
8120 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
8121
8122 #define L1_CACHE_SHIFT 5
8123 -#define L1_CACHE_BYTES 32
8124 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8125
8126 #ifdef CONFIG_SPARC32
8127 #define SMP_CACHE_BYTES_SHIFT 5
8128 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
8129 index ac74a2c..a9e58af 100644
8130 --- a/arch/sparc/include/asm/elf_32.h
8131 +++ b/arch/sparc/include/asm/elf_32.h
8132 @@ -114,6 +114,13 @@ typedef struct {
8133
8134 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
8135
8136 +#ifdef CONFIG_PAX_ASLR
8137 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
8138 +
8139 +#define PAX_DELTA_MMAP_LEN 16
8140 +#define PAX_DELTA_STACK_LEN 16
8141 +#endif
8142 +
8143 /* This yields a mask that user programs can use to figure out what
8144 instruction set this cpu supports. This can NOT be done in userspace
8145 on Sparc. */
8146 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
8147 index 370ca1e..d4f4a98 100644
8148 --- a/arch/sparc/include/asm/elf_64.h
8149 +++ b/arch/sparc/include/asm/elf_64.h
8150 @@ -189,6 +189,13 @@ typedef struct {
8151 #define ELF_ET_DYN_BASE 0x0000010000000000UL
8152 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
8153
8154 +#ifdef CONFIG_PAX_ASLR
8155 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
8156 +
8157 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
8158 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
8159 +#endif
8160 +
8161 extern unsigned long sparc64_elf_hwcap;
8162 #define ELF_HWCAP sparc64_elf_hwcap
8163
8164 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
8165 index 9b1c36d..209298b 100644
8166 --- a/arch/sparc/include/asm/pgalloc_32.h
8167 +++ b/arch/sparc/include/asm/pgalloc_32.h
8168 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
8169 }
8170
8171 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
8172 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
8173
8174 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
8175 unsigned long address)
8176 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
8177 index bcfe063..b333142 100644
8178 --- a/arch/sparc/include/asm/pgalloc_64.h
8179 +++ b/arch/sparc/include/asm/pgalloc_64.h
8180 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
8181 }
8182
8183 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
8184 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
8185
8186 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
8187 {
8188 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
8189 index 6fc1348..390c50a 100644
8190 --- a/arch/sparc/include/asm/pgtable_32.h
8191 +++ b/arch/sparc/include/asm/pgtable_32.h
8192 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
8193 #define PAGE_SHARED SRMMU_PAGE_SHARED
8194 #define PAGE_COPY SRMMU_PAGE_COPY
8195 #define PAGE_READONLY SRMMU_PAGE_RDONLY
8196 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
8197 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
8198 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
8199 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
8200
8201 /* Top-level page directory - dummy used by init-mm.
8202 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
8203
8204 /* xwr */
8205 #define __P000 PAGE_NONE
8206 -#define __P001 PAGE_READONLY
8207 -#define __P010 PAGE_COPY
8208 -#define __P011 PAGE_COPY
8209 +#define __P001 PAGE_READONLY_NOEXEC
8210 +#define __P010 PAGE_COPY_NOEXEC
8211 +#define __P011 PAGE_COPY_NOEXEC
8212 #define __P100 PAGE_READONLY
8213 #define __P101 PAGE_READONLY
8214 #define __P110 PAGE_COPY
8215 #define __P111 PAGE_COPY
8216
8217 #define __S000 PAGE_NONE
8218 -#define __S001 PAGE_READONLY
8219 -#define __S010 PAGE_SHARED
8220 -#define __S011 PAGE_SHARED
8221 +#define __S001 PAGE_READONLY_NOEXEC
8222 +#define __S010 PAGE_SHARED_NOEXEC
8223 +#define __S011 PAGE_SHARED_NOEXEC
8224 #define __S100 PAGE_READONLY
8225 #define __S101 PAGE_READONLY
8226 #define __S110 PAGE_SHARED
8227 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
8228 index 79da178..c2eede8 100644
8229 --- a/arch/sparc/include/asm/pgtsrmmu.h
8230 +++ b/arch/sparc/include/asm/pgtsrmmu.h
8231 @@ -115,6 +115,11 @@
8232 SRMMU_EXEC | SRMMU_REF)
8233 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
8234 SRMMU_EXEC | SRMMU_REF)
8235 +
8236 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
8237 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8238 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8239 +
8240 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
8241 SRMMU_DIRTY | SRMMU_REF)
8242
8243 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
8244 index 9689176..63c18ea 100644
8245 --- a/arch/sparc/include/asm/spinlock_64.h
8246 +++ b/arch/sparc/include/asm/spinlock_64.h
8247 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
8248
8249 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
8250
8251 -static void inline arch_read_lock(arch_rwlock_t *lock)
8252 +static inline void arch_read_lock(arch_rwlock_t *lock)
8253 {
8254 unsigned long tmp1, tmp2;
8255
8256 __asm__ __volatile__ (
8257 "1: ldsw [%2], %0\n"
8258 " brlz,pn %0, 2f\n"
8259 -"4: add %0, 1, %1\n"
8260 +"4: addcc %0, 1, %1\n"
8261 +
8262 +#ifdef CONFIG_PAX_REFCOUNT
8263 +" tvs %%icc, 6\n"
8264 +#endif
8265 +
8266 " cas [%2], %0, %1\n"
8267 " cmp %0, %1\n"
8268 " bne,pn %%icc, 1b\n"
8269 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
8270 " .previous"
8271 : "=&r" (tmp1), "=&r" (tmp2)
8272 : "r" (lock)
8273 - : "memory");
8274 + : "memory", "cc");
8275 }
8276
8277 -static int inline arch_read_trylock(arch_rwlock_t *lock)
8278 +static inline int arch_read_trylock(arch_rwlock_t *lock)
8279 {
8280 int tmp1, tmp2;
8281
8282 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8283 "1: ldsw [%2], %0\n"
8284 " brlz,a,pn %0, 2f\n"
8285 " mov 0, %0\n"
8286 -" add %0, 1, %1\n"
8287 +" addcc %0, 1, %1\n"
8288 +
8289 +#ifdef CONFIG_PAX_REFCOUNT
8290 +" tvs %%icc, 6\n"
8291 +#endif
8292 +
8293 " cas [%2], %0, %1\n"
8294 " cmp %0, %1\n"
8295 " bne,pn %%icc, 1b\n"
8296 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8297 return tmp1;
8298 }
8299
8300 -static void inline arch_read_unlock(arch_rwlock_t *lock)
8301 +static inline void arch_read_unlock(arch_rwlock_t *lock)
8302 {
8303 unsigned long tmp1, tmp2;
8304
8305 __asm__ __volatile__(
8306 "1: lduw [%2], %0\n"
8307 -" sub %0, 1, %1\n"
8308 +" subcc %0, 1, %1\n"
8309 +
8310 +#ifdef CONFIG_PAX_REFCOUNT
8311 +" tvs %%icc, 6\n"
8312 +#endif
8313 +
8314 " cas [%2], %0, %1\n"
8315 " cmp %0, %1\n"
8316 " bne,pn %%xcc, 1b\n"
8317 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8318 : "memory");
8319 }
8320
8321 -static void inline arch_write_lock(arch_rwlock_t *lock)
8322 +static inline void arch_write_lock(arch_rwlock_t *lock)
8323 {
8324 unsigned long mask, tmp1, tmp2;
8325
8326 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8327 : "memory");
8328 }
8329
8330 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8331 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8332 {
8333 __asm__ __volatile__(
8334 " stw %%g0, [%0]"
8335 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8336 : "memory");
8337 }
8338
8339 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8340 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8341 {
8342 unsigned long mask, tmp1, tmp2, result;
8343
8344 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8345 index 25849ae..924c54b 100644
8346 --- a/arch/sparc/include/asm/thread_info_32.h
8347 +++ b/arch/sparc/include/asm/thread_info_32.h
8348 @@ -49,6 +49,8 @@ struct thread_info {
8349 unsigned long w_saved;
8350
8351 struct restart_block restart_block;
8352 +
8353 + unsigned long lowest_stack;
8354 };
8355
8356 /*
8357 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8358 index 269bd92..e46a9b8 100644
8359 --- a/arch/sparc/include/asm/thread_info_64.h
8360 +++ b/arch/sparc/include/asm/thread_info_64.h
8361 @@ -63,6 +63,8 @@ struct thread_info {
8362 struct pt_regs *kern_una_regs;
8363 unsigned int kern_una_insn;
8364
8365 + unsigned long lowest_stack;
8366 +
8367 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8368 };
8369
8370 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8371 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8372 /* flag bit 6 is available */
8373 #define TIF_32BIT 7 /* 32-bit binary */
8374 -/* flag bit 8 is available */
8375 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8376 #define TIF_SECCOMP 9 /* secure computing */
8377 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8378 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8379 +
8380 /* NOTE: Thread flags >= 12 should be ones we have no interest
8381 * in using in assembly, else we can't use the mask as
8382 * an immediate value in instructions such as andcc.
8383 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8384 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8385 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8386 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8387 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8388
8389 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8390 _TIF_DO_NOTIFY_RESUME_MASK | \
8391 _TIF_NEED_RESCHED)
8392 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8393
8394 +#define _TIF_WORK_SYSCALL \
8395 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8396 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8397 +
8398 +
8399 /*
8400 * Thread-synchronous status.
8401 *
8402 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8403 index 0167d26..767bb0c 100644
8404 --- a/arch/sparc/include/asm/uaccess.h
8405 +++ b/arch/sparc/include/asm/uaccess.h
8406 @@ -1,5 +1,6 @@
8407 #ifndef ___ASM_SPARC_UACCESS_H
8408 #define ___ASM_SPARC_UACCESS_H
8409 +
8410 #if defined(__sparc__) && defined(__arch64__)
8411 #include <asm/uaccess_64.h>
8412 #else
8413 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8414 index 53a28dd..50c38c3 100644
8415 --- a/arch/sparc/include/asm/uaccess_32.h
8416 +++ b/arch/sparc/include/asm/uaccess_32.h
8417 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8418
8419 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8420 {
8421 - if (n && __access_ok((unsigned long) to, n))
8422 + if ((long)n < 0)
8423 + return n;
8424 +
8425 + if (n && __access_ok((unsigned long) to, n)) {
8426 + if (!__builtin_constant_p(n))
8427 + check_object_size(from, n, true);
8428 return __copy_user(to, (__force void __user *) from, n);
8429 - else
8430 + } else
8431 return n;
8432 }
8433
8434 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8435 {
8436 + if ((long)n < 0)
8437 + return n;
8438 +
8439 + if (!__builtin_constant_p(n))
8440 + check_object_size(from, n, true);
8441 +
8442 return __copy_user(to, (__force void __user *) from, n);
8443 }
8444
8445 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8446 {
8447 - if (n && __access_ok((unsigned long) from, n))
8448 + if ((long)n < 0)
8449 + return n;
8450 +
8451 + if (n && __access_ok((unsigned long) from, n)) {
8452 + if (!__builtin_constant_p(n))
8453 + check_object_size(to, n, false);
8454 return __copy_user((__force void __user *) to, from, n);
8455 - else
8456 + } else
8457 return n;
8458 }
8459
8460 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8461 {
8462 + if ((long)n < 0)
8463 + return n;
8464 +
8465 return __copy_user((__force void __user *) to, from, n);
8466 }
8467
8468 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8469 index e562d3c..191f176 100644
8470 --- a/arch/sparc/include/asm/uaccess_64.h
8471 +++ b/arch/sparc/include/asm/uaccess_64.h
8472 @@ -10,6 +10,7 @@
8473 #include <linux/compiler.h>
8474 #include <linux/string.h>
8475 #include <linux/thread_info.h>
8476 +#include <linux/kernel.h>
8477 #include <asm/asi.h>
8478 #include <asm/spitfire.h>
8479 #include <asm-generic/uaccess-unaligned.h>
8480 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8481 static inline unsigned long __must_check
8482 copy_from_user(void *to, const void __user *from, unsigned long size)
8483 {
8484 - unsigned long ret = ___copy_from_user(to, from, size);
8485 + unsigned long ret;
8486
8487 + if ((long)size < 0 || size > INT_MAX)
8488 + return size;
8489 +
8490 + if (!__builtin_constant_p(size))
8491 + check_object_size(to, size, false);
8492 +
8493 + ret = ___copy_from_user(to, from, size);
8494 if (unlikely(ret))
8495 ret = copy_from_user_fixup(to, from, size);
8496
8497 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8498 static inline unsigned long __must_check
8499 copy_to_user(void __user *to, const void *from, unsigned long size)
8500 {
8501 - unsigned long ret = ___copy_to_user(to, from, size);
8502 + unsigned long ret;
8503
8504 + if ((long)size < 0 || size > INT_MAX)
8505 + return size;
8506 +
8507 + if (!__builtin_constant_p(size))
8508 + check_object_size(from, size, true);
8509 +
8510 + ret = ___copy_to_user(to, from, size);
8511 if (unlikely(ret))
8512 ret = copy_to_user_fixup(to, from, size);
8513 return ret;
8514 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8515 index 6cf591b..b49e65a 100644
8516 --- a/arch/sparc/kernel/Makefile
8517 +++ b/arch/sparc/kernel/Makefile
8518 @@ -3,7 +3,7 @@
8519 #
8520
8521 asflags-y := -ansi
8522 -ccflags-y := -Werror
8523 +#ccflags-y := -Werror
8524
8525 extra-y := head_$(BITS).o
8526
8527 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8528 index be8e862..5b50b12 100644
8529 --- a/arch/sparc/kernel/process_32.c
8530 +++ b/arch/sparc/kernel/process_32.c
8531 @@ -126,14 +126,14 @@ void show_regs(struct pt_regs *r)
8532
8533 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8534 r->psr, r->pc, r->npc, r->y, print_tainted());
8535 - printk("PC: <%pS>\n", (void *) r->pc);
8536 + printk("PC: <%pA>\n", (void *) r->pc);
8537 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8538 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8539 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8540 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8541 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8542 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8543 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8544 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8545
8546 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8547 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8548 @@ -168,7 +168,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8549 rw = (struct reg_window32 *) fp;
8550 pc = rw->ins[7];
8551 printk("[%08lx : ", pc);
8552 - printk("%pS ] ", (void *) pc);
8553 + printk("%pA ] ", (void *) pc);
8554 fp = rw->ins[6];
8555 } while (++count < 16);
8556 printk("\n");
8557 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8558 index cdb80b2..5ca141d 100644
8559 --- a/arch/sparc/kernel/process_64.c
8560 +++ b/arch/sparc/kernel/process_64.c
8561 @@ -181,14 +181,14 @@ static void show_regwindow(struct pt_regs *regs)
8562 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8563 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8564 if (regs->tstate & TSTATE_PRIV)
8565 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8566 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8567 }
8568
8569 void show_regs(struct pt_regs *regs)
8570 {
8571 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8572 regs->tpc, regs->tnpc, regs->y, print_tainted());
8573 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8574 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8575 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8576 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8577 regs->u_regs[3]);
8578 @@ -201,7 +201,7 @@ void show_regs(struct pt_regs *regs)
8579 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8580 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8581 regs->u_regs[15]);
8582 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8583 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8584 show_regwindow(regs);
8585 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8586 }
8587 @@ -290,7 +290,7 @@ void arch_trigger_all_cpu_backtrace(void)
8588 ((tp && tp->task) ? tp->task->pid : -1));
8589
8590 if (gp->tstate & TSTATE_PRIV) {
8591 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8592 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8593 (void *) gp->tpc,
8594 (void *) gp->o7,
8595 (void *) gp->i7,
8596 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
8597 index 1303021..c2a6321 100644
8598 --- a/arch/sparc/kernel/prom_common.c
8599 +++ b/arch/sparc/kernel/prom_common.c
8600 @@ -143,7 +143,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
8601
8602 unsigned int prom_early_allocated __initdata;
8603
8604 -static struct of_pdt_ops prom_sparc_ops __initdata = {
8605 +static struct of_pdt_ops prom_sparc_ops __initconst = {
8606 .nextprop = prom_common_nextprop,
8607 .getproplen = prom_getproplen,
8608 .getproperty = prom_getproperty,
8609 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8610 index 7ff45e4..a58f271 100644
8611 --- a/arch/sparc/kernel/ptrace_64.c
8612 +++ b/arch/sparc/kernel/ptrace_64.c
8613 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8614 return ret;
8615 }
8616
8617 +#ifdef CONFIG_GRKERNSEC_SETXID
8618 +extern void gr_delayed_cred_worker(void);
8619 +#endif
8620 +
8621 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8622 {
8623 int ret = 0;
8624 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8625 /* do the secure computing check first */
8626 secure_computing_strict(regs->u_regs[UREG_G1]);
8627
8628 +#ifdef CONFIG_GRKERNSEC_SETXID
8629 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8630 + gr_delayed_cred_worker();
8631 +#endif
8632 +
8633 if (test_thread_flag(TIF_SYSCALL_TRACE))
8634 ret = tracehook_report_syscall_entry(regs);
8635
8636 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8637
8638 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8639 {
8640 +#ifdef CONFIG_GRKERNSEC_SETXID
8641 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8642 + gr_delayed_cred_worker();
8643 +#endif
8644 +
8645 audit_syscall_exit(regs);
8646
8647 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8648 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8649 index 2da0bdc..79128d2 100644
8650 --- a/arch/sparc/kernel/sys_sparc_32.c
8651 +++ b/arch/sparc/kernel/sys_sparc_32.c
8652 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8653 if (len > TASK_SIZE - PAGE_SIZE)
8654 return -ENOMEM;
8655 if (!addr)
8656 - addr = TASK_UNMAPPED_BASE;
8657 + addr = current->mm->mmap_base;
8658
8659 info.flags = 0;
8660 info.length = len;
8661 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8662 index 708bc29..f0129cb 100644
8663 --- a/arch/sparc/kernel/sys_sparc_64.c
8664 +++ b/arch/sparc/kernel/sys_sparc_64.c
8665 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8666 struct vm_area_struct * vma;
8667 unsigned long task_size = TASK_SIZE;
8668 int do_color_align;
8669 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8670 struct vm_unmapped_area_info info;
8671
8672 if (flags & MAP_FIXED) {
8673 /* We do not accept a shared mapping if it would violate
8674 * cache aliasing constraints.
8675 */
8676 - if ((flags & MAP_SHARED) &&
8677 + if ((filp || (flags & MAP_SHARED)) &&
8678 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8679 return -EINVAL;
8680 return addr;
8681 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8682 if (filp || (flags & MAP_SHARED))
8683 do_color_align = 1;
8684
8685 +#ifdef CONFIG_PAX_RANDMMAP
8686 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8687 +#endif
8688 +
8689 if (addr) {
8690 if (do_color_align)
8691 addr = COLOR_ALIGN(addr, pgoff);
8692 @@ -118,14 +123,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8693 addr = PAGE_ALIGN(addr);
8694
8695 vma = find_vma(mm, addr);
8696 - if (task_size - len >= addr &&
8697 - (!vma || addr + len <= vma->vm_start))
8698 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8699 return addr;
8700 }
8701
8702 info.flags = 0;
8703 info.length = len;
8704 - info.low_limit = TASK_UNMAPPED_BASE;
8705 + info.low_limit = mm->mmap_base;
8706 info.high_limit = min(task_size, VA_EXCLUDE_START);
8707 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8708 info.align_offset = pgoff << PAGE_SHIFT;
8709 @@ -134,6 +138,12 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8710 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8711 VM_BUG_ON(addr != -ENOMEM);
8712 info.low_limit = VA_EXCLUDE_END;
8713 +
8714 +#ifdef CONFIG_PAX_RANDMMAP
8715 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8716 + info.low_limit += mm->delta_mmap;
8717 +#endif
8718 +
8719 info.high_limit = task_size;
8720 addr = vm_unmapped_area(&info);
8721 }
8722 @@ -151,6 +161,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8723 unsigned long task_size = STACK_TOP32;
8724 unsigned long addr = addr0;
8725 int do_color_align;
8726 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8727 struct vm_unmapped_area_info info;
8728
8729 /* This should only ever run for 32-bit processes. */
8730 @@ -160,7 +171,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8731 /* We do not accept a shared mapping if it would violate
8732 * cache aliasing constraints.
8733 */
8734 - if ((flags & MAP_SHARED) &&
8735 + if ((filp || (flags & MAP_SHARED)) &&
8736 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8737 return -EINVAL;
8738 return addr;
8739 @@ -173,6 +184,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8740 if (filp || (flags & MAP_SHARED))
8741 do_color_align = 1;
8742
8743 +#ifdef CONFIG_PAX_RANDMMAP
8744 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8745 +#endif
8746 +
8747 /* requesting a specific address */
8748 if (addr) {
8749 if (do_color_align)
8750 @@ -181,8 +196,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8751 addr = PAGE_ALIGN(addr);
8752
8753 vma = find_vma(mm, addr);
8754 - if (task_size - len >= addr &&
8755 - (!vma || addr + len <= vma->vm_start))
8756 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8757 return addr;
8758 }
8759
8760 @@ -204,6 +218,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8761 VM_BUG_ON(addr != -ENOMEM);
8762 info.flags = 0;
8763 info.low_limit = TASK_UNMAPPED_BASE;
8764 +
8765 +#ifdef CONFIG_PAX_RANDMMAP
8766 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8767 + info.low_limit += mm->delta_mmap;
8768 +#endif
8769 +
8770 info.high_limit = STACK_TOP32;
8771 addr = vm_unmapped_area(&info);
8772 }
8773 @@ -264,6 +284,10 @@ static unsigned long mmap_rnd(void)
8774 {
8775 unsigned long rnd = 0UL;
8776
8777 +#ifdef CONFIG_PAX_RANDMMAP
8778 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8779 +#endif
8780 +
8781 if (current->flags & PF_RANDOMIZE) {
8782 unsigned long val = get_random_int();
8783 if (test_thread_flag(TIF_32BIT))
8784 @@ -289,6 +313,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8785 gap == RLIM_INFINITY ||
8786 sysctl_legacy_va_layout) {
8787 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8788 +
8789 +#ifdef CONFIG_PAX_RANDMMAP
8790 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8791 + mm->mmap_base += mm->delta_mmap;
8792 +#endif
8793 +
8794 mm->get_unmapped_area = arch_get_unmapped_area;
8795 mm->unmap_area = arch_unmap_area;
8796 } else {
8797 @@ -301,6 +331,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8798 gap = (task_size / 6 * 5);
8799
8800 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8801 +
8802 +#ifdef CONFIG_PAX_RANDMMAP
8803 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8804 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8805 +#endif
8806 +
8807 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8808 mm->unmap_area = arch_unmap_area_topdown;
8809 }
8810 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8811 index e0fed77..604a7e5 100644
8812 --- a/arch/sparc/kernel/syscalls.S
8813 +++ b/arch/sparc/kernel/syscalls.S
8814 @@ -58,7 +58,7 @@ sys32_rt_sigreturn:
8815 #endif
8816 .align 32
8817 1: ldx [%g6 + TI_FLAGS], %l5
8818 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8819 + andcc %l5, _TIF_WORK_SYSCALL, %g0
8820 be,pt %icc, rtrap
8821 nop
8822 call syscall_trace_leave
8823 @@ -190,7 +190,7 @@ linux_sparc_syscall32:
8824
8825 srl %i5, 0, %o5 ! IEU1
8826 srl %i2, 0, %o2 ! IEU0 Group
8827 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8828 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8829 bne,pn %icc, linux_syscall_trace32 ! CTI
8830 mov %i0, %l5 ! IEU1
8831 call %l7 ! CTI Group brk forced
8832 @@ -213,7 +213,7 @@ linux_sparc_syscall:
8833
8834 mov %i3, %o3 ! IEU1
8835 mov %i4, %o4 ! IEU0 Group
8836 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8837 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8838 bne,pn %icc, linux_syscall_trace ! CTI Group
8839 mov %i0, %l5 ! IEU0
8840 2: call %l7 ! CTI Group brk forced
8841 @@ -229,7 +229,7 @@ ret_sys_call:
8842
8843 cmp %o0, -ERESTART_RESTARTBLOCK
8844 bgeu,pn %xcc, 1f
8845 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8846 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8847 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
8848
8849 2:
8850 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
8851 index 654e8aa..45f431b 100644
8852 --- a/arch/sparc/kernel/sysfs.c
8853 +++ b/arch/sparc/kernel/sysfs.c
8854 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8855 return NOTIFY_OK;
8856 }
8857
8858 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8859 +static struct notifier_block sysfs_cpu_nb = {
8860 .notifier_call = sysfs_cpu_notify,
8861 };
8862
8863 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
8864 index a5785ea..405c5f7 100644
8865 --- a/arch/sparc/kernel/traps_32.c
8866 +++ b/arch/sparc/kernel/traps_32.c
8867 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
8868 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
8869 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
8870
8871 +extern void gr_handle_kernel_exploit(void);
8872 +
8873 void die_if_kernel(char *str, struct pt_regs *regs)
8874 {
8875 static int die_counter;
8876 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8877 count++ < 30 &&
8878 (((unsigned long) rw) >= PAGE_OFFSET) &&
8879 !(((unsigned long) rw) & 0x7)) {
8880 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
8881 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
8882 (void *) rw->ins[7]);
8883 rw = (struct reg_window32 *)rw->ins[6];
8884 }
8885 }
8886 printk("Instruction DUMP:");
8887 instruction_dump ((unsigned long *) regs->pc);
8888 - if(regs->psr & PSR_PS)
8889 + if(regs->psr & PSR_PS) {
8890 + gr_handle_kernel_exploit();
8891 do_exit(SIGKILL);
8892 + }
8893 do_exit(SIGSEGV);
8894 }
8895
8896 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
8897 index e7ecf15..6520e65 100644
8898 --- a/arch/sparc/kernel/traps_64.c
8899 +++ b/arch/sparc/kernel/traps_64.c
8900 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
8901 i + 1,
8902 p->trapstack[i].tstate, p->trapstack[i].tpc,
8903 p->trapstack[i].tnpc, p->trapstack[i].tt);
8904 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
8905 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
8906 }
8907 }
8908
8909 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
8910
8911 lvl -= 0x100;
8912 if (regs->tstate & TSTATE_PRIV) {
8913 +
8914 +#ifdef CONFIG_PAX_REFCOUNT
8915 + if (lvl == 6)
8916 + pax_report_refcount_overflow(regs);
8917 +#endif
8918 +
8919 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
8920 die_if_kernel(buffer, regs);
8921 }
8922 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
8923 void bad_trap_tl1(struct pt_regs *regs, long lvl)
8924 {
8925 char buffer[32];
8926 -
8927 +
8928 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
8929 0, lvl, SIGTRAP) == NOTIFY_STOP)
8930 return;
8931
8932 +#ifdef CONFIG_PAX_REFCOUNT
8933 + if (lvl == 6)
8934 + pax_report_refcount_overflow(regs);
8935 +#endif
8936 +
8937 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
8938
8939 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
8940 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
8941 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
8942 printk("%s" "ERROR(%d): ",
8943 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
8944 - printk("TPC<%pS>\n", (void *) regs->tpc);
8945 + printk("TPC<%pA>\n", (void *) regs->tpc);
8946 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
8947 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
8948 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
8949 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8950 smp_processor_id(),
8951 (type & 0x1) ? 'I' : 'D',
8952 regs->tpc);
8953 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
8954 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
8955 panic("Irrecoverable Cheetah+ parity error.");
8956 }
8957
8958 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8959 smp_processor_id(),
8960 (type & 0x1) ? 'I' : 'D',
8961 regs->tpc);
8962 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
8963 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
8964 }
8965
8966 struct sun4v_error_entry {
8967 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
8968
8969 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
8970 regs->tpc, tl);
8971 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
8972 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
8973 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8974 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
8975 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
8976 (void *) regs->u_regs[UREG_I7]);
8977 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
8978 "pte[%lx] error[%lx]\n",
8979 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
8980
8981 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
8982 regs->tpc, tl);
8983 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
8984 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
8985 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8986 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
8987 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
8988 (void *) regs->u_regs[UREG_I7]);
8989 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
8990 "pte[%lx] error[%lx]\n",
8991 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8992 fp = (unsigned long)sf->fp + STACK_BIAS;
8993 }
8994
8995 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8996 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8997 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8998 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
8999 int index = tsk->curr_ret_stack;
9000 if (tsk->ret_stack && index >= graph) {
9001 pc = tsk->ret_stack[index - graph].ret;
9002 - printk(" [%016lx] %pS\n", pc, (void *) pc);
9003 + printk(" [%016lx] %pA\n", pc, (void *) pc);
9004 graph++;
9005 }
9006 }
9007 @@ -2367,6 +2378,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
9008 return (struct reg_window *) (fp + STACK_BIAS);
9009 }
9010
9011 +extern void gr_handle_kernel_exploit(void);
9012 +
9013 void die_if_kernel(char *str, struct pt_regs *regs)
9014 {
9015 static int die_counter;
9016 @@ -2395,7 +2408,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9017 while (rw &&
9018 count++ < 30 &&
9019 kstack_valid(tp, (unsigned long) rw)) {
9020 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
9021 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
9022 (void *) rw->ins[7]);
9023
9024 rw = kernel_stack_up(rw);
9025 @@ -2408,8 +2421,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9026 }
9027 user_instruction_dump ((unsigned int __user *) regs->tpc);
9028 }
9029 - if (regs->tstate & TSTATE_PRIV)
9030 + if (regs->tstate & TSTATE_PRIV) {
9031 + gr_handle_kernel_exploit();
9032 do_exit(SIGKILL);
9033 + }
9034 do_exit(SIGSEGV);
9035 }
9036 EXPORT_SYMBOL(die_if_kernel);
9037 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
9038 index 8201c25e..072a2a7 100644
9039 --- a/arch/sparc/kernel/unaligned_64.c
9040 +++ b/arch/sparc/kernel/unaligned_64.c
9041 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
9042 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
9043
9044 if (__ratelimit(&ratelimit)) {
9045 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
9046 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
9047 regs->tpc, (void *) regs->tpc);
9048 }
9049 }
9050 diff --git a/arch/sparc/kernel/us3_cpufreq.c b/arch/sparc/kernel/us3_cpufreq.c
9051 index eb1624b..f9f4ddb 100644
9052 --- a/arch/sparc/kernel/us3_cpufreq.c
9053 +++ b/arch/sparc/kernel/us3_cpufreq.c
9054 @@ -18,14 +18,12 @@
9055 #include <asm/head.h>
9056 #include <asm/timer.h>
9057
9058 -static struct cpufreq_driver *cpufreq_us3_driver;
9059 -
9060 struct us3_freq_percpu_info {
9061 struct cpufreq_frequency_table table[4];
9062 };
9063
9064 /* Indexed by cpu number. */
9065 -static struct us3_freq_percpu_info *us3_freq_table;
9066 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
9067
9068 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
9069 * in the Safari config register.
9070 @@ -191,12 +189,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
9071
9072 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
9073 {
9074 - if (cpufreq_us3_driver)
9075 - us3_set_cpu_divider_index(policy->cpu, 0);
9076 + us3_set_cpu_divider_index(policy->cpu, 0);
9077
9078 return 0;
9079 }
9080
9081 +static int __init us3_freq_init(void);
9082 +static void __exit us3_freq_exit(void);
9083 +
9084 +static struct cpufreq_driver cpufreq_us3_driver = {
9085 + .init = us3_freq_cpu_init,
9086 + .verify = us3_freq_verify,
9087 + .target = us3_freq_target,
9088 + .get = us3_freq_get,
9089 + .exit = us3_freq_cpu_exit,
9090 + .owner = THIS_MODULE,
9091 + .name = "UltraSPARC-III",
9092 +
9093 +};
9094 +
9095 static int __init us3_freq_init(void)
9096 {
9097 unsigned long manuf, impl, ver;
9098 @@ -213,57 +224,15 @@ static int __init us3_freq_init(void)
9099 (impl == CHEETAH_IMPL ||
9100 impl == CHEETAH_PLUS_IMPL ||
9101 impl == JAGUAR_IMPL ||
9102 - impl == PANTHER_IMPL)) {
9103 - struct cpufreq_driver *driver;
9104 -
9105 - ret = -ENOMEM;
9106 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
9107 - if (!driver)
9108 - goto err_out;
9109 -
9110 - us3_freq_table = kzalloc(
9111 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
9112 - GFP_KERNEL);
9113 - if (!us3_freq_table)
9114 - goto err_out;
9115 -
9116 - driver->init = us3_freq_cpu_init;
9117 - driver->verify = us3_freq_verify;
9118 - driver->target = us3_freq_target;
9119 - driver->get = us3_freq_get;
9120 - driver->exit = us3_freq_cpu_exit;
9121 - driver->owner = THIS_MODULE,
9122 - strcpy(driver->name, "UltraSPARC-III");
9123 -
9124 - cpufreq_us3_driver = driver;
9125 - ret = cpufreq_register_driver(driver);
9126 - if (ret)
9127 - goto err_out;
9128 -
9129 - return 0;
9130 -
9131 -err_out:
9132 - if (driver) {
9133 - kfree(driver);
9134 - cpufreq_us3_driver = NULL;
9135 - }
9136 - kfree(us3_freq_table);
9137 - us3_freq_table = NULL;
9138 - return ret;
9139 - }
9140 + impl == PANTHER_IMPL))
9141 + return cpufreq_register_driver(cpufreq_us3_driver);
9142
9143 return -ENODEV;
9144 }
9145
9146 static void __exit us3_freq_exit(void)
9147 {
9148 - if (cpufreq_us3_driver) {
9149 - cpufreq_unregister_driver(cpufreq_us3_driver);
9150 - kfree(cpufreq_us3_driver);
9151 - cpufreq_us3_driver = NULL;
9152 - kfree(us3_freq_table);
9153 - us3_freq_table = NULL;
9154 - }
9155 + cpufreq_unregister_driver(cpufreq_us3_driver);
9156 }
9157
9158 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
9159 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
9160 index 8410065f2..4fd4ca22 100644
9161 --- a/arch/sparc/lib/Makefile
9162 +++ b/arch/sparc/lib/Makefile
9163 @@ -2,7 +2,7 @@
9164 #
9165
9166 asflags-y := -ansi -DST_DIV0=0x02
9167 -ccflags-y := -Werror
9168 +#ccflags-y := -Werror
9169
9170 lib-$(CONFIG_SPARC32) += ashrdi3.o
9171 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
9172 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
9173 index 85c233d..68500e0 100644
9174 --- a/arch/sparc/lib/atomic_64.S
9175 +++ b/arch/sparc/lib/atomic_64.S
9176 @@ -17,7 +17,12 @@
9177 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
9178 BACKOFF_SETUP(%o2)
9179 1: lduw [%o1], %g1
9180 - add %g1, %o0, %g7
9181 + addcc %g1, %o0, %g7
9182 +
9183 +#ifdef CONFIG_PAX_REFCOUNT
9184 + tvs %icc, 6
9185 +#endif
9186 +
9187 cas [%o1], %g1, %g7
9188 cmp %g1, %g7
9189 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9190 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
9191 2: BACKOFF_SPIN(%o2, %o3, 1b)
9192 ENDPROC(atomic_add)
9193
9194 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9195 + BACKOFF_SETUP(%o2)
9196 +1: lduw [%o1], %g1
9197 + add %g1, %o0, %g7
9198 + cas [%o1], %g1, %g7
9199 + cmp %g1, %g7
9200 + bne,pn %icc, 2f
9201 + nop
9202 + retl
9203 + nop
9204 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9205 +ENDPROC(atomic_add_unchecked)
9206 +
9207 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9208 BACKOFF_SETUP(%o2)
9209 1: lduw [%o1], %g1
9210 - sub %g1, %o0, %g7
9211 + subcc %g1, %o0, %g7
9212 +
9213 +#ifdef CONFIG_PAX_REFCOUNT
9214 + tvs %icc, 6
9215 +#endif
9216 +
9217 cas [%o1], %g1, %g7
9218 cmp %g1, %g7
9219 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9220 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9221 2: BACKOFF_SPIN(%o2, %o3, 1b)
9222 ENDPROC(atomic_sub)
9223
9224 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9225 + BACKOFF_SETUP(%o2)
9226 +1: lduw [%o1], %g1
9227 + sub %g1, %o0, %g7
9228 + cas [%o1], %g1, %g7
9229 + cmp %g1, %g7
9230 + bne,pn %icc, 2f
9231 + nop
9232 + retl
9233 + nop
9234 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9235 +ENDPROC(atomic_sub_unchecked)
9236 +
9237 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9238 BACKOFF_SETUP(%o2)
9239 1: lduw [%o1], %g1
9240 - add %g1, %o0, %g7
9241 + addcc %g1, %o0, %g7
9242 +
9243 +#ifdef CONFIG_PAX_REFCOUNT
9244 + tvs %icc, 6
9245 +#endif
9246 +
9247 cas [%o1], %g1, %g7
9248 cmp %g1, %g7
9249 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9250 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9251 2: BACKOFF_SPIN(%o2, %o3, 1b)
9252 ENDPROC(atomic_add_ret)
9253
9254 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9255 + BACKOFF_SETUP(%o2)
9256 +1: lduw [%o1], %g1
9257 + addcc %g1, %o0, %g7
9258 + cas [%o1], %g1, %g7
9259 + cmp %g1, %g7
9260 + bne,pn %icc, 2f
9261 + add %g7, %o0, %g7
9262 + sra %g7, 0, %o0
9263 + retl
9264 + nop
9265 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9266 +ENDPROC(atomic_add_ret_unchecked)
9267 +
9268 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9269 BACKOFF_SETUP(%o2)
9270 1: lduw [%o1], %g1
9271 - sub %g1, %o0, %g7
9272 + subcc %g1, %o0, %g7
9273 +
9274 +#ifdef CONFIG_PAX_REFCOUNT
9275 + tvs %icc, 6
9276 +#endif
9277 +
9278 cas [%o1], %g1, %g7
9279 cmp %g1, %g7
9280 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9281 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
9282 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9283 BACKOFF_SETUP(%o2)
9284 1: ldx [%o1], %g1
9285 - add %g1, %o0, %g7
9286 + addcc %g1, %o0, %g7
9287 +
9288 +#ifdef CONFIG_PAX_REFCOUNT
9289 + tvs %xcc, 6
9290 +#endif
9291 +
9292 casx [%o1], %g1, %g7
9293 cmp %g1, %g7
9294 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9295 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9296 2: BACKOFF_SPIN(%o2, %o3, 1b)
9297 ENDPROC(atomic64_add)
9298
9299 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9300 + BACKOFF_SETUP(%o2)
9301 +1: ldx [%o1], %g1
9302 + addcc %g1, %o0, %g7
9303 + casx [%o1], %g1, %g7
9304 + cmp %g1, %g7
9305 + bne,pn %xcc, 2f
9306 + nop
9307 + retl
9308 + nop
9309 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9310 +ENDPROC(atomic64_add_unchecked)
9311 +
9312 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9313 BACKOFF_SETUP(%o2)
9314 1: ldx [%o1], %g1
9315 - sub %g1, %o0, %g7
9316 + subcc %g1, %o0, %g7
9317 +
9318 +#ifdef CONFIG_PAX_REFCOUNT
9319 + tvs %xcc, 6
9320 +#endif
9321 +
9322 casx [%o1], %g1, %g7
9323 cmp %g1, %g7
9324 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9325 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9326 2: BACKOFF_SPIN(%o2, %o3, 1b)
9327 ENDPROC(atomic64_sub)
9328
9329 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9330 + BACKOFF_SETUP(%o2)
9331 +1: ldx [%o1], %g1
9332 + subcc %g1, %o0, %g7
9333 + casx [%o1], %g1, %g7
9334 + cmp %g1, %g7
9335 + bne,pn %xcc, 2f
9336 + nop
9337 + retl
9338 + nop
9339 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9340 +ENDPROC(atomic64_sub_unchecked)
9341 +
9342 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9343 BACKOFF_SETUP(%o2)
9344 1: ldx [%o1], %g1
9345 - add %g1, %o0, %g7
9346 + addcc %g1, %o0, %g7
9347 +
9348 +#ifdef CONFIG_PAX_REFCOUNT
9349 + tvs %xcc, 6
9350 +#endif
9351 +
9352 casx [%o1], %g1, %g7
9353 cmp %g1, %g7
9354 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9355 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9356 2: BACKOFF_SPIN(%o2, %o3, 1b)
9357 ENDPROC(atomic64_add_ret)
9358
9359 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9360 + BACKOFF_SETUP(%o2)
9361 +1: ldx [%o1], %g1
9362 + addcc %g1, %o0, %g7
9363 + casx [%o1], %g1, %g7
9364 + cmp %g1, %g7
9365 + bne,pn %xcc, 2f
9366 + add %g7, %o0, %g7
9367 + mov %g7, %o0
9368 + retl
9369 + nop
9370 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9371 +ENDPROC(atomic64_add_ret_unchecked)
9372 +
9373 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9374 BACKOFF_SETUP(%o2)
9375 1: ldx [%o1], %g1
9376 - sub %g1, %o0, %g7
9377 + subcc %g1, %o0, %g7
9378 +
9379 +#ifdef CONFIG_PAX_REFCOUNT
9380 + tvs %xcc, 6
9381 +#endif
9382 +
9383 casx [%o1], %g1, %g7
9384 cmp %g1, %g7
9385 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9386 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9387 index 0c4e35e..745d3e4 100644
9388 --- a/arch/sparc/lib/ksyms.c
9389 +++ b/arch/sparc/lib/ksyms.c
9390 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9391
9392 /* Atomic counter implementation. */
9393 EXPORT_SYMBOL(atomic_add);
9394 +EXPORT_SYMBOL(atomic_add_unchecked);
9395 EXPORT_SYMBOL(atomic_add_ret);
9396 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9397 EXPORT_SYMBOL(atomic_sub);
9398 +EXPORT_SYMBOL(atomic_sub_unchecked);
9399 EXPORT_SYMBOL(atomic_sub_ret);
9400 EXPORT_SYMBOL(atomic64_add);
9401 +EXPORT_SYMBOL(atomic64_add_unchecked);
9402 EXPORT_SYMBOL(atomic64_add_ret);
9403 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9404 EXPORT_SYMBOL(atomic64_sub);
9405 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9406 EXPORT_SYMBOL(atomic64_sub_ret);
9407 EXPORT_SYMBOL(atomic64_dec_if_positive);
9408
9409 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9410 index 30c3ecc..736f015 100644
9411 --- a/arch/sparc/mm/Makefile
9412 +++ b/arch/sparc/mm/Makefile
9413 @@ -2,7 +2,7 @@
9414 #
9415
9416 asflags-y := -ansi
9417 -ccflags-y := -Werror
9418 +#ccflags-y := -Werror
9419
9420 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9421 obj-y += fault_$(BITS).o
9422 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9423 index e98bfda..ea8d221 100644
9424 --- a/arch/sparc/mm/fault_32.c
9425 +++ b/arch/sparc/mm/fault_32.c
9426 @@ -21,6 +21,9 @@
9427 #include <linux/perf_event.h>
9428 #include <linux/interrupt.h>
9429 #include <linux/kdebug.h>
9430 +#include <linux/slab.h>
9431 +#include <linux/pagemap.h>
9432 +#include <linux/compiler.h>
9433
9434 #include <asm/page.h>
9435 #include <asm/pgtable.h>
9436 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9437 return safe_compute_effective_address(regs, insn);
9438 }
9439
9440 +#ifdef CONFIG_PAX_PAGEEXEC
9441 +#ifdef CONFIG_PAX_DLRESOLVE
9442 +static void pax_emuplt_close(struct vm_area_struct *vma)
9443 +{
9444 + vma->vm_mm->call_dl_resolve = 0UL;
9445 +}
9446 +
9447 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9448 +{
9449 + unsigned int *kaddr;
9450 +
9451 + vmf->page = alloc_page(GFP_HIGHUSER);
9452 + if (!vmf->page)
9453 + return VM_FAULT_OOM;
9454 +
9455 + kaddr = kmap(vmf->page);
9456 + memset(kaddr, 0, PAGE_SIZE);
9457 + kaddr[0] = 0x9DE3BFA8U; /* save */
9458 + flush_dcache_page(vmf->page);
9459 + kunmap(vmf->page);
9460 + return VM_FAULT_MAJOR;
9461 +}
9462 +
9463 +static const struct vm_operations_struct pax_vm_ops = {
9464 + .close = pax_emuplt_close,
9465 + .fault = pax_emuplt_fault
9466 +};
9467 +
9468 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9469 +{
9470 + int ret;
9471 +
9472 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9473 + vma->vm_mm = current->mm;
9474 + vma->vm_start = addr;
9475 + vma->vm_end = addr + PAGE_SIZE;
9476 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9477 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9478 + vma->vm_ops = &pax_vm_ops;
9479 +
9480 + ret = insert_vm_struct(current->mm, vma);
9481 + if (ret)
9482 + return ret;
9483 +
9484 + ++current->mm->total_vm;
9485 + return 0;
9486 +}
9487 +#endif
9488 +
9489 +/*
9490 + * PaX: decide what to do with offenders (regs->pc = fault address)
9491 + *
9492 + * returns 1 when task should be killed
9493 + * 2 when patched PLT trampoline was detected
9494 + * 3 when unpatched PLT trampoline was detected
9495 + */
9496 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9497 +{
9498 +
9499 +#ifdef CONFIG_PAX_EMUPLT
9500 + int err;
9501 +
9502 + do { /* PaX: patched PLT emulation #1 */
9503 + unsigned int sethi1, sethi2, jmpl;
9504 +
9505 + err = get_user(sethi1, (unsigned int *)regs->pc);
9506 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9507 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9508 +
9509 + if (err)
9510 + break;
9511 +
9512 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9513 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9514 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9515 + {
9516 + unsigned int addr;
9517 +
9518 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9519 + addr = regs->u_regs[UREG_G1];
9520 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9521 + regs->pc = addr;
9522 + regs->npc = addr+4;
9523 + return 2;
9524 + }
9525 + } while (0);
9526 +
9527 + do { /* PaX: patched PLT emulation #2 */
9528 + unsigned int ba;
9529 +
9530 + err = get_user(ba, (unsigned int *)regs->pc);
9531 +
9532 + if (err)
9533 + break;
9534 +
9535 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9536 + unsigned int addr;
9537 +
9538 + if ((ba & 0xFFC00000U) == 0x30800000U)
9539 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9540 + else
9541 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9542 + regs->pc = addr;
9543 + regs->npc = addr+4;
9544 + return 2;
9545 + }
9546 + } while (0);
9547 +
9548 + do { /* PaX: patched PLT emulation #3 */
9549 + unsigned int sethi, bajmpl, nop;
9550 +
9551 + err = get_user(sethi, (unsigned int *)regs->pc);
9552 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9553 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9554 +
9555 + if (err)
9556 + break;
9557 +
9558 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9559 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9560 + nop == 0x01000000U)
9561 + {
9562 + unsigned int addr;
9563 +
9564 + addr = (sethi & 0x003FFFFFU) << 10;
9565 + regs->u_regs[UREG_G1] = addr;
9566 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9567 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9568 + else
9569 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9570 + regs->pc = addr;
9571 + regs->npc = addr+4;
9572 + return 2;
9573 + }
9574 + } while (0);
9575 +
9576 + do { /* PaX: unpatched PLT emulation step 1 */
9577 + unsigned int sethi, ba, nop;
9578 +
9579 + err = get_user(sethi, (unsigned int *)regs->pc);
9580 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9581 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9582 +
9583 + if (err)
9584 + break;
9585 +
9586 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9587 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9588 + nop == 0x01000000U)
9589 + {
9590 + unsigned int addr, save, call;
9591 +
9592 + if ((ba & 0xFFC00000U) == 0x30800000U)
9593 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9594 + else
9595 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9596 +
9597 + err = get_user(save, (unsigned int *)addr);
9598 + err |= get_user(call, (unsigned int *)(addr+4));
9599 + err |= get_user(nop, (unsigned int *)(addr+8));
9600 + if (err)
9601 + break;
9602 +
9603 +#ifdef CONFIG_PAX_DLRESOLVE
9604 + if (save == 0x9DE3BFA8U &&
9605 + (call & 0xC0000000U) == 0x40000000U &&
9606 + nop == 0x01000000U)
9607 + {
9608 + struct vm_area_struct *vma;
9609 + unsigned long call_dl_resolve;
9610 +
9611 + down_read(&current->mm->mmap_sem);
9612 + call_dl_resolve = current->mm->call_dl_resolve;
9613 + up_read(&current->mm->mmap_sem);
9614 + if (likely(call_dl_resolve))
9615 + goto emulate;
9616 +
9617 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9618 +
9619 + down_write(&current->mm->mmap_sem);
9620 + if (current->mm->call_dl_resolve) {
9621 + call_dl_resolve = current->mm->call_dl_resolve;
9622 + up_write(&current->mm->mmap_sem);
9623 + if (vma)
9624 + kmem_cache_free(vm_area_cachep, vma);
9625 + goto emulate;
9626 + }
9627 +
9628 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9629 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9630 + up_write(&current->mm->mmap_sem);
9631 + if (vma)
9632 + kmem_cache_free(vm_area_cachep, vma);
9633 + return 1;
9634 + }
9635 +
9636 + if (pax_insert_vma(vma, call_dl_resolve)) {
9637 + up_write(&current->mm->mmap_sem);
9638 + kmem_cache_free(vm_area_cachep, vma);
9639 + return 1;
9640 + }
9641 +
9642 + current->mm->call_dl_resolve = call_dl_resolve;
9643 + up_write(&current->mm->mmap_sem);
9644 +
9645 +emulate:
9646 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9647 + regs->pc = call_dl_resolve;
9648 + regs->npc = addr+4;
9649 + return 3;
9650 + }
9651 +#endif
9652 +
9653 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9654 + if ((save & 0xFFC00000U) == 0x05000000U &&
9655 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9656 + nop == 0x01000000U)
9657 + {
9658 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9659 + regs->u_regs[UREG_G2] = addr + 4;
9660 + addr = (save & 0x003FFFFFU) << 10;
9661 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9662 + regs->pc = addr;
9663 + regs->npc = addr+4;
9664 + return 3;
9665 + }
9666 + }
9667 + } while (0);
9668 +
9669 + do { /* PaX: unpatched PLT emulation step 2 */
9670 + unsigned int save, call, nop;
9671 +
9672 + err = get_user(save, (unsigned int *)(regs->pc-4));
9673 + err |= get_user(call, (unsigned int *)regs->pc);
9674 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9675 + if (err)
9676 + break;
9677 +
9678 + if (save == 0x9DE3BFA8U &&
9679 + (call & 0xC0000000U) == 0x40000000U &&
9680 + nop == 0x01000000U)
9681 + {
9682 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9683 +
9684 + regs->u_regs[UREG_RETPC] = regs->pc;
9685 + regs->pc = dl_resolve;
9686 + regs->npc = dl_resolve+4;
9687 + return 3;
9688 + }
9689 + } while (0);
9690 +#endif
9691 +
9692 + return 1;
9693 +}
9694 +
9695 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9696 +{
9697 + unsigned long i;
9698 +
9699 + printk(KERN_ERR "PAX: bytes at PC: ");
9700 + for (i = 0; i < 8; i++) {
9701 + unsigned int c;
9702 + if (get_user(c, (unsigned int *)pc+i))
9703 + printk(KERN_CONT "???????? ");
9704 + else
9705 + printk(KERN_CONT "%08x ", c);
9706 + }
9707 + printk("\n");
9708 +}
9709 +#endif
9710 +
9711 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9712 int text_fault)
9713 {
9714 @@ -230,6 +504,24 @@ good_area:
9715 if (!(vma->vm_flags & VM_WRITE))
9716 goto bad_area;
9717 } else {
9718 +
9719 +#ifdef CONFIG_PAX_PAGEEXEC
9720 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9721 + up_read(&mm->mmap_sem);
9722 + switch (pax_handle_fetch_fault(regs)) {
9723 +
9724 +#ifdef CONFIG_PAX_EMUPLT
9725 + case 2:
9726 + case 3:
9727 + return;
9728 +#endif
9729 +
9730 + }
9731 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9732 + do_group_exit(SIGKILL);
9733 + }
9734 +#endif
9735 +
9736 /* Allow reads even for write-only mappings */
9737 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9738 goto bad_area;
9739 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9740 index 5062ff3..e0b75f3 100644
9741 --- a/arch/sparc/mm/fault_64.c
9742 +++ b/arch/sparc/mm/fault_64.c
9743 @@ -21,6 +21,9 @@
9744 #include <linux/kprobes.h>
9745 #include <linux/kdebug.h>
9746 #include <linux/percpu.h>
9747 +#include <linux/slab.h>
9748 +#include <linux/pagemap.h>
9749 +#include <linux/compiler.h>
9750
9751 #include <asm/page.h>
9752 #include <asm/pgtable.h>
9753 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9754 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9755 regs->tpc);
9756 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9757 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9758 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9759 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9760 dump_stack();
9761 unhandled_fault(regs->tpc, current, regs);
9762 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9763 show_regs(regs);
9764 }
9765
9766 +#ifdef CONFIG_PAX_PAGEEXEC
9767 +#ifdef CONFIG_PAX_DLRESOLVE
9768 +static void pax_emuplt_close(struct vm_area_struct *vma)
9769 +{
9770 + vma->vm_mm->call_dl_resolve = 0UL;
9771 +}
9772 +
9773 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9774 +{
9775 + unsigned int *kaddr;
9776 +
9777 + vmf->page = alloc_page(GFP_HIGHUSER);
9778 + if (!vmf->page)
9779 + return VM_FAULT_OOM;
9780 +
9781 + kaddr = kmap(vmf->page);
9782 + memset(kaddr, 0, PAGE_SIZE);
9783 + kaddr[0] = 0x9DE3BFA8U; /* save */
9784 + flush_dcache_page(vmf->page);
9785 + kunmap(vmf->page);
9786 + return VM_FAULT_MAJOR;
9787 +}
9788 +
9789 +static const struct vm_operations_struct pax_vm_ops = {
9790 + .close = pax_emuplt_close,
9791 + .fault = pax_emuplt_fault
9792 +};
9793 +
9794 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9795 +{
9796 + int ret;
9797 +
9798 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9799 + vma->vm_mm = current->mm;
9800 + vma->vm_start = addr;
9801 + vma->vm_end = addr + PAGE_SIZE;
9802 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9803 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9804 + vma->vm_ops = &pax_vm_ops;
9805 +
9806 + ret = insert_vm_struct(current->mm, vma);
9807 + if (ret)
9808 + return ret;
9809 +
9810 + ++current->mm->total_vm;
9811 + return 0;
9812 +}
9813 +#endif
9814 +
9815 +/*
9816 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9817 + *
9818 + * returns 1 when task should be killed
9819 + * 2 when patched PLT trampoline was detected
9820 + * 3 when unpatched PLT trampoline was detected
9821 + */
9822 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9823 +{
9824 +
9825 +#ifdef CONFIG_PAX_EMUPLT
9826 + int err;
9827 +
9828 + do { /* PaX: patched PLT emulation #1 */
9829 + unsigned int sethi1, sethi2, jmpl;
9830 +
9831 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9832 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9833 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9834 +
9835 + if (err)
9836 + break;
9837 +
9838 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9839 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9840 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9841 + {
9842 + unsigned long addr;
9843 +
9844 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9845 + addr = regs->u_regs[UREG_G1];
9846 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9847 +
9848 + if (test_thread_flag(TIF_32BIT))
9849 + addr &= 0xFFFFFFFFUL;
9850 +
9851 + regs->tpc = addr;
9852 + regs->tnpc = addr+4;
9853 + return 2;
9854 + }
9855 + } while (0);
9856 +
9857 + do { /* PaX: patched PLT emulation #2 */
9858 + unsigned int ba;
9859 +
9860 + err = get_user(ba, (unsigned int *)regs->tpc);
9861 +
9862 + if (err)
9863 + break;
9864 +
9865 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9866 + unsigned long addr;
9867 +
9868 + if ((ba & 0xFFC00000U) == 0x30800000U)
9869 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9870 + else
9871 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9872 +
9873 + if (test_thread_flag(TIF_32BIT))
9874 + addr &= 0xFFFFFFFFUL;
9875 +
9876 + regs->tpc = addr;
9877 + regs->tnpc = addr+4;
9878 + return 2;
9879 + }
9880 + } while (0);
9881 +
9882 + do { /* PaX: patched PLT emulation #3 */
9883 + unsigned int sethi, bajmpl, nop;
9884 +
9885 + err = get_user(sethi, (unsigned int *)regs->tpc);
9886 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9887 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9888 +
9889 + if (err)
9890 + break;
9891 +
9892 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9893 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9894 + nop == 0x01000000U)
9895 + {
9896 + unsigned long addr;
9897 +
9898 + addr = (sethi & 0x003FFFFFU) << 10;
9899 + regs->u_regs[UREG_G1] = addr;
9900 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9901 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9902 + else
9903 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9904 +
9905 + if (test_thread_flag(TIF_32BIT))
9906 + addr &= 0xFFFFFFFFUL;
9907 +
9908 + regs->tpc = addr;
9909 + regs->tnpc = addr+4;
9910 + return 2;
9911 + }
9912 + } while (0);
9913 +
9914 + do { /* PaX: patched PLT emulation #4 */
9915 + unsigned int sethi, mov1, call, mov2;
9916 +
9917 + err = get_user(sethi, (unsigned int *)regs->tpc);
9918 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9919 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9920 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9921 +
9922 + if (err)
9923 + break;
9924 +
9925 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9926 + mov1 == 0x8210000FU &&
9927 + (call & 0xC0000000U) == 0x40000000U &&
9928 + mov2 == 0x9E100001U)
9929 + {
9930 + unsigned long addr;
9931 +
9932 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
9933 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9934 +
9935 + if (test_thread_flag(TIF_32BIT))
9936 + addr &= 0xFFFFFFFFUL;
9937 +
9938 + regs->tpc = addr;
9939 + regs->tnpc = addr+4;
9940 + return 2;
9941 + }
9942 + } while (0);
9943 +
9944 + do { /* PaX: patched PLT emulation #5 */
9945 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
9946 +
9947 + err = get_user(sethi, (unsigned int *)regs->tpc);
9948 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9949 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9950 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
9951 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
9952 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
9953 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
9954 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
9955 +
9956 + if (err)
9957 + break;
9958 +
9959 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9960 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9961 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9962 + (or1 & 0xFFFFE000U) == 0x82106000U &&
9963 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9964 + sllx == 0x83287020U &&
9965 + jmpl == 0x81C04005U &&
9966 + nop == 0x01000000U)
9967 + {
9968 + unsigned long addr;
9969 +
9970 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9971 + regs->u_regs[UREG_G1] <<= 32;
9972 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9973 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9974 + regs->tpc = addr;
9975 + regs->tnpc = addr+4;
9976 + return 2;
9977 + }
9978 + } while (0);
9979 +
9980 + do { /* PaX: patched PLT emulation #6 */
9981 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
9982 +
9983 + err = get_user(sethi, (unsigned int *)regs->tpc);
9984 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9985 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9986 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
9987 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
9988 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
9989 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
9990 +
9991 + if (err)
9992 + break;
9993 +
9994 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9995 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9996 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9997 + sllx == 0x83287020U &&
9998 + (or & 0xFFFFE000U) == 0x8A116000U &&
9999 + jmpl == 0x81C04005U &&
10000 + nop == 0x01000000U)
10001 + {
10002 + unsigned long addr;
10003 +
10004 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
10005 + regs->u_regs[UREG_G1] <<= 32;
10006 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
10007 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10008 + regs->tpc = addr;
10009 + regs->tnpc = addr+4;
10010 + return 2;
10011 + }
10012 + } while (0);
10013 +
10014 + do { /* PaX: unpatched PLT emulation step 1 */
10015 + unsigned int sethi, ba, nop;
10016 +
10017 + err = get_user(sethi, (unsigned int *)regs->tpc);
10018 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10019 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10020 +
10021 + if (err)
10022 + break;
10023 +
10024 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10025 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10026 + nop == 0x01000000U)
10027 + {
10028 + unsigned long addr;
10029 + unsigned int save, call;
10030 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
10031 +
10032 + if ((ba & 0xFFC00000U) == 0x30800000U)
10033 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10034 + else
10035 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10036 +
10037 + if (test_thread_flag(TIF_32BIT))
10038 + addr &= 0xFFFFFFFFUL;
10039 +
10040 + err = get_user(save, (unsigned int *)addr);
10041 + err |= get_user(call, (unsigned int *)(addr+4));
10042 + err |= get_user(nop, (unsigned int *)(addr+8));
10043 + if (err)
10044 + break;
10045 +
10046 +#ifdef CONFIG_PAX_DLRESOLVE
10047 + if (save == 0x9DE3BFA8U &&
10048 + (call & 0xC0000000U) == 0x40000000U &&
10049 + nop == 0x01000000U)
10050 + {
10051 + struct vm_area_struct *vma;
10052 + unsigned long call_dl_resolve;
10053 +
10054 + down_read(&current->mm->mmap_sem);
10055 + call_dl_resolve = current->mm->call_dl_resolve;
10056 + up_read(&current->mm->mmap_sem);
10057 + if (likely(call_dl_resolve))
10058 + goto emulate;
10059 +
10060 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10061 +
10062 + down_write(&current->mm->mmap_sem);
10063 + if (current->mm->call_dl_resolve) {
10064 + call_dl_resolve = current->mm->call_dl_resolve;
10065 + up_write(&current->mm->mmap_sem);
10066 + if (vma)
10067 + kmem_cache_free(vm_area_cachep, vma);
10068 + goto emulate;
10069 + }
10070 +
10071 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10072 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10073 + up_write(&current->mm->mmap_sem);
10074 + if (vma)
10075 + kmem_cache_free(vm_area_cachep, vma);
10076 + return 1;
10077 + }
10078 +
10079 + if (pax_insert_vma(vma, call_dl_resolve)) {
10080 + up_write(&current->mm->mmap_sem);
10081 + kmem_cache_free(vm_area_cachep, vma);
10082 + return 1;
10083 + }
10084 +
10085 + current->mm->call_dl_resolve = call_dl_resolve;
10086 + up_write(&current->mm->mmap_sem);
10087 +
10088 +emulate:
10089 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10090 + regs->tpc = call_dl_resolve;
10091 + regs->tnpc = addr+4;
10092 + return 3;
10093 + }
10094 +#endif
10095 +
10096 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10097 + if ((save & 0xFFC00000U) == 0x05000000U &&
10098 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10099 + nop == 0x01000000U)
10100 + {
10101 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10102 + regs->u_regs[UREG_G2] = addr + 4;
10103 + addr = (save & 0x003FFFFFU) << 10;
10104 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10105 +
10106 + if (test_thread_flag(TIF_32BIT))
10107 + addr &= 0xFFFFFFFFUL;
10108 +
10109 + regs->tpc = addr;
10110 + regs->tnpc = addr+4;
10111 + return 3;
10112 + }
10113 +
10114 + /* PaX: 64-bit PLT stub */
10115 + err = get_user(sethi1, (unsigned int *)addr);
10116 + err |= get_user(sethi2, (unsigned int *)(addr+4));
10117 + err |= get_user(or1, (unsigned int *)(addr+8));
10118 + err |= get_user(or2, (unsigned int *)(addr+12));
10119 + err |= get_user(sllx, (unsigned int *)(addr+16));
10120 + err |= get_user(add, (unsigned int *)(addr+20));
10121 + err |= get_user(jmpl, (unsigned int *)(addr+24));
10122 + err |= get_user(nop, (unsigned int *)(addr+28));
10123 + if (err)
10124 + break;
10125 +
10126 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
10127 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10128 + (or1 & 0xFFFFE000U) == 0x88112000U &&
10129 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10130 + sllx == 0x89293020U &&
10131 + add == 0x8A010005U &&
10132 + jmpl == 0x89C14000U &&
10133 + nop == 0x01000000U)
10134 + {
10135 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10136 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10137 + regs->u_regs[UREG_G4] <<= 32;
10138 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10139 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
10140 + regs->u_regs[UREG_G4] = addr + 24;
10141 + addr = regs->u_regs[UREG_G5];
10142 + regs->tpc = addr;
10143 + regs->tnpc = addr+4;
10144 + return 3;
10145 + }
10146 + }
10147 + } while (0);
10148 +
10149 +#ifdef CONFIG_PAX_DLRESOLVE
10150 + do { /* PaX: unpatched PLT emulation step 2 */
10151 + unsigned int save, call, nop;
10152 +
10153 + err = get_user(save, (unsigned int *)(regs->tpc-4));
10154 + err |= get_user(call, (unsigned int *)regs->tpc);
10155 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
10156 + if (err)
10157 + break;
10158 +
10159 + if (save == 0x9DE3BFA8U &&
10160 + (call & 0xC0000000U) == 0x40000000U &&
10161 + nop == 0x01000000U)
10162 + {
10163 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10164 +
10165 + if (test_thread_flag(TIF_32BIT))
10166 + dl_resolve &= 0xFFFFFFFFUL;
10167 +
10168 + regs->u_regs[UREG_RETPC] = regs->tpc;
10169 + regs->tpc = dl_resolve;
10170 + regs->tnpc = dl_resolve+4;
10171 + return 3;
10172 + }
10173 + } while (0);
10174 +#endif
10175 +
10176 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
10177 + unsigned int sethi, ba, nop;
10178 +
10179 + err = get_user(sethi, (unsigned int *)regs->tpc);
10180 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10181 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10182 +
10183 + if (err)
10184 + break;
10185 +
10186 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10187 + (ba & 0xFFF00000U) == 0x30600000U &&
10188 + nop == 0x01000000U)
10189 + {
10190 + unsigned long addr;
10191 +
10192 + addr = (sethi & 0x003FFFFFU) << 10;
10193 + regs->u_regs[UREG_G1] = addr;
10194 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10195 +
10196 + if (test_thread_flag(TIF_32BIT))
10197 + addr &= 0xFFFFFFFFUL;
10198 +
10199 + regs->tpc = addr;
10200 + regs->tnpc = addr+4;
10201 + return 2;
10202 + }
10203 + } while (0);
10204 +
10205 +#endif
10206 +
10207 + return 1;
10208 +}
10209 +
10210 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10211 +{
10212 + unsigned long i;
10213 +
10214 + printk(KERN_ERR "PAX: bytes at PC: ");
10215 + for (i = 0; i < 8; i++) {
10216 + unsigned int c;
10217 + if (get_user(c, (unsigned int *)pc+i))
10218 + printk(KERN_CONT "???????? ");
10219 + else
10220 + printk(KERN_CONT "%08x ", c);
10221 + }
10222 + printk("\n");
10223 +}
10224 +#endif
10225 +
10226 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
10227 {
10228 struct mm_struct *mm = current->mm;
10229 @@ -341,6 +804,29 @@ retry:
10230 if (!vma)
10231 goto bad_area;
10232
10233 +#ifdef CONFIG_PAX_PAGEEXEC
10234 + /* PaX: detect ITLB misses on non-exec pages */
10235 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
10236 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
10237 + {
10238 + if (address != regs->tpc)
10239 + goto good_area;
10240 +
10241 + up_read(&mm->mmap_sem);
10242 + switch (pax_handle_fetch_fault(regs)) {
10243 +
10244 +#ifdef CONFIG_PAX_EMUPLT
10245 + case 2:
10246 + case 3:
10247 + return;
10248 +#endif
10249 +
10250 + }
10251 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
10252 + do_group_exit(SIGKILL);
10253 + }
10254 +#endif
10255 +
10256 /* Pure DTLB misses do not tell us whether the fault causing
10257 * load/store/atomic was a write or not, it only says that there
10258 * was no match. So in such a case we (carefully) read the
10259 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
10260 index d2b5944..bd813f2 100644
10261 --- a/arch/sparc/mm/hugetlbpage.c
10262 +++ b/arch/sparc/mm/hugetlbpage.c
10263 @@ -38,7 +38,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10264
10265 info.flags = 0;
10266 info.length = len;
10267 - info.low_limit = TASK_UNMAPPED_BASE;
10268 + info.low_limit = mm->mmap_base;
10269 info.high_limit = min(task_size, VA_EXCLUDE_START);
10270 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
10271 info.align_offset = 0;
10272 @@ -47,6 +47,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10273 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
10274 VM_BUG_ON(addr != -ENOMEM);
10275 info.low_limit = VA_EXCLUDE_END;
10276 +
10277 +#ifdef CONFIG_PAX_RANDMMAP
10278 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10279 + info.low_limit += mm->delta_mmap;
10280 +#endif
10281 +
10282 info.high_limit = task_size;
10283 addr = vm_unmapped_area(&info);
10284 }
10285 @@ -85,6 +91,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10286 VM_BUG_ON(addr != -ENOMEM);
10287 info.flags = 0;
10288 info.low_limit = TASK_UNMAPPED_BASE;
10289 +
10290 +#ifdef CONFIG_PAX_RANDMMAP
10291 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10292 + info.low_limit += mm->delta_mmap;
10293 +#endif
10294 +
10295 info.high_limit = STACK_TOP32;
10296 addr = vm_unmapped_area(&info);
10297 }
10298 @@ -99,6 +111,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10299 struct mm_struct *mm = current->mm;
10300 struct vm_area_struct *vma;
10301 unsigned long task_size = TASK_SIZE;
10302 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
10303
10304 if (test_thread_flag(TIF_32BIT))
10305 task_size = STACK_TOP32;
10306 @@ -114,11 +127,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10307 return addr;
10308 }
10309
10310 +#ifdef CONFIG_PAX_RANDMMAP
10311 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10312 +#endif
10313 +
10314 if (addr) {
10315 addr = ALIGN(addr, HPAGE_SIZE);
10316 vma = find_vma(mm, addr);
10317 - if (task_size - len >= addr &&
10318 - (!vma || addr + len <= vma->vm_start))
10319 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10320 return addr;
10321 }
10322 if (mm->get_unmapped_area == arch_get_unmapped_area)
10323 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
10324 index f4500c6..889656c 100644
10325 --- a/arch/tile/include/asm/atomic_64.h
10326 +++ b/arch/tile/include/asm/atomic_64.h
10327 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
10328
10329 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10330
10331 +#define atomic64_read_unchecked(v) atomic64_read(v)
10332 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
10333 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
10334 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
10335 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
10336 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
10337 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
10338 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
10339 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
10340 +
10341 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
10342 #define smp_mb__before_atomic_dec() smp_mb()
10343 #define smp_mb__after_atomic_dec() smp_mb()
10344 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
10345 index a9a5299..0fce79e 100644
10346 --- a/arch/tile/include/asm/cache.h
10347 +++ b/arch/tile/include/asm/cache.h
10348 @@ -15,11 +15,12 @@
10349 #ifndef _ASM_TILE_CACHE_H
10350 #define _ASM_TILE_CACHE_H
10351
10352 +#include <linux/const.h>
10353 #include <arch/chip.h>
10354
10355 /* bytes per L1 data cache line */
10356 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
10357 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10358 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10359
10360 /* bytes per L2 cache line */
10361 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
10362 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
10363 index 9ab078a..d6635c2 100644
10364 --- a/arch/tile/include/asm/uaccess.h
10365 +++ b/arch/tile/include/asm/uaccess.h
10366 @@ -403,9 +403,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10367 const void __user *from,
10368 unsigned long n)
10369 {
10370 - int sz = __compiletime_object_size(to);
10371 + size_t sz = __compiletime_object_size(to);
10372
10373 - if (likely(sz == -1 || sz >= n))
10374 + if (likely(sz == (size_t)-1 || sz >= n))
10375 n = _copy_from_user(to, from, n);
10376 else
10377 copy_from_user_overflow();
10378 diff --git a/arch/um/Makefile b/arch/um/Makefile
10379 index 133f7de..1d6f2f1 100644
10380 --- a/arch/um/Makefile
10381 +++ b/arch/um/Makefile
10382 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10383 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10384 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10385
10386 +ifdef CONSTIFY_PLUGIN
10387 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10388 +endif
10389 +
10390 #This will adjust *FLAGS accordingly to the platform.
10391 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10392
10393 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10394 index 19e1bdd..3665b77 100644
10395 --- a/arch/um/include/asm/cache.h
10396 +++ b/arch/um/include/asm/cache.h
10397 @@ -1,6 +1,7 @@
10398 #ifndef __UM_CACHE_H
10399 #define __UM_CACHE_H
10400
10401 +#include <linux/const.h>
10402
10403 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10404 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10405 @@ -12,6 +13,6 @@
10406 # define L1_CACHE_SHIFT 5
10407 #endif
10408
10409 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10410 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10411
10412 #endif
10413 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10414 index 2e0a6b1..a64d0f5 100644
10415 --- a/arch/um/include/asm/kmap_types.h
10416 +++ b/arch/um/include/asm/kmap_types.h
10417 @@ -8,6 +8,6 @@
10418
10419 /* No more #include "asm/arch/kmap_types.h" ! */
10420
10421 -#define KM_TYPE_NR 14
10422 +#define KM_TYPE_NR 15
10423
10424 #endif
10425 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10426 index 5ff53d9..5850cdf 100644
10427 --- a/arch/um/include/asm/page.h
10428 +++ b/arch/um/include/asm/page.h
10429 @@ -14,6 +14,9 @@
10430 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10431 #define PAGE_MASK (~(PAGE_SIZE-1))
10432
10433 +#define ktla_ktva(addr) (addr)
10434 +#define ktva_ktla(addr) (addr)
10435 +
10436 #ifndef __ASSEMBLY__
10437
10438 struct page;
10439 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10440 index 0032f92..cd151e0 100644
10441 --- a/arch/um/include/asm/pgtable-3level.h
10442 +++ b/arch/um/include/asm/pgtable-3level.h
10443 @@ -58,6 +58,7 @@
10444 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10445 #define pud_populate(mm, pud, pmd) \
10446 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10447 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10448
10449 #ifdef CONFIG_64BIT
10450 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10451 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10452 index b462b13..e7a19aa 100644
10453 --- a/arch/um/kernel/process.c
10454 +++ b/arch/um/kernel/process.c
10455 @@ -386,22 +386,6 @@ int singlestepping(void * t)
10456 return 2;
10457 }
10458
10459 -/*
10460 - * Only x86 and x86_64 have an arch_align_stack().
10461 - * All other arches have "#define arch_align_stack(x) (x)"
10462 - * in their asm/system.h
10463 - * As this is included in UML from asm-um/system-generic.h,
10464 - * we can use it to behave as the subarch does.
10465 - */
10466 -#ifndef arch_align_stack
10467 -unsigned long arch_align_stack(unsigned long sp)
10468 -{
10469 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10470 - sp -= get_random_int() % 8192;
10471 - return sp & ~0xf;
10472 -}
10473 -#endif
10474 -
10475 unsigned long get_wchan(struct task_struct *p)
10476 {
10477 unsigned long stack_page, sp, ip;
10478 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10479 index ad8f795..2c7eec6 100644
10480 --- a/arch/unicore32/include/asm/cache.h
10481 +++ b/arch/unicore32/include/asm/cache.h
10482 @@ -12,8 +12,10 @@
10483 #ifndef __UNICORE_CACHE_H__
10484 #define __UNICORE_CACHE_H__
10485
10486 -#define L1_CACHE_SHIFT (5)
10487 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10488 +#include <linux/const.h>
10489 +
10490 +#define L1_CACHE_SHIFT 5
10491 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10492
10493 /*
10494 * Memory returned by kmalloc() may be used for DMA, so we must make
10495 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10496 index 0694d09..b58b3aa 100644
10497 --- a/arch/x86/Kconfig
10498 +++ b/arch/x86/Kconfig
10499 @@ -238,7 +238,7 @@ config X86_HT
10500
10501 config X86_32_LAZY_GS
10502 def_bool y
10503 - depends on X86_32 && !CC_STACKPROTECTOR
10504 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10505
10506 config ARCH_HWEIGHT_CFLAGS
10507 string
10508 @@ -1031,6 +1031,7 @@ config MICROCODE_OLD_INTERFACE
10509
10510 config X86_MSR
10511 tristate "/dev/cpu/*/msr - Model-specific register support"
10512 + depends on !GRKERNSEC_KMEM
10513 ---help---
10514 This device gives privileged processes access to the x86
10515 Model-Specific Registers (MSRs). It is a character device with
10516 @@ -1054,7 +1055,7 @@ choice
10517
10518 config NOHIGHMEM
10519 bool "off"
10520 - depends on !X86_NUMAQ
10521 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10522 ---help---
10523 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10524 However, the address space of 32-bit x86 processors is only 4
10525 @@ -1091,7 +1092,7 @@ config NOHIGHMEM
10526
10527 config HIGHMEM4G
10528 bool "4GB"
10529 - depends on !X86_NUMAQ
10530 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10531 ---help---
10532 Select this if you have a 32-bit processor and between 1 and 4
10533 gigabytes of physical RAM.
10534 @@ -1145,7 +1146,7 @@ config PAGE_OFFSET
10535 hex
10536 default 0xB0000000 if VMSPLIT_3G_OPT
10537 default 0x80000000 if VMSPLIT_2G
10538 - default 0x78000000 if VMSPLIT_2G_OPT
10539 + default 0x70000000 if VMSPLIT_2G_OPT
10540 default 0x40000000 if VMSPLIT_1G
10541 default 0xC0000000
10542 depends on X86_32
10543 @@ -1542,6 +1543,7 @@ config SECCOMP
10544
10545 config CC_STACKPROTECTOR
10546 bool "Enable -fstack-protector buffer overflow detection"
10547 + depends on X86_64 || !PAX_MEMORY_UDEREF
10548 ---help---
10549 This option turns on the -fstack-protector GCC feature. This
10550 feature puts, at the beginning of functions, a canary value on
10551 @@ -1599,6 +1601,7 @@ config KEXEC_JUMP
10552 config PHYSICAL_START
10553 hex "Physical address where the kernel is loaded" if (EXPERT || CRASH_DUMP)
10554 default "0x1000000"
10555 + range 0x400000 0x40000000
10556 ---help---
10557 This gives the physical address where the kernel is loaded.
10558
10559 @@ -1662,6 +1665,7 @@ config X86_NEED_RELOCS
10560 config PHYSICAL_ALIGN
10561 hex "Alignment value to which kernel should be aligned" if X86_32
10562 default "0x1000000"
10563 + range 0x400000 0x1000000 if PAX_KERNEXEC
10564 range 0x2000 0x1000000
10565 ---help---
10566 This value puts the alignment restrictions on physical address
10567 @@ -1737,9 +1741,10 @@ config DEBUG_HOTPLUG_CPU0
10568 If unsure, say N.
10569
10570 config COMPAT_VDSO
10571 - def_bool y
10572 + def_bool n
10573 prompt "Compat VDSO support"
10574 depends on X86_32 || IA32_EMULATION
10575 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10576 ---help---
10577 Map the 32-bit VDSO to the predictable old-style address too.
10578
10579 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10580 index c026cca..14657ae 100644
10581 --- a/arch/x86/Kconfig.cpu
10582 +++ b/arch/x86/Kconfig.cpu
10583 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10584
10585 config X86_F00F_BUG
10586 def_bool y
10587 - depends on M586MMX || M586TSC || M586 || M486
10588 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10589
10590 config X86_INVD_BUG
10591 def_bool y
10592 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10593
10594 config X86_ALIGNMENT_16
10595 def_bool y
10596 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10597 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10598
10599 config X86_INTEL_USERCOPY
10600 def_bool y
10601 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10602 # generates cmov.
10603 config X86_CMOV
10604 def_bool y
10605 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10606 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10607
10608 config X86_MINIMUM_CPU_FAMILY
10609 int
10610 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10611 index b322f12..652d0d9 100644
10612 --- a/arch/x86/Kconfig.debug
10613 +++ b/arch/x86/Kconfig.debug
10614 @@ -84,7 +84,7 @@ config X86_PTDUMP
10615 config DEBUG_RODATA
10616 bool "Write protect kernel read-only data structures"
10617 default y
10618 - depends on DEBUG_KERNEL
10619 + depends on DEBUG_KERNEL && BROKEN
10620 ---help---
10621 Mark the kernel read-only data as write-protected in the pagetables,
10622 in order to catch accidental (and incorrect) writes to such const
10623 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10624
10625 config DEBUG_SET_MODULE_RONX
10626 bool "Set loadable kernel module data as NX and text as RO"
10627 - depends on MODULES
10628 + depends on MODULES && BROKEN
10629 ---help---
10630 This option helps catch unintended modifications to loadable
10631 kernel module's text and read-only data. It also prevents execution
10632 @@ -294,7 +294,7 @@ config OPTIMIZE_INLINING
10633
10634 config DEBUG_STRICT_USER_COPY_CHECKS
10635 bool "Strict copy size checks"
10636 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
10637 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
10638 ---help---
10639 Enabling this option turns a certain set of sanity checks for user
10640 copy operations into compile time failures.
10641 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10642 index e71fc42..7829607 100644
10643 --- a/arch/x86/Makefile
10644 +++ b/arch/x86/Makefile
10645 @@ -50,6 +50,7 @@ else
10646 UTS_MACHINE := x86_64
10647 CHECKFLAGS += -D__x86_64__ -m64
10648
10649 + biarch := $(call cc-option,-m64)
10650 KBUILD_AFLAGS += -m64
10651 KBUILD_CFLAGS += -m64
10652
10653 @@ -230,3 +231,12 @@ define archhelp
10654 echo ' FDARGS="..." arguments for the booted kernel'
10655 echo ' FDINITRD=file initrd for the booted kernel'
10656 endef
10657 +
10658 +define OLD_LD
10659 +
10660 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10661 +*** Please upgrade your binutils to 2.18 or newer
10662 +endef
10663 +
10664 +archprepare:
10665 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10666 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10667 index 379814b..add62ce 100644
10668 --- a/arch/x86/boot/Makefile
10669 +++ b/arch/x86/boot/Makefile
10670 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10671 $(call cc-option, -fno-stack-protector) \
10672 $(call cc-option, -mpreferred-stack-boundary=2)
10673 KBUILD_CFLAGS += $(call cc-option, -m32)
10674 +ifdef CONSTIFY_PLUGIN
10675 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10676 +endif
10677 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10678 GCOV_PROFILE := n
10679
10680 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10681 index 878e4b9..20537ab 100644
10682 --- a/arch/x86/boot/bitops.h
10683 +++ b/arch/x86/boot/bitops.h
10684 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10685 u8 v;
10686 const u32 *p = (const u32 *)addr;
10687
10688 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10689 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10690 return v;
10691 }
10692
10693 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10694
10695 static inline void set_bit(int nr, void *addr)
10696 {
10697 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10698 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10699 }
10700
10701 #endif /* BOOT_BITOPS_H */
10702 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10703 index 18997e5..83d9c67 100644
10704 --- a/arch/x86/boot/boot.h
10705 +++ b/arch/x86/boot/boot.h
10706 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10707 static inline u16 ds(void)
10708 {
10709 u16 seg;
10710 - asm("movw %%ds,%0" : "=rm" (seg));
10711 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10712 return seg;
10713 }
10714
10715 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10716 static inline int memcmp(const void *s1, const void *s2, size_t len)
10717 {
10718 u8 diff;
10719 - asm("repe; cmpsb; setnz %0"
10720 + asm volatile("repe; cmpsb; setnz %0"
10721 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10722 return diff;
10723 }
10724 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10725 index 8a84501..b2d165f 100644
10726 --- a/arch/x86/boot/compressed/Makefile
10727 +++ b/arch/x86/boot/compressed/Makefile
10728 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10729 KBUILD_CFLAGS += $(cflags-y)
10730 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10731 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10732 +ifdef CONSTIFY_PLUGIN
10733 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10734 +endif
10735
10736 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10737 GCOV_PROFILE := n
10738 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10739 index c205035..5853587 100644
10740 --- a/arch/x86/boot/compressed/eboot.c
10741 +++ b/arch/x86/boot/compressed/eboot.c
10742 @@ -150,7 +150,6 @@ again:
10743 *addr = max_addr;
10744 }
10745
10746 -free_pool:
10747 efi_call_phys1(sys_table->boottime->free_pool, map);
10748
10749 fail:
10750 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10751 if (i == map_size / desc_size)
10752 status = EFI_NOT_FOUND;
10753
10754 -free_pool:
10755 efi_call_phys1(sys_table->boottime->free_pool, map);
10756 fail:
10757 return status;
10758 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10759 index 1e3184f..0d11e2e 100644
10760 --- a/arch/x86/boot/compressed/head_32.S
10761 +++ b/arch/x86/boot/compressed/head_32.S
10762 @@ -118,7 +118,7 @@ preferred_addr:
10763 notl %eax
10764 andl %eax, %ebx
10765 #else
10766 - movl $LOAD_PHYSICAL_ADDR, %ebx
10767 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10768 #endif
10769
10770 /* Target address to relocate to for decompression */
10771 @@ -204,7 +204,7 @@ relocated:
10772 * and where it was actually loaded.
10773 */
10774 movl %ebp, %ebx
10775 - subl $LOAD_PHYSICAL_ADDR, %ebx
10776 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10777 jz 2f /* Nothing to be done if loaded at compiled addr. */
10778 /*
10779 * Process relocations.
10780 @@ -212,8 +212,7 @@ relocated:
10781
10782 1: subl $4, %edi
10783 movl (%edi), %ecx
10784 - testl %ecx, %ecx
10785 - jz 2f
10786 + jecxz 2f
10787 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10788 jmp 1b
10789 2:
10790 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10791 index f5d1aaa..cce11dc 100644
10792 --- a/arch/x86/boot/compressed/head_64.S
10793 +++ b/arch/x86/boot/compressed/head_64.S
10794 @@ -91,7 +91,7 @@ ENTRY(startup_32)
10795 notl %eax
10796 andl %eax, %ebx
10797 #else
10798 - movl $LOAD_PHYSICAL_ADDR, %ebx
10799 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10800 #endif
10801
10802 /* Target address to relocate to for decompression */
10803 @@ -273,7 +273,7 @@ preferred_addr:
10804 notq %rax
10805 andq %rax, %rbp
10806 #else
10807 - movq $LOAD_PHYSICAL_ADDR, %rbp
10808 + movq $____LOAD_PHYSICAL_ADDR, %rbp
10809 #endif
10810
10811 /* Target address to relocate to for decompression */
10812 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
10813 index 88f7ff6..ed695dd 100644
10814 --- a/arch/x86/boot/compressed/misc.c
10815 +++ b/arch/x86/boot/compressed/misc.c
10816 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
10817 case PT_LOAD:
10818 #ifdef CONFIG_RELOCATABLE
10819 dest = output;
10820 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
10821 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
10822 #else
10823 dest = (void *)(phdr->p_paddr);
10824 #endif
10825 @@ -352,7 +352,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
10826 error("Destination address too large");
10827 #endif
10828 #ifndef CONFIG_RELOCATABLE
10829 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
10830 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
10831 error("Wrong destination address");
10832 #endif
10833
10834 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
10835 index 4d3ff03..e4972ff 100644
10836 --- a/arch/x86/boot/cpucheck.c
10837 +++ b/arch/x86/boot/cpucheck.c
10838 @@ -74,7 +74,7 @@ static int has_fpu(void)
10839 u16 fcw = -1, fsw = -1;
10840 u32 cr0;
10841
10842 - asm("movl %%cr0,%0" : "=r" (cr0));
10843 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
10844 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
10845 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
10846 asm volatile("movl %0,%%cr0" : : "r" (cr0));
10847 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
10848 {
10849 u32 f0, f1;
10850
10851 - asm("pushfl ; "
10852 + asm volatile("pushfl ; "
10853 "pushfl ; "
10854 "popl %0 ; "
10855 "movl %0,%1 ; "
10856 @@ -115,7 +115,7 @@ static void get_flags(void)
10857 set_bit(X86_FEATURE_FPU, cpu.flags);
10858
10859 if (has_eflag(X86_EFLAGS_ID)) {
10860 - asm("cpuid"
10861 + asm volatile("cpuid"
10862 : "=a" (max_intel_level),
10863 "=b" (cpu_vendor[0]),
10864 "=d" (cpu_vendor[1]),
10865 @@ -124,7 +124,7 @@ static void get_flags(void)
10866
10867 if (max_intel_level >= 0x00000001 &&
10868 max_intel_level <= 0x0000ffff) {
10869 - asm("cpuid"
10870 + asm volatile("cpuid"
10871 : "=a" (tfms),
10872 "=c" (cpu.flags[4]),
10873 "=d" (cpu.flags[0])
10874 @@ -136,7 +136,7 @@ static void get_flags(void)
10875 cpu.model += ((tfms >> 16) & 0xf) << 4;
10876 }
10877
10878 - asm("cpuid"
10879 + asm volatile("cpuid"
10880 : "=a" (max_amd_level)
10881 : "a" (0x80000000)
10882 : "ebx", "ecx", "edx");
10883 @@ -144,7 +144,7 @@ static void get_flags(void)
10884 if (max_amd_level >= 0x80000001 &&
10885 max_amd_level <= 0x8000ffff) {
10886 u32 eax = 0x80000001;
10887 - asm("cpuid"
10888 + asm volatile("cpuid"
10889 : "+a" (eax),
10890 "=c" (cpu.flags[6]),
10891 "=d" (cpu.flags[1])
10892 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10893 u32 ecx = MSR_K7_HWCR;
10894 u32 eax, edx;
10895
10896 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10897 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10898 eax &= ~(1 << 15);
10899 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10900 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10901
10902 get_flags(); /* Make sure it really did something */
10903 err = check_flags();
10904 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10905 u32 ecx = MSR_VIA_FCR;
10906 u32 eax, edx;
10907
10908 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10909 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10910 eax |= (1<<1)|(1<<7);
10911 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10912 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10913
10914 set_bit(X86_FEATURE_CX8, cpu.flags);
10915 err = check_flags();
10916 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10917 u32 eax, edx;
10918 u32 level = 1;
10919
10920 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10921 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10922 - asm("cpuid"
10923 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10924 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10925 + asm volatile("cpuid"
10926 : "+a" (level), "=d" (cpu.flags[0])
10927 : : "ecx", "ebx");
10928 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10929 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10930
10931 err = check_flags();
10932 }
10933 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
10934 index 944ce59..87ee37a 100644
10935 --- a/arch/x86/boot/header.S
10936 +++ b/arch/x86/boot/header.S
10937 @@ -401,10 +401,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
10938 # single linked list of
10939 # struct setup_data
10940
10941 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
10942 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
10943
10944 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
10945 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
10946 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
10947 +#else
10948 #define VO_INIT_SIZE (VO__end - VO__text)
10949 +#endif
10950 #if ZO_INIT_SIZE > VO_INIT_SIZE
10951 #define INIT_SIZE ZO_INIT_SIZE
10952 #else
10953 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
10954 index db75d07..8e6d0af 100644
10955 --- a/arch/x86/boot/memory.c
10956 +++ b/arch/x86/boot/memory.c
10957 @@ -19,7 +19,7 @@
10958
10959 static int detect_memory_e820(void)
10960 {
10961 - int count = 0;
10962 + unsigned int count = 0;
10963 struct biosregs ireg, oreg;
10964 struct e820entry *desc = boot_params.e820_map;
10965 static struct e820entry buf; /* static so it is zeroed */
10966 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
10967 index 11e8c6e..fdbb1ed 100644
10968 --- a/arch/x86/boot/video-vesa.c
10969 +++ b/arch/x86/boot/video-vesa.c
10970 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
10971
10972 boot_params.screen_info.vesapm_seg = oreg.es;
10973 boot_params.screen_info.vesapm_off = oreg.di;
10974 + boot_params.screen_info.vesapm_size = oreg.cx;
10975 }
10976
10977 /*
10978 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
10979 index 43eda28..5ab5fdb 100644
10980 --- a/arch/x86/boot/video.c
10981 +++ b/arch/x86/boot/video.c
10982 @@ -96,7 +96,7 @@ static void store_mode_params(void)
10983 static unsigned int get_entry(void)
10984 {
10985 char entry_buf[4];
10986 - int i, len = 0;
10987 + unsigned int i, len = 0;
10988 int key;
10989 unsigned int v;
10990
10991 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
10992 index 5b577d5..3c1fed4 100644
10993 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
10994 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
10995 @@ -8,6 +8,8 @@
10996 * including this sentence is retained in full.
10997 */
10998
10999 +#include <asm/alternative-asm.h>
11000 +
11001 .extern crypto_ft_tab
11002 .extern crypto_it_tab
11003 .extern crypto_fl_tab
11004 @@ -71,6 +73,8 @@ FUNC: movq r1,r2; \
11005 je B192; \
11006 leaq 32(r9),r9;
11007
11008 +#define ret pax_force_retaddr 0, 1; ret
11009 +
11010 #define epilogue(r1,r2,r3,r4,r5,r6,r7,r8,r9) \
11011 movq r1,r2; \
11012 movq r3,r4; \
11013 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
11014 index 3470624..201259d 100644
11015 --- a/arch/x86/crypto/aesni-intel_asm.S
11016 +++ b/arch/x86/crypto/aesni-intel_asm.S
11017 @@ -31,6 +31,7 @@
11018
11019 #include <linux/linkage.h>
11020 #include <asm/inst.h>
11021 +#include <asm/alternative-asm.h>
11022
11023 #ifdef __x86_64__
11024 .data
11025 @@ -1436,7 +1437,9 @@ _return_T_done_decrypt:
11026 pop %r14
11027 pop %r13
11028 pop %r12
11029 + pax_force_retaddr 0, 1
11030 ret
11031 +ENDPROC(aesni_gcm_dec)
11032
11033
11034 /*****************************************************************************
11035 @@ -1699,7 +1702,9 @@ _return_T_done_encrypt:
11036 pop %r14
11037 pop %r13
11038 pop %r12
11039 + pax_force_retaddr 0, 1
11040 ret
11041 +ENDPROC(aesni_gcm_enc)
11042
11043 #endif
11044
11045 @@ -1714,6 +1719,7 @@ _key_expansion_256a:
11046 pxor %xmm1, %xmm0
11047 movaps %xmm0, (TKEYP)
11048 add $0x10, TKEYP
11049 + pax_force_retaddr_bts
11050 ret
11051
11052 .align 4
11053 @@ -1738,6 +1744,7 @@ _key_expansion_192a:
11054 shufps $0b01001110, %xmm2, %xmm1
11055 movaps %xmm1, 0x10(TKEYP)
11056 add $0x20, TKEYP
11057 + pax_force_retaddr_bts
11058 ret
11059
11060 .align 4
11061 @@ -1757,6 +1764,7 @@ _key_expansion_192b:
11062
11063 movaps %xmm0, (TKEYP)
11064 add $0x10, TKEYP
11065 + pax_force_retaddr_bts
11066 ret
11067
11068 .align 4
11069 @@ -1769,6 +1777,7 @@ _key_expansion_256b:
11070 pxor %xmm1, %xmm2
11071 movaps %xmm2, (TKEYP)
11072 add $0x10, TKEYP
11073 + pax_force_retaddr_bts
11074 ret
11075
11076 /*
11077 @@ -1881,7 +1890,9 @@ ENTRY(aesni_set_key)
11078 #ifndef __x86_64__
11079 popl KEYP
11080 #endif
11081 + pax_force_retaddr 0, 1
11082 ret
11083 +ENDPROC(aesni_set_key)
11084
11085 /*
11086 * void aesni_enc(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src)
11087 @@ -1902,7 +1913,9 @@ ENTRY(aesni_enc)
11088 popl KLEN
11089 popl KEYP
11090 #endif
11091 + pax_force_retaddr 0, 1
11092 ret
11093 +ENDPROC(aesni_enc)
11094
11095 /*
11096 * _aesni_enc1: internal ABI
11097 @@ -1959,6 +1972,7 @@ _aesni_enc1:
11098 AESENC KEY STATE
11099 movaps 0x70(TKEYP), KEY
11100 AESENCLAST KEY STATE
11101 + pax_force_retaddr_bts
11102 ret
11103
11104 /*
11105 @@ -2067,6 +2081,7 @@ _aesni_enc4:
11106 AESENCLAST KEY STATE2
11107 AESENCLAST KEY STATE3
11108 AESENCLAST KEY STATE4
11109 + pax_force_retaddr_bts
11110 ret
11111
11112 /*
11113 @@ -2089,7 +2104,9 @@ ENTRY(aesni_dec)
11114 popl KLEN
11115 popl KEYP
11116 #endif
11117 + pax_force_retaddr 0, 1
11118 ret
11119 +ENDPROC(aesni_dec)
11120
11121 /*
11122 * _aesni_dec1: internal ABI
11123 @@ -2146,6 +2163,7 @@ _aesni_dec1:
11124 AESDEC KEY STATE
11125 movaps 0x70(TKEYP), KEY
11126 AESDECLAST KEY STATE
11127 + pax_force_retaddr_bts
11128 ret
11129
11130 /*
11131 @@ -2254,6 +2272,7 @@ _aesni_dec4:
11132 AESDECLAST KEY STATE2
11133 AESDECLAST KEY STATE3
11134 AESDECLAST KEY STATE4
11135 + pax_force_retaddr_bts
11136 ret
11137
11138 /*
11139 @@ -2311,7 +2330,9 @@ ENTRY(aesni_ecb_enc)
11140 popl KEYP
11141 popl LEN
11142 #endif
11143 + pax_force_retaddr 0, 1
11144 ret
11145 +ENDPROC(aesni_ecb_enc)
11146
11147 /*
11148 * void aesni_ecb_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11149 @@ -2369,7 +2390,9 @@ ENTRY(aesni_ecb_dec)
11150 popl KEYP
11151 popl LEN
11152 #endif
11153 + pax_force_retaddr 0, 1
11154 ret
11155 +ENDPROC(aesni_ecb_dec)
11156
11157 /*
11158 * void aesni_cbc_enc(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11159 @@ -2410,7 +2433,9 @@ ENTRY(aesni_cbc_enc)
11160 popl LEN
11161 popl IVP
11162 #endif
11163 + pax_force_retaddr 0, 1
11164 ret
11165 +ENDPROC(aesni_cbc_enc)
11166
11167 /*
11168 * void aesni_cbc_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11169 @@ -2500,7 +2525,9 @@ ENTRY(aesni_cbc_dec)
11170 popl LEN
11171 popl IVP
11172 #endif
11173 + pax_force_retaddr 0, 1
11174 ret
11175 +ENDPROC(aesni_cbc_dec)
11176
11177 #ifdef __x86_64__
11178 .align 16
11179 @@ -2526,6 +2553,7 @@ _aesni_inc_init:
11180 mov $1, TCTR_LOW
11181 MOVQ_R64_XMM TCTR_LOW INC
11182 MOVQ_R64_XMM CTR TCTR_LOW
11183 + pax_force_retaddr_bts
11184 ret
11185
11186 /*
11187 @@ -2554,6 +2582,7 @@ _aesni_inc:
11188 .Linc_low:
11189 movaps CTR, IV
11190 PSHUFB_XMM BSWAP_MASK IV
11191 + pax_force_retaddr_bts
11192 ret
11193
11194 /*
11195 @@ -2614,5 +2643,7 @@ ENTRY(aesni_ctr_enc)
11196 .Lctr_enc_ret:
11197 movups IV, (IVP)
11198 .Lctr_enc_just_ret:
11199 + pax_force_retaddr 0, 1
11200 ret
11201 +ENDPROC(aesni_ctr_enc)
11202 #endif
11203 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
11204 index 391d245..67f35c2 100644
11205 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
11206 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
11207 @@ -20,6 +20,8 @@
11208 *
11209 */
11210
11211 +#include <asm/alternative-asm.h>
11212 +
11213 .file "blowfish-x86_64-asm.S"
11214 .text
11215
11216 @@ -151,9 +153,11 @@ __blowfish_enc_blk:
11217 jnz __enc_xor;
11218
11219 write_block();
11220 + pax_force_retaddr 0, 1
11221 ret;
11222 __enc_xor:
11223 xor_block();
11224 + pax_force_retaddr 0, 1
11225 ret;
11226
11227 .align 8
11228 @@ -188,6 +192,7 @@ blowfish_dec_blk:
11229
11230 movq %r11, %rbp;
11231
11232 + pax_force_retaddr 0, 1
11233 ret;
11234
11235 /**********************************************************************
11236 @@ -342,6 +347,7 @@ __blowfish_enc_blk_4way:
11237
11238 popq %rbx;
11239 popq %rbp;
11240 + pax_force_retaddr 0, 1
11241 ret;
11242
11243 __enc_xor4:
11244 @@ -349,6 +355,7 @@ __enc_xor4:
11245
11246 popq %rbx;
11247 popq %rbp;
11248 + pax_force_retaddr 0, 1
11249 ret;
11250
11251 .align 8
11252 @@ -386,5 +393,6 @@ blowfish_dec_blk_4way:
11253 popq %rbx;
11254 popq %rbp;
11255
11256 + pax_force_retaddr 0, 1
11257 ret;
11258
11259 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
11260 index 0b33743..7a56206 100644
11261 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
11262 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
11263 @@ -20,6 +20,8 @@
11264 *
11265 */
11266
11267 +#include <asm/alternative-asm.h>
11268 +
11269 .file "camellia-x86_64-asm_64.S"
11270 .text
11271
11272 @@ -229,12 +231,14 @@ __enc_done:
11273 enc_outunpack(mov, RT1);
11274
11275 movq RRBP, %rbp;
11276 + pax_force_retaddr 0, 1
11277 ret;
11278
11279 __enc_xor:
11280 enc_outunpack(xor, RT1);
11281
11282 movq RRBP, %rbp;
11283 + pax_force_retaddr 0, 1
11284 ret;
11285
11286 .global camellia_dec_blk;
11287 @@ -275,6 +279,7 @@ __dec_rounds16:
11288 dec_outunpack();
11289
11290 movq RRBP, %rbp;
11291 + pax_force_retaddr 0, 1
11292 ret;
11293
11294 /**********************************************************************
11295 @@ -468,6 +473,7 @@ __enc2_done:
11296
11297 movq RRBP, %rbp;
11298 popq %rbx;
11299 + pax_force_retaddr 0, 1
11300 ret;
11301
11302 __enc2_xor:
11303 @@ -475,6 +481,7 @@ __enc2_xor:
11304
11305 movq RRBP, %rbp;
11306 popq %rbx;
11307 + pax_force_retaddr 0, 1
11308 ret;
11309
11310 .global camellia_dec_blk_2way;
11311 @@ -517,4 +524,5 @@ __dec2_rounds16:
11312
11313 movq RRBP, %rbp;
11314 movq RXOR, %rbx;
11315 + pax_force_retaddr 0, 1
11316 ret;
11317 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11318 index 15b00ac..2071784 100644
11319 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11320 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11321 @@ -23,6 +23,8 @@
11322 *
11323 */
11324
11325 +#include <asm/alternative-asm.h>
11326 +
11327 .file "cast5-avx-x86_64-asm_64.S"
11328
11329 .extern cast_s1
11330 @@ -281,6 +283,7 @@ __skip_enc:
11331 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11332 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11333
11334 + pax_force_retaddr 0, 1
11335 ret;
11336
11337 .align 16
11338 @@ -353,6 +356,7 @@ __dec_tail:
11339 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11340 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11341
11342 + pax_force_retaddr 0, 1
11343 ret;
11344
11345 __skip_dec:
11346 @@ -392,6 +396,7 @@ cast5_ecb_enc_16way:
11347 vmovdqu RR4, (6*4*4)(%r11);
11348 vmovdqu RL4, (7*4*4)(%r11);
11349
11350 + pax_force_retaddr
11351 ret;
11352
11353 .align 16
11354 @@ -427,6 +432,7 @@ cast5_ecb_dec_16way:
11355 vmovdqu RR4, (6*4*4)(%r11);
11356 vmovdqu RL4, (7*4*4)(%r11);
11357
11358 + pax_force_retaddr
11359 ret;
11360
11361 .align 16
11362 @@ -479,6 +485,7 @@ cast5_cbc_dec_16way:
11363
11364 popq %r12;
11365
11366 + pax_force_retaddr
11367 ret;
11368
11369 .align 16
11370 @@ -555,4 +562,5 @@ cast5_ctr_16way:
11371
11372 popq %r12;
11373
11374 + pax_force_retaddr
11375 ret;
11376 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11377 index 2569d0d..637c289 100644
11378 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11379 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11380 @@ -23,6 +23,8 @@
11381 *
11382 */
11383
11384 +#include <asm/alternative-asm.h>
11385 +
11386 #include "glue_helper-asm-avx.S"
11387
11388 .file "cast6-avx-x86_64-asm_64.S"
11389 @@ -294,6 +296,7 @@ __cast6_enc_blk8:
11390 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11391 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11392
11393 + pax_force_retaddr 0, 1
11394 ret;
11395
11396 .align 8
11397 @@ -340,6 +343,7 @@ __cast6_dec_blk8:
11398 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11399 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11400
11401 + pax_force_retaddr 0, 1
11402 ret;
11403
11404 .align 8
11405 @@ -361,6 +365,7 @@ cast6_ecb_enc_8way:
11406
11407 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11408
11409 + pax_force_retaddr
11410 ret;
11411
11412 .align 8
11413 @@ -382,6 +387,7 @@ cast6_ecb_dec_8way:
11414
11415 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11416
11417 + pax_force_retaddr
11418 ret;
11419
11420 .align 8
11421 @@ -408,6 +414,7 @@ cast6_cbc_dec_8way:
11422
11423 popq %r12;
11424
11425 + pax_force_retaddr
11426 ret;
11427
11428 .align 8
11429 @@ -436,4 +443,5 @@ cast6_ctr_8way:
11430
11431 popq %r12;
11432
11433 + pax_force_retaddr
11434 ret;
11435 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11436 index 6214a9b..1f4fc9a 100644
11437 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11438 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11439 @@ -1,3 +1,5 @@
11440 +#include <asm/alternative-asm.h>
11441 +
11442 # enter ECRYPT_encrypt_bytes
11443 .text
11444 .p2align 5
11445 @@ -790,6 +792,7 @@ ECRYPT_encrypt_bytes:
11446 add %r11,%rsp
11447 mov %rdi,%rax
11448 mov %rsi,%rdx
11449 + pax_force_retaddr 0, 1
11450 ret
11451 # bytesatleast65:
11452 ._bytesatleast65:
11453 @@ -891,6 +894,7 @@ ECRYPT_keysetup:
11454 add %r11,%rsp
11455 mov %rdi,%rax
11456 mov %rsi,%rdx
11457 + pax_force_retaddr
11458 ret
11459 # enter ECRYPT_ivsetup
11460 .text
11461 @@ -917,4 +921,5 @@ ECRYPT_ivsetup:
11462 add %r11,%rsp
11463 mov %rdi,%rax
11464 mov %rsi,%rdx
11465 + pax_force_retaddr
11466 ret
11467 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11468 index 02b0e9f..cf4cf5c 100644
11469 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11470 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11471 @@ -24,6 +24,8 @@
11472 *
11473 */
11474
11475 +#include <asm/alternative-asm.h>
11476 +
11477 #include "glue_helper-asm-avx.S"
11478
11479 .file "serpent-avx-x86_64-asm_64.S"
11480 @@ -618,6 +620,7 @@ __serpent_enc_blk8_avx:
11481 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11482 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11483
11484 + pax_force_retaddr
11485 ret;
11486
11487 .align 8
11488 @@ -673,6 +676,7 @@ __serpent_dec_blk8_avx:
11489 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11490 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11491
11492 + pax_force_retaddr
11493 ret;
11494
11495 .align 8
11496 @@ -692,6 +696,7 @@ serpent_ecb_enc_8way_avx:
11497
11498 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11499
11500 + pax_force_retaddr
11501 ret;
11502
11503 .align 8
11504 @@ -711,6 +716,7 @@ serpent_ecb_dec_8way_avx:
11505
11506 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11507
11508 + pax_force_retaddr
11509 ret;
11510
11511 .align 8
11512 @@ -730,6 +736,7 @@ serpent_cbc_dec_8way_avx:
11513
11514 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11515
11516 + pax_force_retaddr
11517 ret;
11518
11519 .align 8
11520 @@ -751,4 +758,5 @@ serpent_ctr_8way_avx:
11521
11522 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11523
11524 + pax_force_retaddr
11525 ret;
11526 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11527 index 3ee1ff0..cbc568b 100644
11528 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11529 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11530 @@ -24,6 +24,8 @@
11531 *
11532 */
11533
11534 +#include <asm/alternative-asm.h>
11535 +
11536 .file "serpent-sse2-x86_64-asm_64.S"
11537 .text
11538
11539 @@ -692,12 +694,14 @@ __serpent_enc_blk_8way:
11540 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11541 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11542
11543 + pax_force_retaddr
11544 ret;
11545
11546 __enc_xor8:
11547 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11548 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11549
11550 + pax_force_retaddr
11551 ret;
11552
11553 .align 8
11554 @@ -755,4 +759,5 @@ serpent_dec_blk_8way:
11555 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11556 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11557
11558 + pax_force_retaddr
11559 ret;
11560 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
11561 index 49d6987..df66bd4 100644
11562 --- a/arch/x86/crypto/sha1_ssse3_asm.S
11563 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
11564 @@ -28,6 +28,8 @@
11565 * (at your option) any later version.
11566 */
11567
11568 +#include <asm/alternative-asm.h>
11569 +
11570 #define CTX %rdi // arg1
11571 #define BUF %rsi // arg2
11572 #define CNT %rdx // arg3
11573 @@ -104,6 +106,7 @@
11574 pop %r12
11575 pop %rbp
11576 pop %rbx
11577 + pax_force_retaddr 0, 1
11578 ret
11579
11580 .size \name, .-\name
11581 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11582 index ebac16b..8092eb9 100644
11583 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11584 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11585 @@ -23,6 +23,8 @@
11586 *
11587 */
11588
11589 +#include <asm/alternative-asm.h>
11590 +
11591 #include "glue_helper-asm-avx.S"
11592
11593 .file "twofish-avx-x86_64-asm_64.S"
11594 @@ -283,6 +285,7 @@ __twofish_enc_blk8:
11595 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
11596 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
11597
11598 + pax_force_retaddr 0, 1
11599 ret;
11600
11601 .align 8
11602 @@ -324,6 +327,7 @@ __twofish_dec_blk8:
11603 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
11604 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
11605
11606 + pax_force_retaddr 0, 1
11607 ret;
11608
11609 .align 8
11610 @@ -345,6 +349,7 @@ twofish_ecb_enc_8way:
11611
11612 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11613
11614 + pax_force_retaddr 0, 1
11615 ret;
11616
11617 .align 8
11618 @@ -366,6 +371,7 @@ twofish_ecb_dec_8way:
11619
11620 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11621
11622 + pax_force_retaddr 0, 1
11623 ret;
11624
11625 .align 8
11626 @@ -392,6 +398,7 @@ twofish_cbc_dec_8way:
11627
11628 popq %r12;
11629
11630 + pax_force_retaddr 0, 1
11631 ret;
11632
11633 .align 8
11634 @@ -420,4 +427,5 @@ twofish_ctr_8way:
11635
11636 popq %r12;
11637
11638 + pax_force_retaddr 0, 1
11639 ret;
11640 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11641 index 5b012a2..36d5364 100644
11642 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11643 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11644 @@ -20,6 +20,8 @@
11645 *
11646 */
11647
11648 +#include <asm/alternative-asm.h>
11649 +
11650 .file "twofish-x86_64-asm-3way.S"
11651 .text
11652
11653 @@ -260,6 +262,7 @@ __twofish_enc_blk_3way:
11654 popq %r13;
11655 popq %r14;
11656 popq %r15;
11657 + pax_force_retaddr 0, 1
11658 ret;
11659
11660 __enc_xor3:
11661 @@ -271,6 +274,7 @@ __enc_xor3:
11662 popq %r13;
11663 popq %r14;
11664 popq %r15;
11665 + pax_force_retaddr 0, 1
11666 ret;
11667
11668 .global twofish_dec_blk_3way
11669 @@ -312,5 +316,6 @@ twofish_dec_blk_3way:
11670 popq %r13;
11671 popq %r14;
11672 popq %r15;
11673 + pax_force_retaddr 0, 1
11674 ret;
11675
11676 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
11677 index 7bcf3fc..f53832f 100644
11678 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
11679 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
11680 @@ -21,6 +21,7 @@
11681 .text
11682
11683 #include <asm/asm-offsets.h>
11684 +#include <asm/alternative-asm.h>
11685
11686 #define a_offset 0
11687 #define b_offset 4
11688 @@ -268,6 +269,7 @@ twofish_enc_blk:
11689
11690 popq R1
11691 movq $1,%rax
11692 + pax_force_retaddr 0, 1
11693 ret
11694
11695 twofish_dec_blk:
11696 @@ -319,4 +321,5 @@ twofish_dec_blk:
11697
11698 popq R1
11699 movq $1,%rax
11700 + pax_force_retaddr 0, 1
11701 ret
11702 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
11703 index a703af1..f5b9c36 100644
11704 --- a/arch/x86/ia32/ia32_aout.c
11705 +++ b/arch/x86/ia32/ia32_aout.c
11706 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
11707 unsigned long dump_start, dump_size;
11708 struct user32 dump;
11709
11710 + memset(&dump, 0, sizeof(dump));
11711 +
11712 fs = get_fs();
11713 set_fs(KERNEL_DS);
11714 has_dumped = 1;
11715 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
11716 index a1daf4a..f8c4537 100644
11717 --- a/arch/x86/ia32/ia32_signal.c
11718 +++ b/arch/x86/ia32/ia32_signal.c
11719 @@ -348,7 +348,7 @@ static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
11720 sp -= frame_size;
11721 /* Align the stack pointer according to the i386 ABI,
11722 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
11723 - sp = ((sp + 4) & -16ul) - 4;
11724 + sp = ((sp - 12) & -16ul) - 4;
11725 return (void __user *) sp;
11726 }
11727
11728 @@ -406,7 +406,7 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
11729 * These are actually not used anymore, but left because some
11730 * gdb versions depend on them as a marker.
11731 */
11732 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11733 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11734 } put_user_catch(err);
11735
11736 if (err)
11737 @@ -448,7 +448,7 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
11738 0xb8,
11739 __NR_ia32_rt_sigreturn,
11740 0x80cd,
11741 - 0,
11742 + 0
11743 };
11744
11745 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
11746 @@ -471,16 +471,18 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
11747
11748 if (ka->sa.sa_flags & SA_RESTORER)
11749 restorer = ka->sa.sa_restorer;
11750 + else if (current->mm->context.vdso)
11751 + /* Return stub is in 32bit vsyscall page */
11752 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
11753 else
11754 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
11755 - rt_sigreturn);
11756 + restorer = &frame->retcode;
11757 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
11758
11759 /*
11760 * Not actually used anymore, but left because some gdb
11761 * versions need it.
11762 */
11763 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11764 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11765 } put_user_catch(err);
11766
11767 err |= copy_siginfo_to_user32(&frame->info, info);
11768 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
11769 index 142c4ce..19b683f 100644
11770 --- a/arch/x86/ia32/ia32entry.S
11771 +++ b/arch/x86/ia32/ia32entry.S
11772 @@ -15,8 +15,10 @@
11773 #include <asm/irqflags.h>
11774 #include <asm/asm.h>
11775 #include <asm/smap.h>
11776 +#include <asm/pgtable.h>
11777 #include <linux/linkage.h>
11778 #include <linux/err.h>
11779 +#include <asm/alternative-asm.h>
11780
11781 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
11782 #include <linux/elf-em.h>
11783 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
11784 ENDPROC(native_irq_enable_sysexit)
11785 #endif
11786
11787 + .macro pax_enter_kernel_user
11788 + pax_set_fptr_mask
11789 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11790 + call pax_enter_kernel_user
11791 +#endif
11792 + .endm
11793 +
11794 + .macro pax_exit_kernel_user
11795 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11796 + call pax_exit_kernel_user
11797 +#endif
11798 +#ifdef CONFIG_PAX_RANDKSTACK
11799 + pushq %rax
11800 + pushq %r11
11801 + call pax_randomize_kstack
11802 + popq %r11
11803 + popq %rax
11804 +#endif
11805 + .endm
11806 +
11807 +.macro pax_erase_kstack
11808 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
11809 + call pax_erase_kstack
11810 +#endif
11811 +.endm
11812 +
11813 /*
11814 * 32bit SYSENTER instruction entry.
11815 *
11816 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
11817 CFI_REGISTER rsp,rbp
11818 SWAPGS_UNSAFE_STACK
11819 movq PER_CPU_VAR(kernel_stack), %rsp
11820 - addq $(KERNEL_STACK_OFFSET),%rsp
11821 - /*
11822 - * No need to follow this irqs on/off section: the syscall
11823 - * disabled irqs, here we enable it straight after entry:
11824 - */
11825 - ENABLE_INTERRUPTS(CLBR_NONE)
11826 movl %ebp,%ebp /* zero extension */
11827 pushq_cfi $__USER32_DS
11828 /*CFI_REL_OFFSET ss,0*/
11829 @@ -135,24 +157,44 @@ ENTRY(ia32_sysenter_target)
11830 CFI_REL_OFFSET rsp,0
11831 pushfq_cfi
11832 /*CFI_REL_OFFSET rflags,0*/
11833 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
11834 - CFI_REGISTER rip,r10
11835 + orl $X86_EFLAGS_IF,(%rsp)
11836 + GET_THREAD_INFO(%r11)
11837 + movl TI_sysenter_return(%r11), %r11d
11838 + CFI_REGISTER rip,r11
11839 pushq_cfi $__USER32_CS
11840 /*CFI_REL_OFFSET cs,0*/
11841 movl %eax, %eax
11842 - pushq_cfi %r10
11843 + pushq_cfi %r11
11844 CFI_REL_OFFSET rip,0
11845 pushq_cfi %rax
11846 cld
11847 SAVE_ARGS 0,1,0
11848 + pax_enter_kernel_user
11849 +
11850 +#ifdef CONFIG_PAX_RANDKSTACK
11851 + pax_erase_kstack
11852 +#endif
11853 +
11854 + /*
11855 + * No need to follow this irqs on/off section: the syscall
11856 + * disabled irqs, here we enable it straight after entry:
11857 + */
11858 + ENABLE_INTERRUPTS(CLBR_NONE)
11859 /* no need to do an access_ok check here because rbp has been
11860 32bit zero extended */
11861 +
11862 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11863 + mov $PAX_USER_SHADOW_BASE,%r11
11864 + add %r11,%rbp
11865 +#endif
11866 +
11867 ASM_STAC
11868 1: movl (%rbp),%ebp
11869 _ASM_EXTABLE(1b,ia32_badarg)
11870 ASM_CLAC
11871 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11872 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11873 + GET_THREAD_INFO(%r11)
11874 + orl $TS_COMPAT,TI_status(%r11)
11875 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11876 CFI_REMEMBER_STATE
11877 jnz sysenter_tracesys
11878 cmpq $(IA32_NR_syscalls-1),%rax
11879 @@ -162,12 +204,15 @@ sysenter_do_call:
11880 sysenter_dispatch:
11881 call *ia32_sys_call_table(,%rax,8)
11882 movq %rax,RAX-ARGOFFSET(%rsp)
11883 + GET_THREAD_INFO(%r11)
11884 DISABLE_INTERRUPTS(CLBR_NONE)
11885 TRACE_IRQS_OFF
11886 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11887 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11888 jnz sysexit_audit
11889 sysexit_from_sys_call:
11890 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11891 + pax_exit_kernel_user
11892 + pax_erase_kstack
11893 + andl $~TS_COMPAT,TI_status(%r11)
11894 /* clear IF, that popfq doesn't enable interrupts early */
11895 andl $~0x200,EFLAGS-R11(%rsp)
11896 movl RIP-R11(%rsp),%edx /* User %eip */
11897 @@ -193,6 +238,9 @@ sysexit_from_sys_call:
11898 movl %eax,%esi /* 2nd arg: syscall number */
11899 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
11900 call __audit_syscall_entry
11901 +
11902 + pax_erase_kstack
11903 +
11904 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
11905 cmpq $(IA32_NR_syscalls-1),%rax
11906 ja ia32_badsys
11907 @@ -204,7 +252,7 @@ sysexit_from_sys_call:
11908 .endm
11909
11910 .macro auditsys_exit exit
11911 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11912 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11913 jnz ia32_ret_from_sys_call
11914 TRACE_IRQS_ON
11915 ENABLE_INTERRUPTS(CLBR_NONE)
11916 @@ -215,11 +263,12 @@ sysexit_from_sys_call:
11917 1: setbe %al /* 1 if error, 0 if not */
11918 movzbl %al,%edi /* zero-extend that into %edi */
11919 call __audit_syscall_exit
11920 + GET_THREAD_INFO(%r11)
11921 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
11922 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
11923 DISABLE_INTERRUPTS(CLBR_NONE)
11924 TRACE_IRQS_OFF
11925 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11926 + testl %edi,TI_flags(%r11)
11927 jz \exit
11928 CLEAR_RREGS -ARGOFFSET
11929 jmp int_with_check
11930 @@ -237,7 +286,7 @@ sysexit_audit:
11931
11932 sysenter_tracesys:
11933 #ifdef CONFIG_AUDITSYSCALL
11934 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11935 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11936 jz sysenter_auditsys
11937 #endif
11938 SAVE_REST
11939 @@ -249,6 +298,9 @@ sysenter_tracesys:
11940 RESTORE_REST
11941 cmpq $(IA32_NR_syscalls-1),%rax
11942 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
11943 +
11944 + pax_erase_kstack
11945 +
11946 jmp sysenter_do_call
11947 CFI_ENDPROC
11948 ENDPROC(ia32_sysenter_target)
11949 @@ -276,19 +328,25 @@ ENDPROC(ia32_sysenter_target)
11950 ENTRY(ia32_cstar_target)
11951 CFI_STARTPROC32 simple
11952 CFI_SIGNAL_FRAME
11953 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
11954 + CFI_DEF_CFA rsp,0
11955 CFI_REGISTER rip,rcx
11956 /*CFI_REGISTER rflags,r11*/
11957 SWAPGS_UNSAFE_STACK
11958 movl %esp,%r8d
11959 CFI_REGISTER rsp,r8
11960 movq PER_CPU_VAR(kernel_stack),%rsp
11961 + SAVE_ARGS 8*6,0,0
11962 + pax_enter_kernel_user
11963 +
11964 +#ifdef CONFIG_PAX_RANDKSTACK
11965 + pax_erase_kstack
11966 +#endif
11967 +
11968 /*
11969 * No need to follow this irqs on/off section: the syscall
11970 * disabled irqs and here we enable it straight after entry:
11971 */
11972 ENABLE_INTERRUPTS(CLBR_NONE)
11973 - SAVE_ARGS 8,0,0
11974 movl %eax,%eax /* zero extension */
11975 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
11976 movq %rcx,RIP-ARGOFFSET(%rsp)
11977 @@ -304,12 +362,19 @@ ENTRY(ia32_cstar_target)
11978 /* no need to do an access_ok check here because r8 has been
11979 32bit zero extended */
11980 /* hardware stack frame is complete now */
11981 +
11982 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11983 + mov $PAX_USER_SHADOW_BASE,%r11
11984 + add %r11,%r8
11985 +#endif
11986 +
11987 ASM_STAC
11988 1: movl (%r8),%r9d
11989 _ASM_EXTABLE(1b,ia32_badarg)
11990 ASM_CLAC
11991 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11992 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11993 + GET_THREAD_INFO(%r11)
11994 + orl $TS_COMPAT,TI_status(%r11)
11995 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11996 CFI_REMEMBER_STATE
11997 jnz cstar_tracesys
11998 cmpq $IA32_NR_syscalls-1,%rax
11999 @@ -319,12 +384,15 @@ cstar_do_call:
12000 cstar_dispatch:
12001 call *ia32_sys_call_table(,%rax,8)
12002 movq %rax,RAX-ARGOFFSET(%rsp)
12003 + GET_THREAD_INFO(%r11)
12004 DISABLE_INTERRUPTS(CLBR_NONE)
12005 TRACE_IRQS_OFF
12006 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12007 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
12008 jnz sysretl_audit
12009 sysretl_from_sys_call:
12010 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12011 + pax_exit_kernel_user
12012 + pax_erase_kstack
12013 + andl $~TS_COMPAT,TI_status(%r11)
12014 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
12015 movl RIP-ARGOFFSET(%rsp),%ecx
12016 CFI_REGISTER rip,rcx
12017 @@ -352,7 +420,7 @@ sysretl_audit:
12018
12019 cstar_tracesys:
12020 #ifdef CONFIG_AUDITSYSCALL
12021 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12022 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
12023 jz cstar_auditsys
12024 #endif
12025 xchgl %r9d,%ebp
12026 @@ -366,6 +434,9 @@ cstar_tracesys:
12027 xchgl %ebp,%r9d
12028 cmpq $(IA32_NR_syscalls-1),%rax
12029 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
12030 +
12031 + pax_erase_kstack
12032 +
12033 jmp cstar_do_call
12034 END(ia32_cstar_target)
12035
12036 @@ -407,19 +478,26 @@ ENTRY(ia32_syscall)
12037 CFI_REL_OFFSET rip,RIP-RIP
12038 PARAVIRT_ADJUST_EXCEPTION_FRAME
12039 SWAPGS
12040 - /*
12041 - * No need to follow this irqs on/off section: the syscall
12042 - * disabled irqs and here we enable it straight after entry:
12043 - */
12044 - ENABLE_INTERRUPTS(CLBR_NONE)
12045 movl %eax,%eax
12046 pushq_cfi %rax
12047 cld
12048 /* note the registers are not zero extended to the sf.
12049 this could be a problem. */
12050 SAVE_ARGS 0,1,0
12051 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12052 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12053 + pax_enter_kernel_user
12054 +
12055 +#ifdef CONFIG_PAX_RANDKSTACK
12056 + pax_erase_kstack
12057 +#endif
12058 +
12059 + /*
12060 + * No need to follow this irqs on/off section: the syscall
12061 + * disabled irqs and here we enable it straight after entry:
12062 + */
12063 + ENABLE_INTERRUPTS(CLBR_NONE)
12064 + GET_THREAD_INFO(%r11)
12065 + orl $TS_COMPAT,TI_status(%r11)
12066 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
12067 jnz ia32_tracesys
12068 cmpq $(IA32_NR_syscalls-1),%rax
12069 ja ia32_badsys
12070 @@ -442,6 +520,9 @@ ia32_tracesys:
12071 RESTORE_REST
12072 cmpq $(IA32_NR_syscalls-1),%rax
12073 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
12074 +
12075 + pax_erase_kstack
12076 +
12077 jmp ia32_do_call
12078 END(ia32_syscall)
12079
12080 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
12081 index d0b689b..6811ddc 100644
12082 --- a/arch/x86/ia32/sys_ia32.c
12083 +++ b/arch/x86/ia32/sys_ia32.c
12084 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
12085 */
12086 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
12087 {
12088 - typeof(ubuf->st_uid) uid = 0;
12089 - typeof(ubuf->st_gid) gid = 0;
12090 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
12091 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
12092 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
12093 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
12094 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
12095 @@ -303,7 +303,7 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
12096 mm_segment_t old_fs = get_fs();
12097
12098 set_fs(KERNEL_DS);
12099 - ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
12100 + ret = sys_sched_rr_get_interval(pid, (struct timespec __force_user *)&t);
12101 set_fs(old_fs);
12102 if (put_compat_timespec(&t, interval))
12103 return -EFAULT;
12104 @@ -313,13 +313,13 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
12105 asmlinkage long sys32_rt_sigpending(compat_sigset_t __user *set,
12106 compat_size_t sigsetsize)
12107 {
12108 - sigset_t s;
12109 + sigset_t s = { };
12110 compat_sigset_t s32;
12111 int ret;
12112 mm_segment_t old_fs = get_fs();
12113
12114 set_fs(KERNEL_DS);
12115 - ret = sys_rt_sigpending((sigset_t __user *)&s, sigsetsize);
12116 + ret = sys_rt_sigpending((sigset_t __force_user *)&s, sigsetsize);
12117 set_fs(old_fs);
12118 if (!ret) {
12119 switch (_NSIG_WORDS) {
12120 @@ -344,7 +344,7 @@ asmlinkage long sys32_rt_sigqueueinfo(int pid, int sig,
12121 if (copy_siginfo_from_user32(&info, uinfo))
12122 return -EFAULT;
12123 set_fs(KERNEL_DS);
12124 - ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *)&info);
12125 + ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __force_user *)&info);
12126 set_fs(old_fs);
12127 return ret;
12128 }
12129 @@ -376,7 +376,7 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
12130 return -EFAULT;
12131
12132 set_fs(KERNEL_DS);
12133 - ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL,
12134 + ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __force_user *)&of : NULL,
12135 count);
12136 set_fs(old_fs);
12137
12138 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
12139 index 372231c..a5aa1a1 100644
12140 --- a/arch/x86/include/asm/alternative-asm.h
12141 +++ b/arch/x86/include/asm/alternative-asm.h
12142 @@ -18,6 +18,45 @@
12143 .endm
12144 #endif
12145
12146 +#ifdef KERNEXEC_PLUGIN
12147 + .macro pax_force_retaddr_bts rip=0
12148 + btsq $63,\rip(%rsp)
12149 + .endm
12150 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
12151 + .macro pax_force_retaddr rip=0, reload=0
12152 + btsq $63,\rip(%rsp)
12153 + .endm
12154 + .macro pax_force_fptr ptr
12155 + btsq $63,\ptr
12156 + .endm
12157 + .macro pax_set_fptr_mask
12158 + .endm
12159 +#endif
12160 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
12161 + .macro pax_force_retaddr rip=0, reload=0
12162 + .if \reload
12163 + pax_set_fptr_mask
12164 + .endif
12165 + orq %r10,\rip(%rsp)
12166 + .endm
12167 + .macro pax_force_fptr ptr
12168 + orq %r10,\ptr
12169 + .endm
12170 + .macro pax_set_fptr_mask
12171 + movabs $0x8000000000000000,%r10
12172 + .endm
12173 +#endif
12174 +#else
12175 + .macro pax_force_retaddr rip=0, reload=0
12176 + .endm
12177 + .macro pax_force_fptr ptr
12178 + .endm
12179 + .macro pax_force_retaddr_bts rip=0
12180 + .endm
12181 + .macro pax_set_fptr_mask
12182 + .endm
12183 +#endif
12184 +
12185 .macro altinstruction_entry orig alt feature orig_len alt_len
12186 .long \orig - .
12187 .long \alt - .
12188 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
12189 index 58ed6d9..f1cbe58 100644
12190 --- a/arch/x86/include/asm/alternative.h
12191 +++ b/arch/x86/include/asm/alternative.h
12192 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
12193 ".pushsection .discard,\"aw\",@progbits\n" \
12194 DISCARD_ENTRY(1) \
12195 ".popsection\n" \
12196 - ".pushsection .altinstr_replacement, \"ax\"\n" \
12197 + ".pushsection .altinstr_replacement, \"a\"\n" \
12198 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
12199 ".popsection"
12200
12201 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
12202 DISCARD_ENTRY(1) \
12203 DISCARD_ENTRY(2) \
12204 ".popsection\n" \
12205 - ".pushsection .altinstr_replacement, \"ax\"\n" \
12206 + ".pushsection .altinstr_replacement, \"a\"\n" \
12207 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
12208 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
12209 ".popsection"
12210 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
12211 index 3388034..050f0b9 100644
12212 --- a/arch/x86/include/asm/apic.h
12213 +++ b/arch/x86/include/asm/apic.h
12214 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
12215
12216 #ifdef CONFIG_X86_LOCAL_APIC
12217
12218 -extern unsigned int apic_verbosity;
12219 +extern int apic_verbosity;
12220 extern int local_apic_timer_c2_ok;
12221
12222 extern int disable_apic;
12223 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
12224 index 20370c6..a2eb9b0 100644
12225 --- a/arch/x86/include/asm/apm.h
12226 +++ b/arch/x86/include/asm/apm.h
12227 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
12228 __asm__ __volatile__(APM_DO_ZERO_SEGS
12229 "pushl %%edi\n\t"
12230 "pushl %%ebp\n\t"
12231 - "lcall *%%cs:apm_bios_entry\n\t"
12232 + "lcall *%%ss:apm_bios_entry\n\t"
12233 "setc %%al\n\t"
12234 "popl %%ebp\n\t"
12235 "popl %%edi\n\t"
12236 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
12237 __asm__ __volatile__(APM_DO_ZERO_SEGS
12238 "pushl %%edi\n\t"
12239 "pushl %%ebp\n\t"
12240 - "lcall *%%cs:apm_bios_entry\n\t"
12241 + "lcall *%%ss:apm_bios_entry\n\t"
12242 "setc %%bl\n\t"
12243 "popl %%ebp\n\t"
12244 "popl %%edi\n\t"
12245 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
12246 index 722aa3b..3a0bb27 100644
12247 --- a/arch/x86/include/asm/atomic.h
12248 +++ b/arch/x86/include/asm/atomic.h
12249 @@ -22,7 +22,18 @@
12250 */
12251 static inline int atomic_read(const atomic_t *v)
12252 {
12253 - return (*(volatile int *)&(v)->counter);
12254 + return (*(volatile const int *)&(v)->counter);
12255 +}
12256 +
12257 +/**
12258 + * atomic_read_unchecked - read atomic variable
12259 + * @v: pointer of type atomic_unchecked_t
12260 + *
12261 + * Atomically reads the value of @v.
12262 + */
12263 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
12264 +{
12265 + return (*(volatile const int *)&(v)->counter);
12266 }
12267
12268 /**
12269 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
12270 }
12271
12272 /**
12273 + * atomic_set_unchecked - set atomic variable
12274 + * @v: pointer of type atomic_unchecked_t
12275 + * @i: required value
12276 + *
12277 + * Atomically sets the value of @v to @i.
12278 + */
12279 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
12280 +{
12281 + v->counter = i;
12282 +}
12283 +
12284 +/**
12285 * atomic_add - add integer to atomic variable
12286 * @i: integer value to add
12287 * @v: pointer of type atomic_t
12288 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
12289 */
12290 static inline void atomic_add(int i, atomic_t *v)
12291 {
12292 - asm volatile(LOCK_PREFIX "addl %1,%0"
12293 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12294 +
12295 +#ifdef CONFIG_PAX_REFCOUNT
12296 + "jno 0f\n"
12297 + LOCK_PREFIX "subl %1,%0\n"
12298 + "int $4\n0:\n"
12299 + _ASM_EXTABLE(0b, 0b)
12300 +#endif
12301 +
12302 + : "+m" (v->counter)
12303 + : "ir" (i));
12304 +}
12305 +
12306 +/**
12307 + * atomic_add_unchecked - add integer to atomic variable
12308 + * @i: integer value to add
12309 + * @v: pointer of type atomic_unchecked_t
12310 + *
12311 + * Atomically adds @i to @v.
12312 + */
12313 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
12314 +{
12315 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12316 : "+m" (v->counter)
12317 : "ir" (i));
12318 }
12319 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
12320 */
12321 static inline void atomic_sub(int i, atomic_t *v)
12322 {
12323 - asm volatile(LOCK_PREFIX "subl %1,%0"
12324 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12325 +
12326 +#ifdef CONFIG_PAX_REFCOUNT
12327 + "jno 0f\n"
12328 + LOCK_PREFIX "addl %1,%0\n"
12329 + "int $4\n0:\n"
12330 + _ASM_EXTABLE(0b, 0b)
12331 +#endif
12332 +
12333 + : "+m" (v->counter)
12334 + : "ir" (i));
12335 +}
12336 +
12337 +/**
12338 + * atomic_sub_unchecked - subtract integer from atomic variable
12339 + * @i: integer value to subtract
12340 + * @v: pointer of type atomic_unchecked_t
12341 + *
12342 + * Atomically subtracts @i from @v.
12343 + */
12344 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
12345 +{
12346 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12347 : "+m" (v->counter)
12348 : "ir" (i));
12349 }
12350 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12351 {
12352 unsigned char c;
12353
12354 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
12355 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
12356 +
12357 +#ifdef CONFIG_PAX_REFCOUNT
12358 + "jno 0f\n"
12359 + LOCK_PREFIX "addl %2,%0\n"
12360 + "int $4\n0:\n"
12361 + _ASM_EXTABLE(0b, 0b)
12362 +#endif
12363 +
12364 + "sete %1\n"
12365 : "+m" (v->counter), "=qm" (c)
12366 : "ir" (i) : "memory");
12367 return c;
12368 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12369 */
12370 static inline void atomic_inc(atomic_t *v)
12371 {
12372 - asm volatile(LOCK_PREFIX "incl %0"
12373 + asm volatile(LOCK_PREFIX "incl %0\n"
12374 +
12375 +#ifdef CONFIG_PAX_REFCOUNT
12376 + "jno 0f\n"
12377 + LOCK_PREFIX "decl %0\n"
12378 + "int $4\n0:\n"
12379 + _ASM_EXTABLE(0b, 0b)
12380 +#endif
12381 +
12382 + : "+m" (v->counter));
12383 +}
12384 +
12385 +/**
12386 + * atomic_inc_unchecked - increment atomic variable
12387 + * @v: pointer of type atomic_unchecked_t
12388 + *
12389 + * Atomically increments @v by 1.
12390 + */
12391 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
12392 +{
12393 + asm volatile(LOCK_PREFIX "incl %0\n"
12394 : "+m" (v->counter));
12395 }
12396
12397 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
12398 */
12399 static inline void atomic_dec(atomic_t *v)
12400 {
12401 - asm volatile(LOCK_PREFIX "decl %0"
12402 + asm volatile(LOCK_PREFIX "decl %0\n"
12403 +
12404 +#ifdef CONFIG_PAX_REFCOUNT
12405 + "jno 0f\n"
12406 + LOCK_PREFIX "incl %0\n"
12407 + "int $4\n0:\n"
12408 + _ASM_EXTABLE(0b, 0b)
12409 +#endif
12410 +
12411 + : "+m" (v->counter));
12412 +}
12413 +
12414 +/**
12415 + * atomic_dec_unchecked - decrement atomic variable
12416 + * @v: pointer of type atomic_unchecked_t
12417 + *
12418 + * Atomically decrements @v by 1.
12419 + */
12420 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
12421 +{
12422 + asm volatile(LOCK_PREFIX "decl %0\n"
12423 : "+m" (v->counter));
12424 }
12425
12426 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
12427 {
12428 unsigned char c;
12429
12430 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
12431 + asm volatile(LOCK_PREFIX "decl %0\n"
12432 +
12433 +#ifdef CONFIG_PAX_REFCOUNT
12434 + "jno 0f\n"
12435 + LOCK_PREFIX "incl %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 : : "memory");
12443 return c != 0;
12444 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
12445 {
12446 unsigned char c;
12447
12448 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
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 + "sete %1\n"
12459 + : "+m" (v->counter), "=qm" (c)
12460 + : : "memory");
12461 + return c != 0;
12462 +}
12463 +
12464 +/**
12465 + * atomic_inc_and_test_unchecked - increment and test
12466 + * @v: pointer of type atomic_unchecked_t
12467 + *
12468 + * Atomically increments @v by 1
12469 + * and returns true if the result is zero, or false for all
12470 + * other cases.
12471 + */
12472 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
12473 +{
12474 + unsigned char c;
12475 +
12476 + asm volatile(LOCK_PREFIX "incl %0\n"
12477 + "sete %1\n"
12478 : "+m" (v->counter), "=qm" (c)
12479 : : "memory");
12480 return c != 0;
12481 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12482 {
12483 unsigned char c;
12484
12485 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
12486 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
12487 +
12488 +#ifdef CONFIG_PAX_REFCOUNT
12489 + "jno 0f\n"
12490 + LOCK_PREFIX "subl %2,%0\n"
12491 + "int $4\n0:\n"
12492 + _ASM_EXTABLE(0b, 0b)
12493 +#endif
12494 +
12495 + "sets %1\n"
12496 : "+m" (v->counter), "=qm" (c)
12497 : "ir" (i) : "memory");
12498 return c;
12499 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12500 */
12501 static inline int atomic_add_return(int i, atomic_t *v)
12502 {
12503 + return i + xadd_check_overflow(&v->counter, i);
12504 +}
12505 +
12506 +/**
12507 + * atomic_add_return_unchecked - add integer and return
12508 + * @i: integer value to add
12509 + * @v: pointer of type atomic_unchecked_t
12510 + *
12511 + * Atomically adds @i to @v and returns @i + @v
12512 + */
12513 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
12514 +{
12515 return i + xadd(&v->counter, i);
12516 }
12517
12518 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
12519 }
12520
12521 #define atomic_inc_return(v) (atomic_add_return(1, v))
12522 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
12523 +{
12524 + return atomic_add_return_unchecked(1, v);
12525 +}
12526 #define atomic_dec_return(v) (atomic_sub_return(1, v))
12527
12528 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12529 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12530 return cmpxchg(&v->counter, old, new);
12531 }
12532
12533 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
12534 +{
12535 + return cmpxchg(&v->counter, old, new);
12536 +}
12537 +
12538 static inline int atomic_xchg(atomic_t *v, int new)
12539 {
12540 return xchg(&v->counter, new);
12541 }
12542
12543 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
12544 +{
12545 + return xchg(&v->counter, new);
12546 +}
12547 +
12548 /**
12549 * __atomic_add_unless - add unless the number is already a given value
12550 * @v: pointer of type atomic_t
12551 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
12552 */
12553 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12554 {
12555 - int c, old;
12556 + int c, old, new;
12557 c = atomic_read(v);
12558 for (;;) {
12559 - if (unlikely(c == (u)))
12560 + if (unlikely(c == u))
12561 break;
12562 - old = atomic_cmpxchg((v), c, c + (a));
12563 +
12564 + asm volatile("addl %2,%0\n"
12565 +
12566 +#ifdef CONFIG_PAX_REFCOUNT
12567 + "jno 0f\n"
12568 + "subl %2,%0\n"
12569 + "int $4\n0:\n"
12570 + _ASM_EXTABLE(0b, 0b)
12571 +#endif
12572 +
12573 + : "=r" (new)
12574 + : "0" (c), "ir" (a));
12575 +
12576 + old = atomic_cmpxchg(v, c, new);
12577 if (likely(old == c))
12578 break;
12579 c = old;
12580 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12581 }
12582
12583 /**
12584 + * atomic_inc_not_zero_hint - increment if not null
12585 + * @v: pointer of type atomic_t
12586 + * @hint: probable value of the atomic before the increment
12587 + *
12588 + * This version of atomic_inc_not_zero() gives a hint of probable
12589 + * value of the atomic. This helps processor to not read the memory
12590 + * before doing the atomic read/modify/write cycle, lowering
12591 + * number of bus transactions on some arches.
12592 + *
12593 + * Returns: 0 if increment was not done, 1 otherwise.
12594 + */
12595 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
12596 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
12597 +{
12598 + int val, c = hint, new;
12599 +
12600 + /* sanity test, should be removed by compiler if hint is a constant */
12601 + if (!hint)
12602 + return __atomic_add_unless(v, 1, 0);
12603 +
12604 + do {
12605 + asm volatile("incl %0\n"
12606 +
12607 +#ifdef CONFIG_PAX_REFCOUNT
12608 + "jno 0f\n"
12609 + "decl %0\n"
12610 + "int $4\n0:\n"
12611 + _ASM_EXTABLE(0b, 0b)
12612 +#endif
12613 +
12614 + : "=r" (new)
12615 + : "0" (c));
12616 +
12617 + val = atomic_cmpxchg(v, c, new);
12618 + if (val == c)
12619 + return 1;
12620 + c = val;
12621 + } while (c);
12622 +
12623 + return 0;
12624 +}
12625 +
12626 +/**
12627 * atomic_inc_short - increment of a short integer
12628 * @v: pointer to type int
12629 *
12630 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
12631 #endif
12632
12633 /* These are x86-specific, used by some header files */
12634 -#define atomic_clear_mask(mask, addr) \
12635 - asm volatile(LOCK_PREFIX "andl %0,%1" \
12636 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
12637 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
12638 +{
12639 + asm volatile(LOCK_PREFIX "andl %1,%0"
12640 + : "+m" (v->counter)
12641 + : "r" (~(mask))
12642 + : "memory");
12643 +}
12644
12645 -#define atomic_set_mask(mask, addr) \
12646 - asm volatile(LOCK_PREFIX "orl %0,%1" \
12647 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
12648 - : "memory")
12649 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12650 +{
12651 + asm volatile(LOCK_PREFIX "andl %1,%0"
12652 + : "+m" (v->counter)
12653 + : "r" (~(mask))
12654 + : "memory");
12655 +}
12656 +
12657 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
12658 +{
12659 + asm volatile(LOCK_PREFIX "orl %1,%0"
12660 + : "+m" (v->counter)
12661 + : "r" (mask)
12662 + : "memory");
12663 +}
12664 +
12665 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12666 +{
12667 + asm volatile(LOCK_PREFIX "orl %1,%0"
12668 + : "+m" (v->counter)
12669 + : "r" (mask)
12670 + : "memory");
12671 +}
12672
12673 /* Atomic operations are already serializing on x86 */
12674 #define smp_mb__before_atomic_dec() barrier()
12675 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
12676 index b154de7..aadebd8 100644
12677 --- a/arch/x86/include/asm/atomic64_32.h
12678 +++ b/arch/x86/include/asm/atomic64_32.h
12679 @@ -12,6 +12,14 @@ typedef struct {
12680 u64 __aligned(8) counter;
12681 } atomic64_t;
12682
12683 +#ifdef CONFIG_PAX_REFCOUNT
12684 +typedef struct {
12685 + u64 __aligned(8) counter;
12686 +} atomic64_unchecked_t;
12687 +#else
12688 +typedef atomic64_t atomic64_unchecked_t;
12689 +#endif
12690 +
12691 #define ATOMIC64_INIT(val) { (val) }
12692
12693 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
12694 @@ -37,21 +45,31 @@ typedef struct {
12695 ATOMIC64_DECL_ONE(sym##_386)
12696
12697 ATOMIC64_DECL_ONE(add_386);
12698 +ATOMIC64_DECL_ONE(add_unchecked_386);
12699 ATOMIC64_DECL_ONE(sub_386);
12700 +ATOMIC64_DECL_ONE(sub_unchecked_386);
12701 ATOMIC64_DECL_ONE(inc_386);
12702 +ATOMIC64_DECL_ONE(inc_unchecked_386);
12703 ATOMIC64_DECL_ONE(dec_386);
12704 +ATOMIC64_DECL_ONE(dec_unchecked_386);
12705 #endif
12706
12707 #define alternative_atomic64(f, out, in...) \
12708 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
12709
12710 ATOMIC64_DECL(read);
12711 +ATOMIC64_DECL(read_unchecked);
12712 ATOMIC64_DECL(set);
12713 +ATOMIC64_DECL(set_unchecked);
12714 ATOMIC64_DECL(xchg);
12715 ATOMIC64_DECL(add_return);
12716 +ATOMIC64_DECL(add_return_unchecked);
12717 ATOMIC64_DECL(sub_return);
12718 +ATOMIC64_DECL(sub_return_unchecked);
12719 ATOMIC64_DECL(inc_return);
12720 +ATOMIC64_DECL(inc_return_unchecked);
12721 ATOMIC64_DECL(dec_return);
12722 +ATOMIC64_DECL(dec_return_unchecked);
12723 ATOMIC64_DECL(dec_if_positive);
12724 ATOMIC64_DECL(inc_not_zero);
12725 ATOMIC64_DECL(add_unless);
12726 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
12727 }
12728
12729 /**
12730 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
12731 + * @p: pointer to type atomic64_unchecked_t
12732 + * @o: expected value
12733 + * @n: new value
12734 + *
12735 + * Atomically sets @v to @n if it was equal to @o and returns
12736 + * the old value.
12737 + */
12738 +
12739 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
12740 +{
12741 + return cmpxchg64(&v->counter, o, n);
12742 +}
12743 +
12744 +/**
12745 * atomic64_xchg - xchg atomic64 variable
12746 * @v: pointer to type atomic64_t
12747 * @n: value to assign
12748 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
12749 }
12750
12751 /**
12752 + * atomic64_set_unchecked - set atomic64 variable
12753 + * @v: pointer to type atomic64_unchecked_t
12754 + * @n: value to assign
12755 + *
12756 + * Atomically sets the value of @v to @n.
12757 + */
12758 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
12759 +{
12760 + unsigned high = (unsigned)(i >> 32);
12761 + unsigned low = (unsigned)i;
12762 + alternative_atomic64(set, /* no output */,
12763 + "S" (v), "b" (low), "c" (high)
12764 + : "eax", "edx", "memory");
12765 +}
12766 +
12767 +/**
12768 * atomic64_read - read atomic64 variable
12769 * @v: pointer to type atomic64_t
12770 *
12771 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
12772 }
12773
12774 /**
12775 + * atomic64_read_unchecked - read atomic64 variable
12776 + * @v: pointer to type atomic64_unchecked_t
12777 + *
12778 + * Atomically reads the value of @v and returns it.
12779 + */
12780 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
12781 +{
12782 + long long r;
12783 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
12784 + return r;
12785 + }
12786 +
12787 +/**
12788 * atomic64_add_return - add and return
12789 * @i: integer value to add
12790 * @v: pointer to type atomic64_t
12791 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
12792 return i;
12793 }
12794
12795 +/**
12796 + * atomic64_add_return_unchecked - add and return
12797 + * @i: integer value to add
12798 + * @v: pointer to type atomic64_unchecked_t
12799 + *
12800 + * Atomically adds @i to @v and returns @i + *@v
12801 + */
12802 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
12803 +{
12804 + alternative_atomic64(add_return_unchecked,
12805 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12806 + ASM_NO_INPUT_CLOBBER("memory"));
12807 + return i;
12808 +}
12809 +
12810 /*
12811 * Other variants with different arithmetic operators:
12812 */
12813 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
12814 return a;
12815 }
12816
12817 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12818 +{
12819 + long long a;
12820 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
12821 + "S" (v) : "memory", "ecx");
12822 + return a;
12823 +}
12824 +
12825 static inline long long atomic64_dec_return(atomic64_t *v)
12826 {
12827 long long a;
12828 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
12829 }
12830
12831 /**
12832 + * atomic64_add_unchecked - add integer to atomic64 variable
12833 + * @i: integer value to add
12834 + * @v: pointer to type atomic64_unchecked_t
12835 + *
12836 + * Atomically adds @i to @v.
12837 + */
12838 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
12839 +{
12840 + __alternative_atomic64(add_unchecked, add_return_unchecked,
12841 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12842 + ASM_NO_INPUT_CLOBBER("memory"));
12843 + return i;
12844 +}
12845 +
12846 +/**
12847 * atomic64_sub - subtract the atomic64 variable
12848 * @i: integer value to subtract
12849 * @v: pointer to type atomic64_t
12850 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
12851 index 0e1cbfc..5623683 100644
12852 --- a/arch/x86/include/asm/atomic64_64.h
12853 +++ b/arch/x86/include/asm/atomic64_64.h
12854 @@ -18,7 +18,19 @@
12855 */
12856 static inline long atomic64_read(const atomic64_t *v)
12857 {
12858 - return (*(volatile long *)&(v)->counter);
12859 + return (*(volatile const long *)&(v)->counter);
12860 +}
12861 +
12862 +/**
12863 + * atomic64_read_unchecked - read atomic64 variable
12864 + * @v: pointer of type atomic64_unchecked_t
12865 + *
12866 + * Atomically reads the value of @v.
12867 + * Doesn't imply a read memory barrier.
12868 + */
12869 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
12870 +{
12871 + return (*(volatile const long *)&(v)->counter);
12872 }
12873
12874 /**
12875 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
12876 }
12877
12878 /**
12879 + * atomic64_set_unchecked - set atomic64 variable
12880 + * @v: pointer to type atomic64_unchecked_t
12881 + * @i: required value
12882 + *
12883 + * Atomically sets the value of @v to @i.
12884 + */
12885 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
12886 +{
12887 + v->counter = i;
12888 +}
12889 +
12890 +/**
12891 * atomic64_add - add integer to atomic64 variable
12892 * @i: integer value to add
12893 * @v: pointer to type atomic64_t
12894 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
12895 */
12896 static inline void atomic64_add(long i, atomic64_t *v)
12897 {
12898 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
12899 +
12900 +#ifdef CONFIG_PAX_REFCOUNT
12901 + "jno 0f\n"
12902 + LOCK_PREFIX "subq %1,%0\n"
12903 + "int $4\n0:\n"
12904 + _ASM_EXTABLE(0b, 0b)
12905 +#endif
12906 +
12907 + : "=m" (v->counter)
12908 + : "er" (i), "m" (v->counter));
12909 +}
12910 +
12911 +/**
12912 + * atomic64_add_unchecked - add integer to atomic64 variable
12913 + * @i: integer value to add
12914 + * @v: pointer to type atomic64_unchecked_t
12915 + *
12916 + * Atomically adds @i to @v.
12917 + */
12918 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
12919 +{
12920 asm volatile(LOCK_PREFIX "addq %1,%0"
12921 : "=m" (v->counter)
12922 : "er" (i), "m" (v->counter));
12923 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
12924 */
12925 static inline void atomic64_sub(long i, atomic64_t *v)
12926 {
12927 - asm volatile(LOCK_PREFIX "subq %1,%0"
12928 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12929 +
12930 +#ifdef CONFIG_PAX_REFCOUNT
12931 + "jno 0f\n"
12932 + LOCK_PREFIX "addq %1,%0\n"
12933 + "int $4\n0:\n"
12934 + _ASM_EXTABLE(0b, 0b)
12935 +#endif
12936 +
12937 + : "=m" (v->counter)
12938 + : "er" (i), "m" (v->counter));
12939 +}
12940 +
12941 +/**
12942 + * atomic64_sub_unchecked - subtract the atomic64 variable
12943 + * @i: integer value to subtract
12944 + * @v: pointer to type atomic64_unchecked_t
12945 + *
12946 + * Atomically subtracts @i from @v.
12947 + */
12948 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
12949 +{
12950 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12951 : "=m" (v->counter)
12952 : "er" (i), "m" (v->counter));
12953 }
12954 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12955 {
12956 unsigned char c;
12957
12958 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
12959 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
12960 +
12961 +#ifdef CONFIG_PAX_REFCOUNT
12962 + "jno 0f\n"
12963 + LOCK_PREFIX "addq %2,%0\n"
12964 + "int $4\n0:\n"
12965 + _ASM_EXTABLE(0b, 0b)
12966 +#endif
12967 +
12968 + "sete %1\n"
12969 : "=m" (v->counter), "=qm" (c)
12970 : "er" (i), "m" (v->counter) : "memory");
12971 return c;
12972 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12973 */
12974 static inline void atomic64_inc(atomic64_t *v)
12975 {
12976 + asm volatile(LOCK_PREFIX "incq %0\n"
12977 +
12978 +#ifdef CONFIG_PAX_REFCOUNT
12979 + "jno 0f\n"
12980 + LOCK_PREFIX "decq %0\n"
12981 + "int $4\n0:\n"
12982 + _ASM_EXTABLE(0b, 0b)
12983 +#endif
12984 +
12985 + : "=m" (v->counter)
12986 + : "m" (v->counter));
12987 +}
12988 +
12989 +/**
12990 + * atomic64_inc_unchecked - increment atomic64 variable
12991 + * @v: pointer to type atomic64_unchecked_t
12992 + *
12993 + * Atomically increments @v by 1.
12994 + */
12995 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
12996 +{
12997 asm volatile(LOCK_PREFIX "incq %0"
12998 : "=m" (v->counter)
12999 : "m" (v->counter));
13000 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
13001 */
13002 static inline void atomic64_dec(atomic64_t *v)
13003 {
13004 - asm volatile(LOCK_PREFIX "decq %0"
13005 + asm volatile(LOCK_PREFIX "decq %0\n"
13006 +
13007 +#ifdef CONFIG_PAX_REFCOUNT
13008 + "jno 0f\n"
13009 + LOCK_PREFIX "incq %0\n"
13010 + "int $4\n0:\n"
13011 + _ASM_EXTABLE(0b, 0b)
13012 +#endif
13013 +
13014 + : "=m" (v->counter)
13015 + : "m" (v->counter));
13016 +}
13017 +
13018 +/**
13019 + * atomic64_dec_unchecked - decrement atomic64 variable
13020 + * @v: pointer to type atomic64_t
13021 + *
13022 + * Atomically decrements @v by 1.
13023 + */
13024 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
13025 +{
13026 + asm volatile(LOCK_PREFIX "decq %0\n"
13027 : "=m" (v->counter)
13028 : "m" (v->counter));
13029 }
13030 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
13031 {
13032 unsigned char c;
13033
13034 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
13035 + asm volatile(LOCK_PREFIX "decq %0\n"
13036 +
13037 +#ifdef CONFIG_PAX_REFCOUNT
13038 + "jno 0f\n"
13039 + LOCK_PREFIX "incq %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 : "m" (v->counter) : "memory");
13047 return c != 0;
13048 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
13049 {
13050 unsigned char c;
13051
13052 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
13053 + asm volatile(LOCK_PREFIX "incq %0\n"
13054 +
13055 +#ifdef CONFIG_PAX_REFCOUNT
13056 + "jno 0f\n"
13057 + LOCK_PREFIX "decq %0\n"
13058 + "int $4\n0:\n"
13059 + _ASM_EXTABLE(0b, 0b)
13060 +#endif
13061 +
13062 + "sete %1\n"
13063 : "=m" (v->counter), "=qm" (c)
13064 : "m" (v->counter) : "memory");
13065 return c != 0;
13066 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
13067 {
13068 unsigned char c;
13069
13070 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
13071 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
13072 +
13073 +#ifdef CONFIG_PAX_REFCOUNT
13074 + "jno 0f\n"
13075 + LOCK_PREFIX "subq %2,%0\n"
13076 + "int $4\n0:\n"
13077 + _ASM_EXTABLE(0b, 0b)
13078 +#endif
13079 +
13080 + "sets %1\n"
13081 : "=m" (v->counter), "=qm" (c)
13082 : "er" (i), "m" (v->counter) : "memory");
13083 return c;
13084 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
13085 */
13086 static inline long atomic64_add_return(long i, atomic64_t *v)
13087 {
13088 + return i + xadd_check_overflow(&v->counter, i);
13089 +}
13090 +
13091 +/**
13092 + * atomic64_add_return_unchecked - add and return
13093 + * @i: integer value to add
13094 + * @v: pointer to type atomic64_unchecked_t
13095 + *
13096 + * Atomically adds @i to @v and returns @i + @v
13097 + */
13098 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
13099 +{
13100 return i + xadd(&v->counter, i);
13101 }
13102
13103 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
13104 }
13105
13106 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
13107 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
13108 +{
13109 + return atomic64_add_return_unchecked(1, v);
13110 +}
13111 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
13112
13113 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
13114 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
13115 return cmpxchg(&v->counter, old, new);
13116 }
13117
13118 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
13119 +{
13120 + return cmpxchg(&v->counter, old, new);
13121 +}
13122 +
13123 static inline long atomic64_xchg(atomic64_t *v, long new)
13124 {
13125 return xchg(&v->counter, new);
13126 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
13127 */
13128 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
13129 {
13130 - long c, old;
13131 + long c, old, new;
13132 c = atomic64_read(v);
13133 for (;;) {
13134 - if (unlikely(c == (u)))
13135 + if (unlikely(c == u))
13136 break;
13137 - old = atomic64_cmpxchg((v), c, c + (a));
13138 +
13139 + asm volatile("add %2,%0\n"
13140 +
13141 +#ifdef CONFIG_PAX_REFCOUNT
13142 + "jno 0f\n"
13143 + "sub %2,%0\n"
13144 + "int $4\n0:\n"
13145 + _ASM_EXTABLE(0b, 0b)
13146 +#endif
13147 +
13148 + : "=r" (new)
13149 + : "0" (c), "ir" (a));
13150 +
13151 + old = atomic64_cmpxchg(v, c, new);
13152 if (likely(old == c))
13153 break;
13154 c = old;
13155 }
13156 - return c != (u);
13157 + return c != u;
13158 }
13159
13160 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
13161 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
13162 index 6dfd019..28e188d 100644
13163 --- a/arch/x86/include/asm/bitops.h
13164 +++ b/arch/x86/include/asm/bitops.h
13165 @@ -40,7 +40,7 @@
13166 * a mask operation on a byte.
13167 */
13168 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
13169 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
13170 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
13171 #define CONST_MASK(nr) (1 << ((nr) & 7))
13172
13173 /**
13174 @@ -486,7 +486,7 @@ static inline int fls(int x)
13175 * at position 64.
13176 */
13177 #ifdef CONFIG_X86_64
13178 -static __always_inline int fls64(__u64 x)
13179 +static __always_inline long fls64(__u64 x)
13180 {
13181 int bitpos = -1;
13182 /*
13183 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
13184 index 4fa687a..60f2d39 100644
13185 --- a/arch/x86/include/asm/boot.h
13186 +++ b/arch/x86/include/asm/boot.h
13187 @@ -6,10 +6,15 @@
13188 #include <uapi/asm/boot.h>
13189
13190 /* Physical address where kernel should be loaded. */
13191 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
13192 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
13193 + (CONFIG_PHYSICAL_ALIGN - 1)) \
13194 & ~(CONFIG_PHYSICAL_ALIGN - 1))
13195
13196 +#ifndef __ASSEMBLY__
13197 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
13198 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
13199 +#endif
13200 +
13201 /* Minimum kernel alignment, as a power of two */
13202 #ifdef CONFIG_X86_64
13203 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
13204 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
13205 index 48f99f1..d78ebf9 100644
13206 --- a/arch/x86/include/asm/cache.h
13207 +++ b/arch/x86/include/asm/cache.h
13208 @@ -5,12 +5,13 @@
13209
13210 /* L1 cache line size */
13211 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
13212 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
13213 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
13214
13215 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
13216 +#define __read_only __attribute__((__section__(".data..read_only")))
13217
13218 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
13219 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
13220 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
13221
13222 #ifdef CONFIG_X86_VSMP
13223 #ifdef CONFIG_SMP
13224 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
13225 index 9863ee3..4a1f8e1 100644
13226 --- a/arch/x86/include/asm/cacheflush.h
13227 +++ b/arch/x86/include/asm/cacheflush.h
13228 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
13229 unsigned long pg_flags = pg->flags & _PGMT_MASK;
13230
13231 if (pg_flags == _PGMT_DEFAULT)
13232 - return -1;
13233 + return ~0UL;
13234 else if (pg_flags == _PGMT_WC)
13235 return _PAGE_CACHE_WC;
13236 else if (pg_flags == _PGMT_UC_MINUS)
13237 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
13238 index 46fc474..b02b0f9 100644
13239 --- a/arch/x86/include/asm/checksum_32.h
13240 +++ b/arch/x86/include/asm/checksum_32.h
13241 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
13242 int len, __wsum sum,
13243 int *src_err_ptr, int *dst_err_ptr);
13244
13245 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
13246 + int len, __wsum sum,
13247 + int *src_err_ptr, int *dst_err_ptr);
13248 +
13249 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
13250 + int len, __wsum sum,
13251 + int *src_err_ptr, int *dst_err_ptr);
13252 +
13253 /*
13254 * Note: when you get a NULL pointer exception here this means someone
13255 * passed in an incorrect kernel address to one of these functions.
13256 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
13257 int *err_ptr)
13258 {
13259 might_sleep();
13260 - return csum_partial_copy_generic((__force void *)src, dst,
13261 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
13262 len, sum, err_ptr, NULL);
13263 }
13264
13265 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
13266 {
13267 might_sleep();
13268 if (access_ok(VERIFY_WRITE, dst, len))
13269 - return csum_partial_copy_generic(src, (__force void *)dst,
13270 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
13271 len, sum, NULL, err_ptr);
13272
13273 if (len)
13274 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
13275 index 8d871ea..c1a0dc9 100644
13276 --- a/arch/x86/include/asm/cmpxchg.h
13277 +++ b/arch/x86/include/asm/cmpxchg.h
13278 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
13279 __compiletime_error("Bad argument size for cmpxchg");
13280 extern void __xadd_wrong_size(void)
13281 __compiletime_error("Bad argument size for xadd");
13282 +extern void __xadd_check_overflow_wrong_size(void)
13283 + __compiletime_error("Bad argument size for xadd_check_overflow");
13284 extern void __add_wrong_size(void)
13285 __compiletime_error("Bad argument size for add");
13286 +extern void __add_check_overflow_wrong_size(void)
13287 + __compiletime_error("Bad argument size for add_check_overflow");
13288
13289 /*
13290 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
13291 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
13292 __ret; \
13293 })
13294
13295 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
13296 + ({ \
13297 + __typeof__ (*(ptr)) __ret = (arg); \
13298 + switch (sizeof(*(ptr))) { \
13299 + case __X86_CASE_L: \
13300 + asm volatile (lock #op "l %0, %1\n" \
13301 + "jno 0f\n" \
13302 + "mov %0,%1\n" \
13303 + "int $4\n0:\n" \
13304 + _ASM_EXTABLE(0b, 0b) \
13305 + : "+r" (__ret), "+m" (*(ptr)) \
13306 + : : "memory", "cc"); \
13307 + break; \
13308 + case __X86_CASE_Q: \
13309 + asm volatile (lock #op "q %q0, %1\n" \
13310 + "jno 0f\n" \
13311 + "mov %0,%1\n" \
13312 + "int $4\n0:\n" \
13313 + _ASM_EXTABLE(0b, 0b) \
13314 + : "+r" (__ret), "+m" (*(ptr)) \
13315 + : : "memory", "cc"); \
13316 + break; \
13317 + default: \
13318 + __ ## op ## _check_overflow_wrong_size(); \
13319 + } \
13320 + __ret; \
13321 + })
13322 +
13323 /*
13324 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
13325 * Since this is generally used to protect other memory information, we
13326 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
13327 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
13328 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
13329
13330 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
13331 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
13332 +
13333 #define __add(ptr, inc, lock) \
13334 ({ \
13335 __typeof__ (*(ptr)) __ret = (inc); \
13336 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
13337 index 59c6c40..5e0b22c 100644
13338 --- a/arch/x86/include/asm/compat.h
13339 +++ b/arch/x86/include/asm/compat.h
13340 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
13341 typedef u32 compat_uint_t;
13342 typedef u32 compat_ulong_t;
13343 typedef u64 __attribute__((aligned(4))) compat_u64;
13344 -typedef u32 compat_uptr_t;
13345 +typedef u32 __user compat_uptr_t;
13346
13347 struct compat_timespec {
13348 compat_time_t tv_sec;
13349 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
13350 index 2d9075e..b75a844 100644
13351 --- a/arch/x86/include/asm/cpufeature.h
13352 +++ b/arch/x86/include/asm/cpufeature.h
13353 @@ -206,7 +206,7 @@
13354 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
13355 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
13356 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
13357 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
13358 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
13359 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
13360 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
13361 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
13362 @@ -375,7 +375,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
13363 ".section .discard,\"aw\",@progbits\n"
13364 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
13365 ".previous\n"
13366 - ".section .altinstr_replacement,\"ax\"\n"
13367 + ".section .altinstr_replacement,\"a\"\n"
13368 "3: movb $1,%0\n"
13369 "4:\n"
13370 ".previous\n"
13371 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
13372 index 8bf1c06..b6ae785 100644
13373 --- a/arch/x86/include/asm/desc.h
13374 +++ b/arch/x86/include/asm/desc.h
13375 @@ -4,6 +4,7 @@
13376 #include <asm/desc_defs.h>
13377 #include <asm/ldt.h>
13378 #include <asm/mmu.h>
13379 +#include <asm/pgtable.h>
13380
13381 #include <linux/smp.h>
13382 #include <linux/percpu.h>
13383 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13384
13385 desc->type = (info->read_exec_only ^ 1) << 1;
13386 desc->type |= info->contents << 2;
13387 + desc->type |= info->seg_not_present ^ 1;
13388
13389 desc->s = 1;
13390 desc->dpl = 0x3;
13391 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13392 }
13393
13394 extern struct desc_ptr idt_descr;
13395 -extern gate_desc idt_table[];
13396 extern struct desc_ptr nmi_idt_descr;
13397 -extern gate_desc nmi_idt_table[];
13398 -
13399 -struct gdt_page {
13400 - struct desc_struct gdt[GDT_ENTRIES];
13401 -} __attribute__((aligned(PAGE_SIZE)));
13402 -
13403 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
13404 +extern gate_desc idt_table[256];
13405 +extern gate_desc nmi_idt_table[256];
13406
13407 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
13408 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
13409 {
13410 - return per_cpu(gdt_page, cpu).gdt;
13411 + return cpu_gdt_table[cpu];
13412 }
13413
13414 #ifdef CONFIG_X86_64
13415 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
13416 unsigned long base, unsigned dpl, unsigned flags,
13417 unsigned short seg)
13418 {
13419 - gate->a = (seg << 16) | (base & 0xffff);
13420 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
13421 + gate->gate.offset_low = base;
13422 + gate->gate.seg = seg;
13423 + gate->gate.reserved = 0;
13424 + gate->gate.type = type;
13425 + gate->gate.s = 0;
13426 + gate->gate.dpl = dpl;
13427 + gate->gate.p = 1;
13428 + gate->gate.offset_high = base >> 16;
13429 }
13430
13431 #endif
13432 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
13433
13434 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
13435 {
13436 + pax_open_kernel();
13437 memcpy(&idt[entry], gate, sizeof(*gate));
13438 + pax_close_kernel();
13439 }
13440
13441 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
13442 {
13443 + pax_open_kernel();
13444 memcpy(&ldt[entry], desc, 8);
13445 + pax_close_kernel();
13446 }
13447
13448 static inline void
13449 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
13450 default: size = sizeof(*gdt); break;
13451 }
13452
13453 + pax_open_kernel();
13454 memcpy(&gdt[entry], desc, size);
13455 + pax_close_kernel();
13456 }
13457
13458 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
13459 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
13460
13461 static inline void native_load_tr_desc(void)
13462 {
13463 + pax_open_kernel();
13464 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
13465 + pax_close_kernel();
13466 }
13467
13468 static inline void native_load_gdt(const struct desc_ptr *dtr)
13469 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
13470 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
13471 unsigned int i;
13472
13473 + pax_open_kernel();
13474 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
13475 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
13476 + pax_close_kernel();
13477 }
13478
13479 #define _LDT_empty(info) \
13480 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
13481 preempt_enable();
13482 }
13483
13484 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
13485 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
13486 {
13487 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
13488 }
13489 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
13490 }
13491
13492 #ifdef CONFIG_X86_64
13493 -static inline void set_nmi_gate(int gate, void *addr)
13494 +static inline void set_nmi_gate(int gate, const void *addr)
13495 {
13496 gate_desc s;
13497
13498 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
13499 }
13500 #endif
13501
13502 -static inline void _set_gate(int gate, unsigned type, void *addr,
13503 +static inline void _set_gate(int gate, unsigned type, const void *addr,
13504 unsigned dpl, unsigned ist, unsigned seg)
13505 {
13506 gate_desc s;
13507 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
13508 * Pentium F0 0F bugfix can have resulted in the mapped
13509 * IDT being write-protected.
13510 */
13511 -static inline void set_intr_gate(unsigned int n, void *addr)
13512 +static inline void set_intr_gate(unsigned int n, const void *addr)
13513 {
13514 BUG_ON((unsigned)n > 0xFF);
13515 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
13516 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
13517 /*
13518 * This routine sets up an interrupt gate at directory privilege level 3.
13519 */
13520 -static inline void set_system_intr_gate(unsigned int n, void *addr)
13521 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
13522 {
13523 BUG_ON((unsigned)n > 0xFF);
13524 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
13525 }
13526
13527 -static inline void set_system_trap_gate(unsigned int n, void *addr)
13528 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
13529 {
13530 BUG_ON((unsigned)n > 0xFF);
13531 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
13532 }
13533
13534 -static inline void set_trap_gate(unsigned int n, void *addr)
13535 +static inline void set_trap_gate(unsigned int n, const void *addr)
13536 {
13537 BUG_ON((unsigned)n > 0xFF);
13538 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
13539 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
13540 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
13541 {
13542 BUG_ON((unsigned)n > 0xFF);
13543 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
13544 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
13545 }
13546
13547 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
13548 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
13549 {
13550 BUG_ON((unsigned)n > 0xFF);
13551 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
13552 }
13553
13554 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
13555 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
13556 {
13557 BUG_ON((unsigned)n > 0xFF);
13558 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
13559 }
13560
13561 +#ifdef CONFIG_X86_32
13562 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
13563 +{
13564 + struct desc_struct d;
13565 +
13566 + if (likely(limit))
13567 + limit = (limit - 1UL) >> PAGE_SHIFT;
13568 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
13569 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
13570 +}
13571 +#endif
13572 +
13573 #endif /* _ASM_X86_DESC_H */
13574 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
13575 index 278441f..b95a174 100644
13576 --- a/arch/x86/include/asm/desc_defs.h
13577 +++ b/arch/x86/include/asm/desc_defs.h
13578 @@ -31,6 +31,12 @@ struct desc_struct {
13579 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
13580 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
13581 };
13582 + struct {
13583 + u16 offset_low;
13584 + u16 seg;
13585 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
13586 + unsigned offset_high: 16;
13587 + } gate;
13588 };
13589 } __attribute__((packed));
13590
13591 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
13592 index ced283a..ffe04cc 100644
13593 --- a/arch/x86/include/asm/div64.h
13594 +++ b/arch/x86/include/asm/div64.h
13595 @@ -39,7 +39,7 @@
13596 __mod; \
13597 })
13598
13599 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13600 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13601 {
13602 union {
13603 u64 v64;
13604 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
13605 index 9c999c1..3860cb8 100644
13606 --- a/arch/x86/include/asm/elf.h
13607 +++ b/arch/x86/include/asm/elf.h
13608 @@ -243,7 +243,25 @@ extern int force_personality32;
13609 the loader. We need to make sure that it is out of the way of the program
13610 that it will "exec", and that there is sufficient room for the brk. */
13611
13612 +#ifdef CONFIG_PAX_SEGMEXEC
13613 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
13614 +#else
13615 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
13616 +#endif
13617 +
13618 +#ifdef CONFIG_PAX_ASLR
13619 +#ifdef CONFIG_X86_32
13620 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
13621 +
13622 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13623 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13624 +#else
13625 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
13626 +
13627 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13628 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13629 +#endif
13630 +#endif
13631
13632 /* This yields a mask that user programs can use to figure out what
13633 instruction set this CPU supports. This could be done in user space,
13634 @@ -296,16 +314,12 @@ do { \
13635
13636 #define ARCH_DLINFO \
13637 do { \
13638 - if (vdso_enabled) \
13639 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13640 - (unsigned long)current->mm->context.vdso); \
13641 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13642 } while (0)
13643
13644 #define ARCH_DLINFO_X32 \
13645 do { \
13646 - if (vdso_enabled) \
13647 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13648 - (unsigned long)current->mm->context.vdso); \
13649 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13650 } while (0)
13651
13652 #define AT_SYSINFO 32
13653 @@ -320,7 +334,7 @@ else \
13654
13655 #endif /* !CONFIG_X86_32 */
13656
13657 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
13658 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
13659
13660 #define VDSO_ENTRY \
13661 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
13662 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
13663 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
13664 #define compat_arch_setup_additional_pages syscall32_setup_pages
13665
13666 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
13667 -#define arch_randomize_brk arch_randomize_brk
13668 -
13669 /*
13670 * True on X86_32 or when emulating IA32 on X86_64
13671 */
13672 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
13673 index 75ce3f4..882e801 100644
13674 --- a/arch/x86/include/asm/emergency-restart.h
13675 +++ b/arch/x86/include/asm/emergency-restart.h
13676 @@ -13,6 +13,6 @@ enum reboot_type {
13677
13678 extern enum reboot_type reboot_type;
13679
13680 -extern void machine_emergency_restart(void);
13681 +extern void machine_emergency_restart(void) __noreturn;
13682
13683 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
13684 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
13685 index 41ab26e..a88c9e6 100644
13686 --- a/arch/x86/include/asm/fpu-internal.h
13687 +++ b/arch/x86/include/asm/fpu-internal.h
13688 @@ -126,7 +126,9 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
13689 ({ \
13690 int err; \
13691 asm volatile(ASM_STAC "\n" \
13692 - "1:" #insn "\n\t" \
13693 + "1:" \
13694 + __copyuser_seg \
13695 + #insn "\n\t" \
13696 "2: " ASM_CLAC "\n" \
13697 ".section .fixup,\"ax\"\n" \
13698 "3: movl $-1,%[err]\n" \
13699 @@ -299,7 +301,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
13700 "emms\n\t" /* clear stack tags */
13701 "fildl %P[addr]", /* set F?P to defined value */
13702 X86_FEATURE_FXSAVE_LEAK,
13703 - [addr] "m" (tsk->thread.fpu.has_fpu));
13704 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
13705
13706 return fpu_restore_checking(&tsk->thread.fpu);
13707 }
13708 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
13709 index be27ba1..8f13ff9 100644
13710 --- a/arch/x86/include/asm/futex.h
13711 +++ b/arch/x86/include/asm/futex.h
13712 @@ -12,6 +12,7 @@
13713 #include <asm/smap.h>
13714
13715 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
13716 + typecheck(u32 __user *, uaddr); \
13717 asm volatile("\t" ASM_STAC "\n" \
13718 "1:\t" insn "\n" \
13719 "2:\t" ASM_CLAC "\n" \
13720 @@ -20,15 +21,16 @@
13721 "\tjmp\t2b\n" \
13722 "\t.previous\n" \
13723 _ASM_EXTABLE(1b, 3b) \
13724 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
13725 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
13726 : "i" (-EFAULT), "0" (oparg), "1" (0))
13727
13728 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
13729 + typecheck(u32 __user *, uaddr); \
13730 asm volatile("\t" ASM_STAC "\n" \
13731 "1:\tmovl %2, %0\n" \
13732 "\tmovl\t%0, %3\n" \
13733 "\t" insn "\n" \
13734 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
13735 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
13736 "\tjnz\t1b\n" \
13737 "3:\t" ASM_CLAC "\n" \
13738 "\t.section .fixup,\"ax\"\n" \
13739 @@ -38,7 +40,7 @@
13740 _ASM_EXTABLE(1b, 4b) \
13741 _ASM_EXTABLE(2b, 4b) \
13742 : "=&a" (oldval), "=&r" (ret), \
13743 - "+m" (*uaddr), "=&r" (tem) \
13744 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
13745 : "r" (oparg), "i" (-EFAULT), "1" (0))
13746
13747 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13748 @@ -59,10 +61,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13749
13750 switch (op) {
13751 case FUTEX_OP_SET:
13752 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
13753 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
13754 break;
13755 case FUTEX_OP_ADD:
13756 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
13757 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
13758 uaddr, oparg);
13759 break;
13760 case FUTEX_OP_OR:
13761 @@ -116,14 +118,14 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
13762 return -EFAULT;
13763
13764 asm volatile("\t" ASM_STAC "\n"
13765 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
13766 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
13767 "2:\t" ASM_CLAC "\n"
13768 "\t.section .fixup, \"ax\"\n"
13769 "3:\tmov %3, %0\n"
13770 "\tjmp 2b\n"
13771 "\t.previous\n"
13772 _ASM_EXTABLE(1b, 3b)
13773 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
13774 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
13775 : "i" (-EFAULT), "r" (newval), "1" (oldval)
13776 : "memory"
13777 );
13778 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
13779 index eb92a6e..b98b2f4 100644
13780 --- a/arch/x86/include/asm/hw_irq.h
13781 +++ b/arch/x86/include/asm/hw_irq.h
13782 @@ -136,8 +136,8 @@ extern void setup_ioapic_dest(void);
13783 extern void enable_IO_APIC(void);
13784
13785 /* Statistics */
13786 -extern atomic_t irq_err_count;
13787 -extern atomic_t irq_mis_count;
13788 +extern atomic_unchecked_t irq_err_count;
13789 +extern atomic_unchecked_t irq_mis_count;
13790
13791 /* EISA */
13792 extern void eisa_set_level_irq(unsigned int irq);
13793 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
13794 index a203659..9889f1c 100644
13795 --- a/arch/x86/include/asm/i8259.h
13796 +++ b/arch/x86/include/asm/i8259.h
13797 @@ -62,7 +62,7 @@ struct legacy_pic {
13798 void (*init)(int auto_eoi);
13799 int (*irq_pending)(unsigned int irq);
13800 void (*make_irq)(unsigned int irq);
13801 -};
13802 +} __do_const;
13803
13804 extern struct legacy_pic *legacy_pic;
13805 extern struct legacy_pic null_legacy_pic;
13806 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
13807 index d8e8eef..1765f78 100644
13808 --- a/arch/x86/include/asm/io.h
13809 +++ b/arch/x86/include/asm/io.h
13810 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
13811 "m" (*(volatile type __force *)addr) barrier); }
13812
13813 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
13814 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
13815 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
13816 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
13817 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
13818
13819 build_mmio_read(__readb, "b", unsigned char, "=q", )
13820 -build_mmio_read(__readw, "w", unsigned short, "=r", )
13821 -build_mmio_read(__readl, "l", unsigned int, "=r", )
13822 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
13823 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
13824
13825 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
13826 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
13827 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
13828 return ioremap_nocache(offset, size);
13829 }
13830
13831 -extern void iounmap(volatile void __iomem *addr);
13832 +extern void iounmap(const volatile void __iomem *addr);
13833
13834 extern void set_iounmap_nonlazy(void);
13835
13836 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
13837
13838 #include <linux/vmalloc.h>
13839
13840 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
13841 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
13842 +{
13843 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13844 +}
13845 +
13846 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
13847 +{
13848 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13849 +}
13850 +
13851 /*
13852 * Convert a virtual cached pointer to an uncached pointer
13853 */
13854 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
13855 index bba3cf8..06bc8da 100644
13856 --- a/arch/x86/include/asm/irqflags.h
13857 +++ b/arch/x86/include/asm/irqflags.h
13858 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
13859 sti; \
13860 sysexit
13861
13862 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
13863 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
13864 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
13865 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
13866 +
13867 #else
13868 #define INTERRUPT_RETURN iret
13869 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
13870 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
13871 index d3ddd17..c9fb0cc 100644
13872 --- a/arch/x86/include/asm/kprobes.h
13873 +++ b/arch/x86/include/asm/kprobes.h
13874 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
13875 #define RELATIVEJUMP_SIZE 5
13876 #define RELATIVECALL_OPCODE 0xe8
13877 #define RELATIVE_ADDR_SIZE 4
13878 -#define MAX_STACK_SIZE 64
13879 -#define MIN_STACK_SIZE(ADDR) \
13880 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
13881 - THREAD_SIZE - (unsigned long)(ADDR))) \
13882 - ? (MAX_STACK_SIZE) \
13883 - : (((unsigned long)current_thread_info()) + \
13884 - THREAD_SIZE - (unsigned long)(ADDR)))
13885 +#define MAX_STACK_SIZE 64UL
13886 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
13887
13888 #define flush_insn_slot(p) do { } while (0)
13889
13890 diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
13891 index dc87b65..85039f9 100644
13892 --- a/arch/x86/include/asm/kvm_host.h
13893 +++ b/arch/x86/include/asm/kvm_host.h
13894 @@ -419,8 +419,8 @@ struct kvm_vcpu_arch {
13895 gpa_t time;
13896 struct pvclock_vcpu_time_info hv_clock;
13897 unsigned int hw_tsc_khz;
13898 - unsigned int time_offset;
13899 - struct page *time_page;
13900 + struct gfn_to_hva_cache pv_time;
13901 + bool pv_time_enabled;
13902 /* set guest stopped flag in pvclock flags field */
13903 bool pvclock_set_guest_stopped_request;
13904
13905 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
13906 index 2d89e39..baee879 100644
13907 --- a/arch/x86/include/asm/local.h
13908 +++ b/arch/x86/include/asm/local.h
13909 @@ -10,33 +10,97 @@ typedef struct {
13910 atomic_long_t a;
13911 } local_t;
13912
13913 +typedef struct {
13914 + atomic_long_unchecked_t a;
13915 +} local_unchecked_t;
13916 +
13917 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
13918
13919 #define local_read(l) atomic_long_read(&(l)->a)
13920 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
13921 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
13922 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
13923
13924 static inline void local_inc(local_t *l)
13925 {
13926 - asm volatile(_ASM_INC "%0"
13927 + asm volatile(_ASM_INC "%0\n"
13928 +
13929 +#ifdef CONFIG_PAX_REFCOUNT
13930 + "jno 0f\n"
13931 + _ASM_DEC "%0\n"
13932 + "int $4\n0:\n"
13933 + _ASM_EXTABLE(0b, 0b)
13934 +#endif
13935 +
13936 + : "+m" (l->a.counter));
13937 +}
13938 +
13939 +static inline void local_inc_unchecked(local_unchecked_t *l)
13940 +{
13941 + asm volatile(_ASM_INC "%0\n"
13942 : "+m" (l->a.counter));
13943 }
13944
13945 static inline void local_dec(local_t *l)
13946 {
13947 - asm volatile(_ASM_DEC "%0"
13948 + asm volatile(_ASM_DEC "%0\n"
13949 +
13950 +#ifdef CONFIG_PAX_REFCOUNT
13951 + "jno 0f\n"
13952 + _ASM_INC "%0\n"
13953 + "int $4\n0:\n"
13954 + _ASM_EXTABLE(0b, 0b)
13955 +#endif
13956 +
13957 + : "+m" (l->a.counter));
13958 +}
13959 +
13960 +static inline void local_dec_unchecked(local_unchecked_t *l)
13961 +{
13962 + asm volatile(_ASM_DEC "%0\n"
13963 : "+m" (l->a.counter));
13964 }
13965
13966 static inline void local_add(long i, local_t *l)
13967 {
13968 - asm volatile(_ASM_ADD "%1,%0"
13969 + asm volatile(_ASM_ADD "%1,%0\n"
13970 +
13971 +#ifdef CONFIG_PAX_REFCOUNT
13972 + "jno 0f\n"
13973 + _ASM_SUB "%1,%0\n"
13974 + "int $4\n0:\n"
13975 + _ASM_EXTABLE(0b, 0b)
13976 +#endif
13977 +
13978 + : "+m" (l->a.counter)
13979 + : "ir" (i));
13980 +}
13981 +
13982 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
13983 +{
13984 + asm volatile(_ASM_ADD "%1,%0\n"
13985 : "+m" (l->a.counter)
13986 : "ir" (i));
13987 }
13988
13989 static inline void local_sub(long i, local_t *l)
13990 {
13991 - asm volatile(_ASM_SUB "%1,%0"
13992 + asm volatile(_ASM_SUB "%1,%0\n"
13993 +
13994 +#ifdef CONFIG_PAX_REFCOUNT
13995 + "jno 0f\n"
13996 + _ASM_ADD "%1,%0\n"
13997 + "int $4\n0:\n"
13998 + _ASM_EXTABLE(0b, 0b)
13999 +#endif
14000 +
14001 + : "+m" (l->a.counter)
14002 + : "ir" (i));
14003 +}
14004 +
14005 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
14006 +{
14007 + asm volatile(_ASM_SUB "%1,%0\n"
14008 : "+m" (l->a.counter)
14009 : "ir" (i));
14010 }
14011 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
14012 {
14013 unsigned char c;
14014
14015 - asm volatile(_ASM_SUB "%2,%0; sete %1"
14016 + asm volatile(_ASM_SUB "%2,%0\n"
14017 +
14018 +#ifdef CONFIG_PAX_REFCOUNT
14019 + "jno 0f\n"
14020 + _ASM_ADD "%2,%0\n"
14021 + "int $4\n0:\n"
14022 + _ASM_EXTABLE(0b, 0b)
14023 +#endif
14024 +
14025 + "sete %1\n"
14026 : "+m" (l->a.counter), "=qm" (c)
14027 : "ir" (i) : "memory");
14028 return c;
14029 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
14030 {
14031 unsigned char c;
14032
14033 - asm volatile(_ASM_DEC "%0; sete %1"
14034 + asm volatile(_ASM_DEC "%0\n"
14035 +
14036 +#ifdef CONFIG_PAX_REFCOUNT
14037 + "jno 0f\n"
14038 + _ASM_INC "%0\n"
14039 + "int $4\n0:\n"
14040 + _ASM_EXTABLE(0b, 0b)
14041 +#endif
14042 +
14043 + "sete %1\n"
14044 : "+m" (l->a.counter), "=qm" (c)
14045 : : "memory");
14046 return c != 0;
14047 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
14048 {
14049 unsigned char c;
14050
14051 - asm volatile(_ASM_INC "%0; sete %1"
14052 + asm volatile(_ASM_INC "%0\n"
14053 +
14054 +#ifdef CONFIG_PAX_REFCOUNT
14055 + "jno 0f\n"
14056 + _ASM_DEC "%0\n"
14057 + "int $4\n0:\n"
14058 + _ASM_EXTABLE(0b, 0b)
14059 +#endif
14060 +
14061 + "sete %1\n"
14062 : "+m" (l->a.counter), "=qm" (c)
14063 : : "memory");
14064 return c != 0;
14065 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
14066 {
14067 unsigned char c;
14068
14069 - asm volatile(_ASM_ADD "%2,%0; sets %1"
14070 + asm volatile(_ASM_ADD "%2,%0\n"
14071 +
14072 +#ifdef CONFIG_PAX_REFCOUNT
14073 + "jno 0f\n"
14074 + _ASM_SUB "%2,%0\n"
14075 + "int $4\n0:\n"
14076 + _ASM_EXTABLE(0b, 0b)
14077 +#endif
14078 +
14079 + "sets %1\n"
14080 : "+m" (l->a.counter), "=qm" (c)
14081 : "ir" (i) : "memory");
14082 return c;
14083 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
14084 static inline long local_add_return(long i, local_t *l)
14085 {
14086 long __i = i;
14087 + asm volatile(_ASM_XADD "%0, %1\n"
14088 +
14089 +#ifdef CONFIG_PAX_REFCOUNT
14090 + "jno 0f\n"
14091 + _ASM_MOV "%0,%1\n"
14092 + "int $4\n0:\n"
14093 + _ASM_EXTABLE(0b, 0b)
14094 +#endif
14095 +
14096 + : "+r" (i), "+m" (l->a.counter)
14097 + : : "memory");
14098 + return i + __i;
14099 +}
14100 +
14101 +/**
14102 + * local_add_return_unchecked - add and return
14103 + * @i: integer value to add
14104 + * @l: pointer to type local_unchecked_t
14105 + *
14106 + * Atomically adds @i to @l and returns @i + @l
14107 + */
14108 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
14109 +{
14110 + long __i = i;
14111 asm volatile(_ASM_XADD "%0, %1;"
14112 : "+r" (i), "+m" (l->a.counter)
14113 : : "memory");
14114 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
14115
14116 #define local_cmpxchg(l, o, n) \
14117 (cmpxchg_local(&((l)->a.counter), (o), (n)))
14118 +#define local_cmpxchg_unchecked(l, o, n) \
14119 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
14120 /* Always has a lock prefix */
14121 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
14122
14123 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
14124 new file mode 100644
14125 index 0000000..2bfd3ba
14126 --- /dev/null
14127 +++ b/arch/x86/include/asm/mman.h
14128 @@ -0,0 +1,15 @@
14129 +#ifndef _X86_MMAN_H
14130 +#define _X86_MMAN_H
14131 +
14132 +#include <uapi/asm/mman.h>
14133 +
14134 +#ifdef __KERNEL__
14135 +#ifndef __ASSEMBLY__
14136 +#ifdef CONFIG_X86_32
14137 +#define arch_mmap_check i386_mmap_check
14138 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
14139 +#endif
14140 +#endif
14141 +#endif
14142 +
14143 +#endif /* X86_MMAN_H */
14144 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
14145 index 5f55e69..e20bfb1 100644
14146 --- a/arch/x86/include/asm/mmu.h
14147 +++ b/arch/x86/include/asm/mmu.h
14148 @@ -9,7 +9,7 @@
14149 * we put the segment information here.
14150 */
14151 typedef struct {
14152 - void *ldt;
14153 + struct desc_struct *ldt;
14154 int size;
14155
14156 #ifdef CONFIG_X86_64
14157 @@ -18,7 +18,19 @@ typedef struct {
14158 #endif
14159
14160 struct mutex lock;
14161 - void *vdso;
14162 + unsigned long vdso;
14163 +
14164 +#ifdef CONFIG_X86_32
14165 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
14166 + unsigned long user_cs_base;
14167 + unsigned long user_cs_limit;
14168 +
14169 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
14170 + cpumask_t cpu_user_cs_mask;
14171 +#endif
14172 +
14173 +#endif
14174 +#endif
14175 } mm_context_t;
14176
14177 #ifdef CONFIG_SMP
14178 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
14179 index cdbf367..adb37ac 100644
14180 --- a/arch/x86/include/asm/mmu_context.h
14181 +++ b/arch/x86/include/asm/mmu_context.h
14182 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
14183
14184 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
14185 {
14186 +
14187 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14188 + unsigned int i;
14189 + pgd_t *pgd;
14190 +
14191 + pax_open_kernel();
14192 + pgd = get_cpu_pgd(smp_processor_id());
14193 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
14194 + set_pgd_batched(pgd+i, native_make_pgd(0));
14195 + pax_close_kernel();
14196 +#endif
14197 +
14198 #ifdef CONFIG_SMP
14199 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
14200 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
14201 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14202 struct task_struct *tsk)
14203 {
14204 unsigned cpu = smp_processor_id();
14205 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14206 + int tlbstate = TLBSTATE_OK;
14207 +#endif
14208
14209 if (likely(prev != next)) {
14210 #ifdef CONFIG_SMP
14211 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14212 + tlbstate = this_cpu_read(cpu_tlbstate.state);
14213 +#endif
14214 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
14215 this_cpu_write(cpu_tlbstate.active_mm, next);
14216 #endif
14217 cpumask_set_cpu(cpu, mm_cpumask(next));
14218
14219 /* Re-load page tables */
14220 +#ifdef CONFIG_PAX_PER_CPU_PGD
14221 + pax_open_kernel();
14222 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
14223 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
14224 + pax_close_kernel();
14225 + load_cr3(get_cpu_pgd(cpu));
14226 +#else
14227 load_cr3(next->pgd);
14228 +#endif
14229
14230 /* stop flush ipis for the previous mm */
14231 cpumask_clear_cpu(cpu, mm_cpumask(prev));
14232 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14233 */
14234 if (unlikely(prev->context.ldt != next->context.ldt))
14235 load_LDT_nolock(&next->context);
14236 - }
14237 +
14238 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
14239 + if (!(__supported_pte_mask & _PAGE_NX)) {
14240 + smp_mb__before_clear_bit();
14241 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
14242 + smp_mb__after_clear_bit();
14243 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14244 + }
14245 +#endif
14246 +
14247 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14248 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
14249 + prev->context.user_cs_limit != next->context.user_cs_limit))
14250 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14251 #ifdef CONFIG_SMP
14252 + else if (unlikely(tlbstate != TLBSTATE_OK))
14253 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14254 +#endif
14255 +#endif
14256 +
14257 + }
14258 else {
14259 +
14260 +#ifdef CONFIG_PAX_PER_CPU_PGD
14261 + pax_open_kernel();
14262 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
14263 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
14264 + pax_close_kernel();
14265 + load_cr3(get_cpu_pgd(cpu));
14266 +#endif
14267 +
14268 +#ifdef CONFIG_SMP
14269 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
14270 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
14271
14272 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14273 * tlb flush IPI delivery. We must reload CR3
14274 * to make sure to use no freed page tables.
14275 */
14276 +
14277 +#ifndef CONFIG_PAX_PER_CPU_PGD
14278 load_cr3(next->pgd);
14279 +#endif
14280 +
14281 load_LDT_nolock(&next->context);
14282 +
14283 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
14284 + if (!(__supported_pte_mask & _PAGE_NX))
14285 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14286 +#endif
14287 +
14288 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14289 +#ifdef CONFIG_PAX_PAGEEXEC
14290 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
14291 +#endif
14292 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14293 +#endif
14294 +
14295 }
14296 +#endif
14297 }
14298 -#endif
14299 }
14300
14301 #define activate_mm(prev, next) \
14302 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
14303 index e3b7819..b257c64 100644
14304 --- a/arch/x86/include/asm/module.h
14305 +++ b/arch/x86/include/asm/module.h
14306 @@ -5,6 +5,7 @@
14307
14308 #ifdef CONFIG_X86_64
14309 /* X86_64 does not define MODULE_PROC_FAMILY */
14310 +#define MODULE_PROC_FAMILY ""
14311 #elif defined CONFIG_M486
14312 #define MODULE_PROC_FAMILY "486 "
14313 #elif defined CONFIG_M586
14314 @@ -57,8 +58,20 @@
14315 #error unknown processor family
14316 #endif
14317
14318 -#ifdef CONFIG_X86_32
14319 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
14320 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14321 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
14322 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
14323 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
14324 +#else
14325 +#define MODULE_PAX_KERNEXEC ""
14326 #endif
14327
14328 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14329 +#define MODULE_PAX_UDEREF "UDEREF "
14330 +#else
14331 +#define MODULE_PAX_UDEREF ""
14332 +#endif
14333 +
14334 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
14335 +
14336 #endif /* _ASM_X86_MODULE_H */
14337 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
14338 index c0fa356..07a498a 100644
14339 --- a/arch/x86/include/asm/nmi.h
14340 +++ b/arch/x86/include/asm/nmi.h
14341 @@ -42,11 +42,11 @@ struct nmiaction {
14342 nmi_handler_t handler;
14343 unsigned long flags;
14344 const char *name;
14345 -};
14346 +} __do_const;
14347
14348 #define register_nmi_handler(t, fn, fg, n, init...) \
14349 ({ \
14350 - static struct nmiaction init fn##_na = { \
14351 + static const struct nmiaction init fn##_na = { \
14352 .handler = (fn), \
14353 .name = (n), \
14354 .flags = (fg), \
14355 @@ -54,7 +54,7 @@ struct nmiaction {
14356 __register_nmi_handler((t), &fn##_na); \
14357 })
14358
14359 -int __register_nmi_handler(unsigned int, struct nmiaction *);
14360 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
14361
14362 void unregister_nmi_handler(unsigned int, const char *);
14363
14364 diff --git a/arch/x86/include/asm/page_64_types.h b/arch/x86/include/asm/page_64_types.h
14365 index 320f7bb..e89f8f8 100644
14366 --- a/arch/x86/include/asm/page_64_types.h
14367 +++ b/arch/x86/include/asm/page_64_types.h
14368 @@ -56,7 +56,7 @@ void copy_page(void *to, void *from);
14369
14370 /* duplicated to the one in bootmem.h */
14371 extern unsigned long max_pfn;
14372 -extern unsigned long phys_base;
14373 +extern const unsigned long phys_base;
14374
14375 extern unsigned long __phys_addr(unsigned long);
14376 #define __phys_reloc_hide(x) (x)
14377 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
14378 index 5edd174..c395822 100644
14379 --- a/arch/x86/include/asm/paravirt.h
14380 +++ b/arch/x86/include/asm/paravirt.h
14381 @@ -564,7 +564,7 @@ static inline pmd_t __pmd(pmdval_t val)
14382 return (pmd_t) { ret };
14383 }
14384
14385 -static inline pmdval_t pmd_val(pmd_t pmd)
14386 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
14387 {
14388 pmdval_t ret;
14389
14390 @@ -630,6 +630,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
14391 val);
14392 }
14393
14394 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14395 +{
14396 + pgdval_t val = native_pgd_val(pgd);
14397 +
14398 + if (sizeof(pgdval_t) > sizeof(long))
14399 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
14400 + val, (u64)val >> 32);
14401 + else
14402 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
14403 + val);
14404 +}
14405 +
14406 static inline void pgd_clear(pgd_t *pgdp)
14407 {
14408 set_pgd(pgdp, __pgd(0));
14409 @@ -711,6 +723,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
14410 pv_mmu_ops.set_fixmap(idx, phys, flags);
14411 }
14412
14413 +#ifdef CONFIG_PAX_KERNEXEC
14414 +static inline unsigned long pax_open_kernel(void)
14415 +{
14416 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
14417 +}
14418 +
14419 +static inline unsigned long pax_close_kernel(void)
14420 +{
14421 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
14422 +}
14423 +#else
14424 +static inline unsigned long pax_open_kernel(void) { return 0; }
14425 +static inline unsigned long pax_close_kernel(void) { return 0; }
14426 +#endif
14427 +
14428 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
14429
14430 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
14431 @@ -927,7 +954,7 @@ extern void default_banner(void);
14432
14433 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
14434 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
14435 -#define PARA_INDIRECT(addr) *%cs:addr
14436 +#define PARA_INDIRECT(addr) *%ss:addr
14437 #endif
14438
14439 #define INTERRUPT_RETURN \
14440 @@ -1002,6 +1029,21 @@ extern void default_banner(void);
14441 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
14442 CLBR_NONE, \
14443 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
14444 +
14445 +#define GET_CR0_INTO_RDI \
14446 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
14447 + mov %rax,%rdi
14448 +
14449 +#define SET_RDI_INTO_CR0 \
14450 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
14451 +
14452 +#define GET_CR3_INTO_RDI \
14453 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
14454 + mov %rax,%rdi
14455 +
14456 +#define SET_RDI_INTO_CR3 \
14457 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
14458 +
14459 #endif /* CONFIG_X86_32 */
14460
14461 #endif /* __ASSEMBLY__ */
14462 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
14463 index 142236e..5446ffbc 100644
14464 --- a/arch/x86/include/asm/paravirt_types.h
14465 +++ b/arch/x86/include/asm/paravirt_types.h
14466 @@ -84,7 +84,7 @@ struct pv_init_ops {
14467 */
14468 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
14469 unsigned long addr, unsigned len);
14470 -};
14471 +} __no_const;
14472
14473
14474 struct pv_lazy_ops {
14475 @@ -97,7 +97,7 @@ struct pv_time_ops {
14476 unsigned long long (*sched_clock)(void);
14477 unsigned long long (*steal_clock)(int cpu);
14478 unsigned long (*get_tsc_khz)(void);
14479 -};
14480 +} __no_const;
14481
14482 struct pv_cpu_ops {
14483 /* hooks for various privileged instructions */
14484 @@ -191,7 +191,7 @@ struct pv_cpu_ops {
14485
14486 void (*start_context_switch)(struct task_struct *prev);
14487 void (*end_context_switch)(struct task_struct *next);
14488 -};
14489 +} __no_const;
14490
14491 struct pv_irq_ops {
14492 /*
14493 @@ -222,7 +222,7 @@ struct pv_apic_ops {
14494 unsigned long start_eip,
14495 unsigned long start_esp);
14496 #endif
14497 -};
14498 +} __no_const;
14499
14500 struct pv_mmu_ops {
14501 unsigned long (*read_cr2)(void);
14502 @@ -312,6 +312,7 @@ struct pv_mmu_ops {
14503 struct paravirt_callee_save make_pud;
14504
14505 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
14506 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
14507 #endif /* PAGETABLE_LEVELS == 4 */
14508 #endif /* PAGETABLE_LEVELS >= 3 */
14509
14510 @@ -323,6 +324,12 @@ struct pv_mmu_ops {
14511 an mfn. We can tell which is which from the index. */
14512 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
14513 phys_addr_t phys, pgprot_t flags);
14514 +
14515 +#ifdef CONFIG_PAX_KERNEXEC
14516 + unsigned long (*pax_open_kernel)(void);
14517 + unsigned long (*pax_close_kernel)(void);
14518 +#endif
14519 +
14520 };
14521
14522 struct arch_spinlock;
14523 @@ -333,7 +340,7 @@ struct pv_lock_ops {
14524 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
14525 int (*spin_trylock)(struct arch_spinlock *lock);
14526 void (*spin_unlock)(struct arch_spinlock *lock);
14527 -};
14528 +} __no_const;
14529
14530 /* This contains all the paravirt structures: we get a convenient
14531 * number for each function using the offset which we use to indicate
14532 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
14533 index b4389a4..7024269 100644
14534 --- a/arch/x86/include/asm/pgalloc.h
14535 +++ b/arch/x86/include/asm/pgalloc.h
14536 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
14537 pmd_t *pmd, pte_t *pte)
14538 {
14539 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14540 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
14541 +}
14542 +
14543 +static inline void pmd_populate_user(struct mm_struct *mm,
14544 + pmd_t *pmd, pte_t *pte)
14545 +{
14546 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14547 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
14548 }
14549
14550 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
14551
14552 #ifdef CONFIG_X86_PAE
14553 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
14554 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
14555 +{
14556 + pud_populate(mm, pudp, pmd);
14557 +}
14558 #else /* !CONFIG_X86_PAE */
14559 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14560 {
14561 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14562 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
14563 }
14564 +
14565 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14566 +{
14567 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14568 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
14569 +}
14570 #endif /* CONFIG_X86_PAE */
14571
14572 #if PAGETABLE_LEVELS > 3
14573 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14574 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
14575 }
14576
14577 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14578 +{
14579 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
14580 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
14581 +}
14582 +
14583 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
14584 {
14585 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
14586 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
14587 index f2b489c..4f7e2e5 100644
14588 --- a/arch/x86/include/asm/pgtable-2level.h
14589 +++ b/arch/x86/include/asm/pgtable-2level.h
14590 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
14591
14592 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14593 {
14594 + pax_open_kernel();
14595 *pmdp = pmd;
14596 + pax_close_kernel();
14597 }
14598
14599 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14600 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
14601 index 4cc9f2b..5fd9226 100644
14602 --- a/arch/x86/include/asm/pgtable-3level.h
14603 +++ b/arch/x86/include/asm/pgtable-3level.h
14604 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14605
14606 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14607 {
14608 + pax_open_kernel();
14609 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
14610 + pax_close_kernel();
14611 }
14612
14613 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14614 {
14615 + pax_open_kernel();
14616 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
14617 + pax_close_kernel();
14618 }
14619
14620 /*
14621 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
14622 index 1c1a955..50f828c 100644
14623 --- a/arch/x86/include/asm/pgtable.h
14624 +++ b/arch/x86/include/asm/pgtable.h
14625 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14626
14627 #ifndef __PAGETABLE_PUD_FOLDED
14628 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
14629 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
14630 #define pgd_clear(pgd) native_pgd_clear(pgd)
14631 #endif
14632
14633 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14634
14635 #define arch_end_context_switch(prev) do {} while(0)
14636
14637 +#define pax_open_kernel() native_pax_open_kernel()
14638 +#define pax_close_kernel() native_pax_close_kernel()
14639 #endif /* CONFIG_PARAVIRT */
14640
14641 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
14642 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
14643 +
14644 +#ifdef CONFIG_PAX_KERNEXEC
14645 +static inline unsigned long native_pax_open_kernel(void)
14646 +{
14647 + unsigned long cr0;
14648 +
14649 + preempt_disable();
14650 + barrier();
14651 + cr0 = read_cr0() ^ X86_CR0_WP;
14652 + BUG_ON(cr0 & X86_CR0_WP);
14653 + write_cr0(cr0);
14654 + return cr0 ^ X86_CR0_WP;
14655 +}
14656 +
14657 +static inline unsigned long native_pax_close_kernel(void)
14658 +{
14659 + unsigned long cr0;
14660 +
14661 + cr0 = read_cr0() ^ X86_CR0_WP;
14662 + BUG_ON(!(cr0 & X86_CR0_WP));
14663 + write_cr0(cr0);
14664 + barrier();
14665 + preempt_enable_no_resched();
14666 + return cr0 ^ X86_CR0_WP;
14667 +}
14668 +#else
14669 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
14670 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
14671 +#endif
14672 +
14673 /*
14674 * The following only work if pte_present() is true.
14675 * Undefined behaviour if not..
14676 */
14677 +static inline int pte_user(pte_t pte)
14678 +{
14679 + return pte_val(pte) & _PAGE_USER;
14680 +}
14681 +
14682 static inline int pte_dirty(pte_t pte)
14683 {
14684 return pte_flags(pte) & _PAGE_DIRTY;
14685 @@ -200,9 +240,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
14686 return pte_clear_flags(pte, _PAGE_RW);
14687 }
14688
14689 +static inline pte_t pte_mkread(pte_t pte)
14690 +{
14691 + return __pte(pte_val(pte) | _PAGE_USER);
14692 +}
14693 +
14694 static inline pte_t pte_mkexec(pte_t pte)
14695 {
14696 - return pte_clear_flags(pte, _PAGE_NX);
14697 +#ifdef CONFIG_X86_PAE
14698 + if (__supported_pte_mask & _PAGE_NX)
14699 + return pte_clear_flags(pte, _PAGE_NX);
14700 + else
14701 +#endif
14702 + return pte_set_flags(pte, _PAGE_USER);
14703 +}
14704 +
14705 +static inline pte_t pte_exprotect(pte_t pte)
14706 +{
14707 +#ifdef CONFIG_X86_PAE
14708 + if (__supported_pte_mask & _PAGE_NX)
14709 + return pte_set_flags(pte, _PAGE_NX);
14710 + else
14711 +#endif
14712 + return pte_clear_flags(pte, _PAGE_USER);
14713 }
14714
14715 static inline pte_t pte_mkdirty(pte_t pte)
14716 @@ -394,6 +454,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
14717 #endif
14718
14719 #ifndef __ASSEMBLY__
14720 +
14721 +#ifdef CONFIG_PAX_PER_CPU_PGD
14722 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
14723 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
14724 +{
14725 + return cpu_pgd[cpu];
14726 +}
14727 +#endif
14728 +
14729 #include <linux/mm_types.h>
14730
14731 static inline int pte_none(pte_t pte)
14732 @@ -583,7 +652,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
14733
14734 static inline int pgd_bad(pgd_t pgd)
14735 {
14736 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
14737 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
14738 }
14739
14740 static inline int pgd_none(pgd_t pgd)
14741 @@ -606,7 +675,12 @@ static inline int pgd_none(pgd_t pgd)
14742 * pgd_offset() returns a (pgd_t *)
14743 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
14744 */
14745 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
14746 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
14747 +
14748 +#ifdef CONFIG_PAX_PER_CPU_PGD
14749 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
14750 +#endif
14751 +
14752 /*
14753 * a shortcut which implies the use of the kernel's pgd, instead
14754 * of a process's
14755 @@ -617,6 +691,20 @@ static inline int pgd_none(pgd_t pgd)
14756 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
14757 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
14758
14759 +#ifdef CONFIG_X86_32
14760 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
14761 +#else
14762 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
14763 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
14764 +
14765 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14766 +#define PAX_USER_SHADOW_BASE (_AC(1,UL) << TASK_SIZE_MAX_SHIFT)
14767 +#else
14768 +#define PAX_USER_SHADOW_BASE (_AC(0,UL))
14769 +#endif
14770 +
14771 +#endif
14772 +
14773 #ifndef __ASSEMBLY__
14774
14775 extern int direct_gbpages;
14776 @@ -781,11 +869,23 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
14777 * dst and src can be on the same page, but the range must not overlap,
14778 * and must not cross a page boundary.
14779 */
14780 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
14781 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
14782 {
14783 - memcpy(dst, src, count * sizeof(pgd_t));
14784 + pax_open_kernel();
14785 + while (count--)
14786 + *dst++ = *src++;
14787 + pax_close_kernel();
14788 }
14789
14790 +#ifdef CONFIG_PAX_PER_CPU_PGD
14791 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
14792 +#endif
14793 +
14794 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14795 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
14796 +#else
14797 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
14798 +#endif
14799
14800 #include <asm-generic/pgtable.h>
14801 #endif /* __ASSEMBLY__ */
14802 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
14803 index 8faa215..a8a17ea 100644
14804 --- a/arch/x86/include/asm/pgtable_32.h
14805 +++ b/arch/x86/include/asm/pgtable_32.h
14806 @@ -25,9 +25,6 @@
14807 struct mm_struct;
14808 struct vm_area_struct;
14809
14810 -extern pgd_t swapper_pg_dir[1024];
14811 -extern pgd_t initial_page_table[1024];
14812 -
14813 static inline void pgtable_cache_init(void) { }
14814 static inline void check_pgt_cache(void) { }
14815 void paging_init(void);
14816 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14817 # include <asm/pgtable-2level.h>
14818 #endif
14819
14820 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
14821 +extern pgd_t initial_page_table[PTRS_PER_PGD];
14822 +#ifdef CONFIG_X86_PAE
14823 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
14824 +#endif
14825 +
14826 #if defined(CONFIG_HIGHPTE)
14827 #define pte_offset_map(dir, address) \
14828 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
14829 @@ -62,7 +65,9 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14830 /* Clear a kernel PTE and flush it from the TLB */
14831 #define kpte_clear_flush(ptep, vaddr) \
14832 do { \
14833 + pax_open_kernel(); \
14834 pte_clear(&init_mm, (vaddr), (ptep)); \
14835 + pax_close_kernel(); \
14836 __flush_tlb_one((vaddr)); \
14837 } while (0)
14838
14839 @@ -75,6 +80,9 @@ do { \
14840
14841 #endif /* !__ASSEMBLY__ */
14842
14843 +#define HAVE_ARCH_UNMAPPED_AREA
14844 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
14845 +
14846 /*
14847 * kern_addr_valid() is (1) for FLATMEM and (0) for
14848 * SPARSEMEM and DISCONTIGMEM
14849 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
14850 index ed5903b..c7fe163 100644
14851 --- a/arch/x86/include/asm/pgtable_32_types.h
14852 +++ b/arch/x86/include/asm/pgtable_32_types.h
14853 @@ -8,7 +8,7 @@
14854 */
14855 #ifdef CONFIG_X86_PAE
14856 # include <asm/pgtable-3level_types.h>
14857 -# define PMD_SIZE (1UL << PMD_SHIFT)
14858 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
14859 # define PMD_MASK (~(PMD_SIZE - 1))
14860 #else
14861 # include <asm/pgtable-2level_types.h>
14862 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
14863 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
14864 #endif
14865
14866 +#ifdef CONFIG_PAX_KERNEXEC
14867 +#ifndef __ASSEMBLY__
14868 +extern unsigned char MODULES_EXEC_VADDR[];
14869 +extern unsigned char MODULES_EXEC_END[];
14870 +#endif
14871 +#include <asm/boot.h>
14872 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
14873 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
14874 +#else
14875 +#define ktla_ktva(addr) (addr)
14876 +#define ktva_ktla(addr) (addr)
14877 +#endif
14878 +
14879 #define MODULES_VADDR VMALLOC_START
14880 #define MODULES_END VMALLOC_END
14881 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
14882 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
14883 index 47356f9..deb94a2 100644
14884 --- a/arch/x86/include/asm/pgtable_64.h
14885 +++ b/arch/x86/include/asm/pgtable_64.h
14886 @@ -16,10 +16,14 @@
14887
14888 extern pud_t level3_kernel_pgt[512];
14889 extern pud_t level3_ident_pgt[512];
14890 +extern pud_t level3_vmalloc_start_pgt[512];
14891 +extern pud_t level3_vmalloc_end_pgt[512];
14892 +extern pud_t level3_vmemmap_pgt[512];
14893 +extern pud_t level2_vmemmap_pgt[512];
14894 extern pmd_t level2_kernel_pgt[512];
14895 extern pmd_t level2_fixmap_pgt[512];
14896 -extern pmd_t level2_ident_pgt[512];
14897 -extern pgd_t init_level4_pgt[];
14898 +extern pmd_t level2_ident_pgt[512*2];
14899 +extern pgd_t init_level4_pgt[512];
14900
14901 #define swapper_pg_dir init_level4_pgt
14902
14903 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14904
14905 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14906 {
14907 + pax_open_kernel();
14908 *pmdp = pmd;
14909 + pax_close_kernel();
14910 }
14911
14912 static inline void native_pmd_clear(pmd_t *pmd)
14913 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
14914
14915 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14916 {
14917 + pax_open_kernel();
14918 *pudp = pud;
14919 + pax_close_kernel();
14920 }
14921
14922 static inline void native_pud_clear(pud_t *pud)
14923 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
14924
14925 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
14926 {
14927 + pax_open_kernel();
14928 + *pgdp = pgd;
14929 + pax_close_kernel();
14930 +}
14931 +
14932 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14933 +{
14934 *pgdp = pgd;
14935 }
14936
14937 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
14938 index 766ea16..5b96cb3 100644
14939 --- a/arch/x86/include/asm/pgtable_64_types.h
14940 +++ b/arch/x86/include/asm/pgtable_64_types.h
14941 @@ -59,5 +59,10 @@ typedef struct { pteval_t pte; } pte_t;
14942 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
14943 #define MODULES_END _AC(0xffffffffff000000, UL)
14944 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
14945 +#define MODULES_EXEC_VADDR MODULES_VADDR
14946 +#define MODULES_EXEC_END MODULES_END
14947 +
14948 +#define ktla_ktva(addr) (addr)
14949 +#define ktva_ktla(addr) (addr)
14950
14951 #endif /* _ASM_X86_PGTABLE_64_DEFS_H */
14952 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
14953 index 3c32db8..1ddccf5 100644
14954 --- a/arch/x86/include/asm/pgtable_types.h
14955 +++ b/arch/x86/include/asm/pgtable_types.h
14956 @@ -16,13 +16,12 @@
14957 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
14958 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
14959 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
14960 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
14961 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
14962 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
14963 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
14964 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
14965 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
14966 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
14967 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
14968 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
14969 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
14970 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
14971
14972 /* If _PAGE_BIT_PRESENT is clear, we use these: */
14973 @@ -40,7 +39,6 @@
14974 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
14975 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
14976 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
14977 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
14978 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
14979 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
14980 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
14981 @@ -57,8 +55,10 @@
14982
14983 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
14984 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
14985 -#else
14986 +#elif defined(CONFIG_KMEMCHECK)
14987 #define _PAGE_NX (_AT(pteval_t, 0))
14988 +#else
14989 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
14990 #endif
14991
14992 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
14993 @@ -116,6 +116,9 @@
14994 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
14995 _PAGE_ACCESSED)
14996
14997 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
14998 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
14999 +
15000 #define __PAGE_KERNEL_EXEC \
15001 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
15002 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
15003 @@ -126,7 +129,7 @@
15004 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
15005 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
15006 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
15007 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
15008 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
15009 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
15010 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
15011 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
15012 @@ -188,8 +191,8 @@
15013 * bits are combined, this will alow user to access the high address mapped
15014 * VDSO in the presence of CONFIG_COMPAT_VDSO
15015 */
15016 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
15017 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
15018 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
15019 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
15020 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
15021 #endif
15022
15023 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
15024 {
15025 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
15026 }
15027 +#endif
15028
15029 +#if PAGETABLE_LEVELS == 3
15030 +#include <asm-generic/pgtable-nopud.h>
15031 +#endif
15032 +
15033 +#if PAGETABLE_LEVELS == 2
15034 +#include <asm-generic/pgtable-nopmd.h>
15035 +#endif
15036 +
15037 +#ifndef __ASSEMBLY__
15038 #if PAGETABLE_LEVELS > 3
15039 typedef struct { pudval_t pud; } pud_t;
15040
15041 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
15042 return pud.pud;
15043 }
15044 #else
15045 -#include <asm-generic/pgtable-nopud.h>
15046 -
15047 static inline pudval_t native_pud_val(pud_t pud)
15048 {
15049 return native_pgd_val(pud.pgd);
15050 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
15051 return pmd.pmd;
15052 }
15053 #else
15054 -#include <asm-generic/pgtable-nopmd.h>
15055 -
15056 static inline pmdval_t native_pmd_val(pmd_t pmd)
15057 {
15058 return native_pgd_val(pmd.pud.pgd);
15059 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
15060
15061 extern pteval_t __supported_pte_mask;
15062 extern void set_nx(void);
15063 -extern int nx_enabled;
15064
15065 #define pgprot_writecombine pgprot_writecombine
15066 extern pgprot_t pgprot_writecombine(pgprot_t prot);
15067 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
15068 index 888184b..a07ac89 100644
15069 --- a/arch/x86/include/asm/processor.h
15070 +++ b/arch/x86/include/asm/processor.h
15071 @@ -287,7 +287,7 @@ struct tss_struct {
15072
15073 } ____cacheline_aligned;
15074
15075 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
15076 +extern struct tss_struct init_tss[NR_CPUS];
15077
15078 /*
15079 * Save the original ist values for checking stack pointers during debugging
15080 @@ -827,11 +827,18 @@ static inline void spin_lock_prefetch(const void *x)
15081 */
15082 #define TASK_SIZE PAGE_OFFSET
15083 #define TASK_SIZE_MAX TASK_SIZE
15084 +
15085 +#ifdef CONFIG_PAX_SEGMEXEC
15086 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
15087 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
15088 +#else
15089 #define STACK_TOP TASK_SIZE
15090 -#define STACK_TOP_MAX STACK_TOP
15091 +#endif
15092 +
15093 +#define STACK_TOP_MAX TASK_SIZE
15094
15095 #define INIT_THREAD { \
15096 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
15097 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
15098 .vm86_info = NULL, \
15099 .sysenter_cs = __KERNEL_CS, \
15100 .io_bitmap_ptr = NULL, \
15101 @@ -845,7 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
15102 */
15103 #define INIT_TSS { \
15104 .x86_tss = { \
15105 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
15106 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
15107 .ss0 = __KERNEL_DS, \
15108 .ss1 = __KERNEL_CS, \
15109 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
15110 @@ -856,11 +863,7 @@ static inline void spin_lock_prefetch(const void *x)
15111 extern unsigned long thread_saved_pc(struct task_struct *tsk);
15112
15113 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
15114 -#define KSTK_TOP(info) \
15115 -({ \
15116 - unsigned long *__ptr = (unsigned long *)(info); \
15117 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
15118 -})
15119 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
15120
15121 /*
15122 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
15123 @@ -875,7 +878,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15124 #define task_pt_regs(task) \
15125 ({ \
15126 struct pt_regs *__regs__; \
15127 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
15128 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
15129 __regs__ - 1; \
15130 })
15131
15132 @@ -885,13 +888,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15133 /*
15134 * User space process size. 47bits minus one guard page.
15135 */
15136 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
15137 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
15138
15139 /* This decides where the kernel will search for a free chunk of vm
15140 * space during mmap's.
15141 */
15142 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
15143 - 0xc0000000 : 0xFFFFe000)
15144 + 0xc0000000 : 0xFFFFf000)
15145
15146 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
15147 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
15148 @@ -902,11 +905,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15149 #define STACK_TOP_MAX TASK_SIZE_MAX
15150
15151 #define INIT_THREAD { \
15152 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
15153 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
15154 }
15155
15156 #define INIT_TSS { \
15157 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
15158 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
15159 }
15160
15161 /*
15162 @@ -934,6 +937,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
15163 */
15164 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
15165
15166 +#ifdef CONFIG_PAX_SEGMEXEC
15167 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
15168 +#endif
15169 +
15170 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
15171
15172 /* Get/set a process' ability to use the timestamp counter instruction */
15173 @@ -994,12 +1001,12 @@ extern bool cpu_has_amd_erratum(const int *);
15174 #define cpu_has_amd_erratum(x) (false)
15175 #endif /* CONFIG_CPU_SUP_AMD */
15176
15177 -extern unsigned long arch_align_stack(unsigned long sp);
15178 +#define arch_align_stack(x) ((x) & ~0xfUL)
15179 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
15180
15181 void default_idle(void);
15182 bool set_pm_idle_to_default(void);
15183
15184 -void stop_this_cpu(void *dummy);
15185 +void stop_this_cpu(void *dummy) __noreturn;
15186
15187 #endif /* _ASM_X86_PROCESSOR_H */
15188 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
15189 index 942a086..6c26446 100644
15190 --- a/arch/x86/include/asm/ptrace.h
15191 +++ b/arch/x86/include/asm/ptrace.h
15192 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
15193 }
15194
15195 /*
15196 - * user_mode_vm(regs) determines whether a register set came from user mode.
15197 + * user_mode(regs) determines whether a register set came from user mode.
15198 * This is true if V8086 mode was enabled OR if the register set was from
15199 * protected mode with RPL-3 CS value. This tricky test checks that with
15200 * one comparison. Many places in the kernel can bypass this full check
15201 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
15202 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
15203 + * be used.
15204 */
15205 -static inline int user_mode(struct pt_regs *regs)
15206 +static inline int user_mode_novm(struct pt_regs *regs)
15207 {
15208 #ifdef CONFIG_X86_32
15209 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
15210 #else
15211 - return !!(regs->cs & 3);
15212 + return !!(regs->cs & SEGMENT_RPL_MASK);
15213 #endif
15214 }
15215
15216 -static inline int user_mode_vm(struct pt_regs *regs)
15217 +static inline int user_mode(struct pt_regs *regs)
15218 {
15219 #ifdef CONFIG_X86_32
15220 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
15221 USER_RPL;
15222 #else
15223 - return user_mode(regs);
15224 + return user_mode_novm(regs);
15225 #endif
15226 }
15227
15228 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
15229 #ifdef CONFIG_X86_64
15230 static inline bool user_64bit_mode(struct pt_regs *regs)
15231 {
15232 + unsigned long cs = regs->cs & 0xffff;
15233 #ifndef CONFIG_PARAVIRT
15234 /*
15235 * On non-paravirt systems, this is the only long mode CPL 3
15236 * selector. We do not allow long mode selectors in the LDT.
15237 */
15238 - return regs->cs == __USER_CS;
15239 + return cs == __USER_CS;
15240 #else
15241 /* Headers are too twisted for this to go in paravirt.h. */
15242 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
15243 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
15244 #endif
15245 }
15246
15247 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
15248 * Traps from the kernel do not save sp and ss.
15249 * Use the helper function to retrieve sp.
15250 */
15251 - if (offset == offsetof(struct pt_regs, sp) &&
15252 - regs->cs == __KERNEL_CS)
15253 - return kernel_stack_pointer(regs);
15254 + if (offset == offsetof(struct pt_regs, sp)) {
15255 + unsigned long cs = regs->cs & 0xffff;
15256 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
15257 + return kernel_stack_pointer(regs);
15258 + }
15259 #endif
15260 return *(unsigned long *)((unsigned long)regs + offset);
15261 }
15262 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
15263 index fe1ec5b..dc5c3fe 100644
15264 --- a/arch/x86/include/asm/realmode.h
15265 +++ b/arch/x86/include/asm/realmode.h
15266 @@ -22,16 +22,14 @@ struct real_mode_header {
15267 #endif
15268 /* APM/BIOS reboot */
15269 u32 machine_real_restart_asm;
15270 -#ifdef CONFIG_X86_64
15271 u32 machine_real_restart_seg;
15272 -#endif
15273 };
15274
15275 /* This must match data at trampoline_32/64.S */
15276 struct trampoline_header {
15277 #ifdef CONFIG_X86_32
15278 u32 start;
15279 - u16 gdt_pad;
15280 + u16 boot_cs;
15281 u16 gdt_limit;
15282 u32 gdt_base;
15283 #else
15284 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
15285 index a82c4f1..ac45053 100644
15286 --- a/arch/x86/include/asm/reboot.h
15287 +++ b/arch/x86/include/asm/reboot.h
15288 @@ -6,13 +6,13 @@
15289 struct pt_regs;
15290
15291 struct machine_ops {
15292 - void (*restart)(char *cmd);
15293 - void (*halt)(void);
15294 - void (*power_off)(void);
15295 + void (* __noreturn restart)(char *cmd);
15296 + void (* __noreturn halt)(void);
15297 + void (* __noreturn power_off)(void);
15298 void (*shutdown)(void);
15299 void (*crash_shutdown)(struct pt_regs *);
15300 - void (*emergency_restart)(void);
15301 -};
15302 + void (* __noreturn emergency_restart)(void);
15303 +} __no_const;
15304
15305 extern struct machine_ops machine_ops;
15306
15307 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
15308 index 2dbe4a7..ce1db00 100644
15309 --- a/arch/x86/include/asm/rwsem.h
15310 +++ b/arch/x86/include/asm/rwsem.h
15311 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
15312 {
15313 asm volatile("# beginning down_read\n\t"
15314 LOCK_PREFIX _ASM_INC "(%1)\n\t"
15315 +
15316 +#ifdef CONFIG_PAX_REFCOUNT
15317 + "jno 0f\n"
15318 + LOCK_PREFIX _ASM_DEC "(%1)\n"
15319 + "int $4\n0:\n"
15320 + _ASM_EXTABLE(0b, 0b)
15321 +#endif
15322 +
15323 /* adds 0x00000001 */
15324 " jns 1f\n"
15325 " call call_rwsem_down_read_failed\n"
15326 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
15327 "1:\n\t"
15328 " mov %1,%2\n\t"
15329 " add %3,%2\n\t"
15330 +
15331 +#ifdef CONFIG_PAX_REFCOUNT
15332 + "jno 0f\n"
15333 + "sub %3,%2\n"
15334 + "int $4\n0:\n"
15335 + _ASM_EXTABLE(0b, 0b)
15336 +#endif
15337 +
15338 " jle 2f\n\t"
15339 LOCK_PREFIX " cmpxchg %2,%0\n\t"
15340 " jnz 1b\n\t"
15341 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
15342 long tmp;
15343 asm volatile("# beginning down_write\n\t"
15344 LOCK_PREFIX " xadd %1,(%2)\n\t"
15345 +
15346 +#ifdef CONFIG_PAX_REFCOUNT
15347 + "jno 0f\n"
15348 + "mov %1,(%2)\n"
15349 + "int $4\n0:\n"
15350 + _ASM_EXTABLE(0b, 0b)
15351 +#endif
15352 +
15353 /* adds 0xffff0001, returns the old value */
15354 " test %1,%1\n\t"
15355 /* was the count 0 before? */
15356 @@ -141,6 +165,14 @@ static inline void __up_read(struct rw_semaphore *sem)
15357 long tmp;
15358 asm volatile("# beginning __up_read\n\t"
15359 LOCK_PREFIX " xadd %1,(%2)\n\t"
15360 +
15361 +#ifdef CONFIG_PAX_REFCOUNT
15362 + "jno 0f\n"
15363 + "mov %1,(%2)\n"
15364 + "int $4\n0:\n"
15365 + _ASM_EXTABLE(0b, 0b)
15366 +#endif
15367 +
15368 /* subtracts 1, returns the old value */
15369 " jns 1f\n\t"
15370 " call call_rwsem_wake\n" /* expects old value in %edx */
15371 @@ -159,6 +191,14 @@ static inline void __up_write(struct rw_semaphore *sem)
15372 long tmp;
15373 asm volatile("# beginning __up_write\n\t"
15374 LOCK_PREFIX " xadd %1,(%2)\n\t"
15375 +
15376 +#ifdef CONFIG_PAX_REFCOUNT
15377 + "jno 0f\n"
15378 + "mov %1,(%2)\n"
15379 + "int $4\n0:\n"
15380 + _ASM_EXTABLE(0b, 0b)
15381 +#endif
15382 +
15383 /* subtracts 0xffff0001, returns the old value */
15384 " jns 1f\n\t"
15385 " call call_rwsem_wake\n" /* expects old value in %edx */
15386 @@ -176,6 +216,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15387 {
15388 asm volatile("# beginning __downgrade_write\n\t"
15389 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
15390 +
15391 +#ifdef CONFIG_PAX_REFCOUNT
15392 + "jno 0f\n"
15393 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
15394 + "int $4\n0:\n"
15395 + _ASM_EXTABLE(0b, 0b)
15396 +#endif
15397 +
15398 /*
15399 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
15400 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
15401 @@ -194,7 +242,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15402 */
15403 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15404 {
15405 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
15406 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
15407 +
15408 +#ifdef CONFIG_PAX_REFCOUNT
15409 + "jno 0f\n"
15410 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
15411 + "int $4\n0:\n"
15412 + _ASM_EXTABLE(0b, 0b)
15413 +#endif
15414 +
15415 : "+m" (sem->count)
15416 : "er" (delta));
15417 }
15418 @@ -204,7 +260,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15419 */
15420 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
15421 {
15422 - return delta + xadd(&sem->count, delta);
15423 + return delta + xadd_check_overflow(&sem->count, delta);
15424 }
15425
15426 #endif /* __KERNEL__ */
15427 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
15428 index c48a950..c6d7468 100644
15429 --- a/arch/x86/include/asm/segment.h
15430 +++ b/arch/x86/include/asm/segment.h
15431 @@ -64,10 +64,15 @@
15432 * 26 - ESPFIX small SS
15433 * 27 - per-cpu [ offset to per-cpu data area ]
15434 * 28 - stack_canary-20 [ for stack protector ]
15435 - * 29 - unused
15436 - * 30 - unused
15437 + * 29 - PCI BIOS CS
15438 + * 30 - PCI BIOS DS
15439 * 31 - TSS for double fault handler
15440 */
15441 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
15442 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
15443 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
15444 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
15445 +
15446 #define GDT_ENTRY_TLS_MIN 6
15447 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
15448
15449 @@ -79,6 +84,8 @@
15450
15451 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
15452
15453 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
15454 +
15455 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
15456
15457 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
15458 @@ -104,6 +111,12 @@
15459 #define __KERNEL_STACK_CANARY 0
15460 #endif
15461
15462 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
15463 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
15464 +
15465 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
15466 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
15467 +
15468 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
15469
15470 /*
15471 @@ -141,7 +154,7 @@
15472 */
15473
15474 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
15475 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
15476 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
15477
15478
15479 #else
15480 @@ -165,6 +178,8 @@
15481 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
15482 #define __USER32_DS __USER_DS
15483
15484 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
15485 +
15486 #define GDT_ENTRY_TSS 8 /* needs two entries */
15487 #define GDT_ENTRY_LDT 10 /* needs two entries */
15488 #define GDT_ENTRY_TLS_MIN 12
15489 @@ -185,6 +200,7 @@
15490 #endif
15491
15492 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
15493 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
15494 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
15495 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
15496 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
15497 @@ -265,7 +281,7 @@ static inline unsigned long get_limit(unsigned long segment)
15498 {
15499 unsigned long __limit;
15500 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
15501 - return __limit + 1;
15502 + return __limit;
15503 }
15504
15505 #endif /* !__ASSEMBLY__ */
15506 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
15507 index b073aae..39f9bdd 100644
15508 --- a/arch/x86/include/asm/smp.h
15509 +++ b/arch/x86/include/asm/smp.h
15510 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
15511 /* cpus sharing the last level cache: */
15512 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
15513 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
15514 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
15515 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
15516
15517 static inline struct cpumask *cpu_sibling_mask(int cpu)
15518 {
15519 @@ -79,7 +79,7 @@ struct smp_ops {
15520
15521 void (*send_call_func_ipi)(const struct cpumask *mask);
15522 void (*send_call_func_single_ipi)(int cpu);
15523 -};
15524 +} __no_const;
15525
15526 /* Globals due to paravirt */
15527 extern void set_cpu_sibling_map(int cpu);
15528 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
15529 extern int safe_smp_processor_id(void);
15530
15531 #elif defined(CONFIG_X86_64_SMP)
15532 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15533 -
15534 -#define stack_smp_processor_id() \
15535 -({ \
15536 - struct thread_info *ti; \
15537 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
15538 - ti->cpu; \
15539 -})
15540 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15541 +#define stack_smp_processor_id() raw_smp_processor_id()
15542 #define safe_smp_processor_id() smp_processor_id()
15543
15544 #endif
15545 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
15546 index 33692ea..350a534 100644
15547 --- a/arch/x86/include/asm/spinlock.h
15548 +++ b/arch/x86/include/asm/spinlock.h
15549 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
15550 static inline void arch_read_lock(arch_rwlock_t *rw)
15551 {
15552 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
15553 +
15554 +#ifdef CONFIG_PAX_REFCOUNT
15555 + "jno 0f\n"
15556 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
15557 + "int $4\n0:\n"
15558 + _ASM_EXTABLE(0b, 0b)
15559 +#endif
15560 +
15561 "jns 1f\n"
15562 "call __read_lock_failed\n\t"
15563 "1:\n"
15564 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
15565 static inline void arch_write_lock(arch_rwlock_t *rw)
15566 {
15567 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
15568 +
15569 +#ifdef CONFIG_PAX_REFCOUNT
15570 + "jno 0f\n"
15571 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
15572 + "int $4\n0:\n"
15573 + _ASM_EXTABLE(0b, 0b)
15574 +#endif
15575 +
15576 "jz 1f\n"
15577 "call __write_lock_failed\n\t"
15578 "1:\n"
15579 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
15580
15581 static inline void arch_read_unlock(arch_rwlock_t *rw)
15582 {
15583 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
15584 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
15585 +
15586 +#ifdef CONFIG_PAX_REFCOUNT
15587 + "jno 0f\n"
15588 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
15589 + "int $4\n0:\n"
15590 + _ASM_EXTABLE(0b, 0b)
15591 +#endif
15592 +
15593 :"+m" (rw->lock) : : "memory");
15594 }
15595
15596 static inline void arch_write_unlock(arch_rwlock_t *rw)
15597 {
15598 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
15599 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
15600 +
15601 +#ifdef CONFIG_PAX_REFCOUNT
15602 + "jno 0f\n"
15603 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
15604 + "int $4\n0:\n"
15605 + _ASM_EXTABLE(0b, 0b)
15606 +#endif
15607 +
15608 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
15609 }
15610
15611 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
15612 index 6a99859..03cb807 100644
15613 --- a/arch/x86/include/asm/stackprotector.h
15614 +++ b/arch/x86/include/asm/stackprotector.h
15615 @@ -47,7 +47,7 @@
15616 * head_32 for boot CPU and setup_per_cpu_areas() for others.
15617 */
15618 #define GDT_STACK_CANARY_INIT \
15619 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
15620 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
15621
15622 /*
15623 * Initialize the stackprotector canary value.
15624 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
15625
15626 static inline void load_stack_canary_segment(void)
15627 {
15628 -#ifdef CONFIG_X86_32
15629 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
15630 asm volatile ("mov %0, %%gs" : : "r" (0));
15631 #endif
15632 }
15633 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
15634 index 70bbe39..4ae2bd4 100644
15635 --- a/arch/x86/include/asm/stacktrace.h
15636 +++ b/arch/x86/include/asm/stacktrace.h
15637 @@ -11,28 +11,20 @@
15638
15639 extern int kstack_depth_to_print;
15640
15641 -struct thread_info;
15642 +struct task_struct;
15643 struct stacktrace_ops;
15644
15645 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
15646 - unsigned long *stack,
15647 - unsigned long bp,
15648 - const struct stacktrace_ops *ops,
15649 - void *data,
15650 - unsigned long *end,
15651 - int *graph);
15652 +typedef unsigned long walk_stack_t(struct task_struct *task,
15653 + void *stack_start,
15654 + unsigned long *stack,
15655 + unsigned long bp,
15656 + const struct stacktrace_ops *ops,
15657 + void *data,
15658 + unsigned long *end,
15659 + int *graph);
15660
15661 -extern unsigned long
15662 -print_context_stack(struct thread_info *tinfo,
15663 - unsigned long *stack, unsigned long bp,
15664 - const struct stacktrace_ops *ops, void *data,
15665 - unsigned long *end, int *graph);
15666 -
15667 -extern unsigned long
15668 -print_context_stack_bp(struct thread_info *tinfo,
15669 - unsigned long *stack, unsigned long bp,
15670 - const struct stacktrace_ops *ops, void *data,
15671 - unsigned long *end, int *graph);
15672 +extern walk_stack_t print_context_stack;
15673 +extern walk_stack_t print_context_stack_bp;
15674
15675 /* Generic stack tracer with callbacks */
15676
15677 @@ -40,7 +32,7 @@ struct stacktrace_ops {
15678 void (*address)(void *data, unsigned long address, int reliable);
15679 /* On negative return stop dumping */
15680 int (*stack)(void *data, char *name);
15681 - walk_stack_t walk_stack;
15682 + walk_stack_t *walk_stack;
15683 };
15684
15685 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
15686 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
15687 index 4ec45b3..a4f0a8a 100644
15688 --- a/arch/x86/include/asm/switch_to.h
15689 +++ b/arch/x86/include/asm/switch_to.h
15690 @@ -108,7 +108,7 @@ do { \
15691 "call __switch_to\n\t" \
15692 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
15693 __switch_canary \
15694 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
15695 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
15696 "movq %%rax,%%rdi\n\t" \
15697 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
15698 "jnz ret_from_fork\n\t" \
15699 @@ -119,7 +119,7 @@ do { \
15700 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
15701 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
15702 [_tif_fork] "i" (_TIF_FORK), \
15703 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
15704 + [thread_info] "m" (current_tinfo), \
15705 [current_task] "m" (current_task) \
15706 __switch_canary_iparam \
15707 : "memory", "cc" __EXTRA_CLOBBER)
15708 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
15709 index 2d946e6..e453ec4 100644
15710 --- a/arch/x86/include/asm/thread_info.h
15711 +++ b/arch/x86/include/asm/thread_info.h
15712 @@ -10,6 +10,7 @@
15713 #include <linux/compiler.h>
15714 #include <asm/page.h>
15715 #include <asm/types.h>
15716 +#include <asm/percpu.h>
15717
15718 /*
15719 * low level task data that entry.S needs immediate access to
15720 @@ -24,7 +25,6 @@ struct exec_domain;
15721 #include <linux/atomic.h>
15722
15723 struct thread_info {
15724 - struct task_struct *task; /* main task structure */
15725 struct exec_domain *exec_domain; /* execution domain */
15726 __u32 flags; /* low level flags */
15727 __u32 status; /* thread synchronous flags */
15728 @@ -34,19 +34,13 @@ struct thread_info {
15729 mm_segment_t addr_limit;
15730 struct restart_block restart_block;
15731 void __user *sysenter_return;
15732 -#ifdef CONFIG_X86_32
15733 - unsigned long previous_esp; /* ESP of the previous stack in
15734 - case of nested (IRQ) stacks
15735 - */
15736 - __u8 supervisor_stack[0];
15737 -#endif
15738 + unsigned long lowest_stack;
15739 unsigned int sig_on_uaccess_error:1;
15740 unsigned int uaccess_err:1; /* uaccess failed */
15741 };
15742
15743 -#define INIT_THREAD_INFO(tsk) \
15744 +#define INIT_THREAD_INFO \
15745 { \
15746 - .task = &tsk, \
15747 .exec_domain = &default_exec_domain, \
15748 .flags = 0, \
15749 .cpu = 0, \
15750 @@ -57,7 +51,7 @@ struct thread_info {
15751 }, \
15752 }
15753
15754 -#define init_thread_info (init_thread_union.thread_info)
15755 +#define init_thread_info (init_thread_union.stack)
15756 #define init_stack (init_thread_union.stack)
15757
15758 #else /* !__ASSEMBLY__ */
15759 @@ -98,6 +92,7 @@ struct thread_info {
15760 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
15761 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
15762 #define TIF_X32 30 /* 32-bit native x86-64 binary */
15763 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
15764
15765 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
15766 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
15767 @@ -122,17 +117,18 @@ struct thread_info {
15768 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
15769 #define _TIF_ADDR32 (1 << TIF_ADDR32)
15770 #define _TIF_X32 (1 << TIF_X32)
15771 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
15772
15773 /* work to do in syscall_trace_enter() */
15774 #define _TIF_WORK_SYSCALL_ENTRY \
15775 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
15776 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
15777 - _TIF_NOHZ)
15778 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15779
15780 /* work to do in syscall_trace_leave() */
15781 #define _TIF_WORK_SYSCALL_EXIT \
15782 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
15783 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
15784 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
15785
15786 /* work to do on interrupt/exception return */
15787 #define _TIF_WORK_MASK \
15788 @@ -143,7 +139,7 @@ struct thread_info {
15789 /* work to do on any return to user space */
15790 #define _TIF_ALLWORK_MASK \
15791 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
15792 - _TIF_NOHZ)
15793 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15794
15795 /* Only used for 64 bit */
15796 #define _TIF_DO_NOTIFY_MASK \
15797 @@ -159,45 +155,40 @@ struct thread_info {
15798
15799 #define PREEMPT_ACTIVE 0x10000000
15800
15801 -#ifdef CONFIG_X86_32
15802 -
15803 -#define STACK_WARN (THREAD_SIZE/8)
15804 -/*
15805 - * macros/functions for gaining access to the thread information structure
15806 - *
15807 - * preempt_count needs to be 1 initially, until the scheduler is functional.
15808 - */
15809 -#ifndef __ASSEMBLY__
15810 -
15811 -
15812 -/* how to get the current stack pointer from C */
15813 -register unsigned long current_stack_pointer asm("esp") __used;
15814 -
15815 -/* how to get the thread information struct from C */
15816 -static inline struct thread_info *current_thread_info(void)
15817 -{
15818 - return (struct thread_info *)
15819 - (current_stack_pointer & ~(THREAD_SIZE - 1));
15820 -}
15821 -
15822 -#else /* !__ASSEMBLY__ */
15823 -
15824 +#ifdef __ASSEMBLY__
15825 /* how to get the thread information struct from ASM */
15826 #define GET_THREAD_INFO(reg) \
15827 - movl $-THREAD_SIZE, reg; \
15828 - andl %esp, reg
15829 + mov PER_CPU_VAR(current_tinfo), reg
15830
15831 /* use this one if reg already contains %esp */
15832 -#define GET_THREAD_INFO_WITH_ESP(reg) \
15833 - andl $-THREAD_SIZE, reg
15834 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
15835 +#else
15836 +/* how to get the thread information struct from C */
15837 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
15838 +
15839 +static __always_inline struct thread_info *current_thread_info(void)
15840 +{
15841 + return this_cpu_read_stable(current_tinfo);
15842 +}
15843 +#endif
15844 +
15845 +#ifdef CONFIG_X86_32
15846 +
15847 +#define STACK_WARN (THREAD_SIZE/8)
15848 +/*
15849 + * macros/functions for gaining access to the thread information structure
15850 + *
15851 + * preempt_count needs to be 1 initially, until the scheduler is functional.
15852 + */
15853 +#ifndef __ASSEMBLY__
15854 +
15855 +/* how to get the current stack pointer from C */
15856 +register unsigned long current_stack_pointer asm("esp") __used;
15857
15858 #endif
15859
15860 #else /* X86_32 */
15861
15862 -#include <asm/percpu.h>
15863 -#define KERNEL_STACK_OFFSET (5*8)
15864 -
15865 /*
15866 * macros/functions for gaining access to the thread information structure
15867 * preempt_count needs to be 1 initially, until the scheduler is functional.
15868 @@ -205,27 +196,8 @@ static inline struct thread_info *current_thread_info(void)
15869 #ifndef __ASSEMBLY__
15870 DECLARE_PER_CPU(unsigned long, kernel_stack);
15871
15872 -static inline struct thread_info *current_thread_info(void)
15873 -{
15874 - struct thread_info *ti;
15875 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
15876 - KERNEL_STACK_OFFSET - THREAD_SIZE);
15877 - return ti;
15878 -}
15879 -
15880 -#else /* !__ASSEMBLY__ */
15881 -
15882 -/* how to get the thread information struct from ASM */
15883 -#define GET_THREAD_INFO(reg) \
15884 - movq PER_CPU_VAR(kernel_stack),reg ; \
15885 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
15886 -
15887 -/*
15888 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
15889 - * a certain register (to be used in assembler memory operands).
15890 - */
15891 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
15892 -
15893 +/* how to get the current stack pointer from C */
15894 +register unsigned long current_stack_pointer asm("rsp") __used;
15895 #endif
15896
15897 #endif /* !X86_32 */
15898 @@ -286,5 +258,12 @@ static inline bool is_ia32_task(void)
15899 extern void arch_task_cache_init(void);
15900 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
15901 extern void arch_release_task_struct(struct task_struct *tsk);
15902 +
15903 +#define __HAVE_THREAD_FUNCTIONS
15904 +#define task_thread_info(task) (&(task)->tinfo)
15905 +#define task_stack_page(task) ((task)->stack)
15906 +#define setup_thread_stack(p, org) do {} while (0)
15907 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
15908 +
15909 #endif
15910 #endif /* _ASM_X86_THREAD_INFO_H */
15911 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
15912 index 1709801..0a60f2f 100644
15913 --- a/arch/x86/include/asm/uaccess.h
15914 +++ b/arch/x86/include/asm/uaccess.h
15915 @@ -7,6 +7,7 @@
15916 #include <linux/compiler.h>
15917 #include <linux/thread_info.h>
15918 #include <linux/string.h>
15919 +#include <linux/sched.h>
15920 #include <asm/asm.h>
15921 #include <asm/page.h>
15922 #include <asm/smap.h>
15923 @@ -29,7 +30,12 @@
15924
15925 #define get_ds() (KERNEL_DS)
15926 #define get_fs() (current_thread_info()->addr_limit)
15927 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15928 +void __set_fs(mm_segment_t x);
15929 +void set_fs(mm_segment_t x);
15930 +#else
15931 #define set_fs(x) (current_thread_info()->addr_limit = (x))
15932 +#endif
15933
15934 #define segment_eq(a, b) ((a).seg == (b).seg)
15935
15936 @@ -77,8 +83,33 @@
15937 * checks that the pointer is in the user space range - after calling
15938 * this function, memory access functions may still return -EFAULT.
15939 */
15940 -#define access_ok(type, addr, size) \
15941 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15942 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15943 +#define access_ok(type, addr, size) \
15944 +({ \
15945 + long __size = size; \
15946 + unsigned long __addr = (unsigned long)addr; \
15947 + unsigned long __addr_ao = __addr & PAGE_MASK; \
15948 + unsigned long __end_ao = __addr + __size - 1; \
15949 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
15950 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
15951 + while(__addr_ao <= __end_ao) { \
15952 + char __c_ao; \
15953 + __addr_ao += PAGE_SIZE; \
15954 + if (__size > PAGE_SIZE) \
15955 + cond_resched(); \
15956 + if (__get_user(__c_ao, (char __user *)__addr)) \
15957 + break; \
15958 + if (type != VERIFY_WRITE) { \
15959 + __addr = __addr_ao; \
15960 + continue; \
15961 + } \
15962 + if (__put_user(__c_ao, (char __user *)__addr)) \
15963 + break; \
15964 + __addr = __addr_ao; \
15965 + } \
15966 + } \
15967 + __ret_ao; \
15968 +})
15969
15970 /*
15971 * The exception table consists of pairs of addresses relative to the
15972 @@ -189,13 +220,21 @@ extern int __get_user_bad(void);
15973 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
15974 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
15975
15976 -
15977 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15978 +#define __copyuser_seg "gs;"
15979 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
15980 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
15981 +#else
15982 +#define __copyuser_seg
15983 +#define __COPYUSER_SET_ES
15984 +#define __COPYUSER_RESTORE_ES
15985 +#endif
15986
15987 #ifdef CONFIG_X86_32
15988 #define __put_user_asm_u64(x, addr, err, errret) \
15989 asm volatile(ASM_STAC "\n" \
15990 - "1: movl %%eax,0(%2)\n" \
15991 - "2: movl %%edx,4(%2)\n" \
15992 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
15993 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
15994 "3: " ASM_CLAC "\n" \
15995 ".section .fixup,\"ax\"\n" \
15996 "4: movl %3,%0\n" \
15997 @@ -208,8 +247,8 @@ extern int __get_user_bad(void);
15998
15999 #define __put_user_asm_ex_u64(x, addr) \
16000 asm volatile(ASM_STAC "\n" \
16001 - "1: movl %%eax,0(%1)\n" \
16002 - "2: movl %%edx,4(%1)\n" \
16003 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
16004 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
16005 "3: " ASM_CLAC "\n" \
16006 _ASM_EXTABLE_EX(1b, 2b) \
16007 _ASM_EXTABLE_EX(2b, 3b) \
16008 @@ -259,7 +298,7 @@ extern void __put_user_8(void);
16009 __typeof__(*(ptr)) __pu_val; \
16010 __chk_user_ptr(ptr); \
16011 might_fault(); \
16012 - __pu_val = x; \
16013 + __pu_val = (x); \
16014 switch (sizeof(*(ptr))) { \
16015 case 1: \
16016 __put_user_x(1, __pu_val, ptr, __ret_pu); \
16017 @@ -358,7 +397,7 @@ do { \
16018
16019 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
16020 asm volatile(ASM_STAC "\n" \
16021 - "1: mov"itype" %2,%"rtype"1\n" \
16022 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
16023 "2: " ASM_CLAC "\n" \
16024 ".section .fixup,\"ax\"\n" \
16025 "3: mov %3,%0\n" \
16026 @@ -366,7 +405,7 @@ do { \
16027 " jmp 2b\n" \
16028 ".previous\n" \
16029 _ASM_EXTABLE(1b, 3b) \
16030 - : "=r" (err), ltype(x) \
16031 + : "=r" (err), ltype (x) \
16032 : "m" (__m(addr)), "i" (errret), "0" (err))
16033
16034 #define __get_user_size_ex(x, ptr, size) \
16035 @@ -391,7 +430,7 @@ do { \
16036 } while (0)
16037
16038 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
16039 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
16040 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
16041 "2:\n" \
16042 _ASM_EXTABLE_EX(1b, 2b) \
16043 : ltype(x) : "m" (__m(addr)))
16044 @@ -408,13 +447,24 @@ do { \
16045 int __gu_err; \
16046 unsigned long __gu_val; \
16047 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
16048 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
16049 + (x) = (__typeof__(*(ptr)))__gu_val; \
16050 __gu_err; \
16051 })
16052
16053 /* FIXME: this hack is definitely wrong -AK */
16054 struct __large_struct { unsigned long buf[100]; };
16055 -#define __m(x) (*(struct __large_struct __user *)(x))
16056 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16057 +#define ____m(x) \
16058 +({ \
16059 + unsigned long ____x = (unsigned long)(x); \
16060 + if (____x < PAX_USER_SHADOW_BASE) \
16061 + ____x += PAX_USER_SHADOW_BASE; \
16062 + (void __user *)____x; \
16063 +})
16064 +#else
16065 +#define ____m(x) (x)
16066 +#endif
16067 +#define __m(x) (*(struct __large_struct __user *)____m(x))
16068
16069 /*
16070 * Tell gcc we read from memory instead of writing: this is because
16071 @@ -423,7 +473,7 @@ struct __large_struct { unsigned long buf[100]; };
16072 */
16073 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
16074 asm volatile(ASM_STAC "\n" \
16075 - "1: mov"itype" %"rtype"1,%2\n" \
16076 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
16077 "2: " ASM_CLAC "\n" \
16078 ".section .fixup,\"ax\"\n" \
16079 "3: mov %3,%0\n" \
16080 @@ -431,10 +481,10 @@ struct __large_struct { unsigned long buf[100]; };
16081 ".previous\n" \
16082 _ASM_EXTABLE(1b, 3b) \
16083 : "=r"(err) \
16084 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
16085 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
16086
16087 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
16088 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
16089 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
16090 "2:\n" \
16091 _ASM_EXTABLE_EX(1b, 2b) \
16092 : : ltype(x), "m" (__m(addr)))
16093 @@ -473,8 +523,12 @@ struct __large_struct { unsigned long buf[100]; };
16094 * On error, the variable @x is set to zero.
16095 */
16096
16097 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16098 +#define __get_user(x, ptr) get_user((x), (ptr))
16099 +#else
16100 #define __get_user(x, ptr) \
16101 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
16102 +#endif
16103
16104 /**
16105 * __put_user: - Write a simple value into user space, with less checking.
16106 @@ -496,8 +550,12 @@ struct __large_struct { unsigned long buf[100]; };
16107 * Returns zero on success, or -EFAULT on error.
16108 */
16109
16110 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16111 +#define __put_user(x, ptr) put_user((x), (ptr))
16112 +#else
16113 #define __put_user(x, ptr) \
16114 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
16115 +#endif
16116
16117 #define __get_user_unaligned __get_user
16118 #define __put_user_unaligned __put_user
16119 @@ -515,7 +573,7 @@ struct __large_struct { unsigned long buf[100]; };
16120 #define get_user_ex(x, ptr) do { \
16121 unsigned long __gue_val; \
16122 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
16123 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
16124 + (x) = (__typeof__(*(ptr)))__gue_val; \
16125 } while (0)
16126
16127 #define put_user_try uaccess_try
16128 @@ -532,8 +590,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
16129 extern __must_check long strlen_user(const char __user *str);
16130 extern __must_check long strnlen_user(const char __user *str, long n);
16131
16132 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
16133 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
16134 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
16135 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
16136
16137 /*
16138 * movsl can be slow when source and dest are not both 8-byte aligned
16139 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
16140 index 7f760a9..04b1c65 100644
16141 --- a/arch/x86/include/asm/uaccess_32.h
16142 +++ b/arch/x86/include/asm/uaccess_32.h
16143 @@ -11,15 +11,15 @@
16144 #include <asm/page.h>
16145
16146 unsigned long __must_check __copy_to_user_ll
16147 - (void __user *to, const void *from, unsigned long n);
16148 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
16149 unsigned long __must_check __copy_from_user_ll
16150 - (void *to, const void __user *from, unsigned long n);
16151 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16152 unsigned long __must_check __copy_from_user_ll_nozero
16153 - (void *to, const void __user *from, unsigned long n);
16154 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16155 unsigned long __must_check __copy_from_user_ll_nocache
16156 - (void *to, const void __user *from, unsigned long n);
16157 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16158 unsigned long __must_check __copy_from_user_ll_nocache_nozero
16159 - (void *to, const void __user *from, unsigned long n);
16160 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16161
16162 /**
16163 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
16164 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
16165 static __always_inline unsigned long __must_check
16166 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
16167 {
16168 + if ((long)n < 0)
16169 + return n;
16170 +
16171 + check_object_size(from, n, true);
16172 +
16173 if (__builtin_constant_p(n)) {
16174 unsigned long ret;
16175
16176 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
16177 __copy_to_user(void __user *to, const void *from, unsigned long n)
16178 {
16179 might_fault();
16180 +
16181 return __copy_to_user_inatomic(to, from, n);
16182 }
16183
16184 static __always_inline unsigned long
16185 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
16186 {
16187 + if ((long)n < 0)
16188 + return n;
16189 +
16190 /* Avoid zeroing the tail if the copy fails..
16191 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
16192 * but as the zeroing behaviour is only significant when n is not
16193 @@ -137,6 +146,12 @@ static __always_inline unsigned long
16194 __copy_from_user(void *to, const void __user *from, unsigned long n)
16195 {
16196 might_fault();
16197 +
16198 + if ((long)n < 0)
16199 + return n;
16200 +
16201 + check_object_size(to, n, false);
16202 +
16203 if (__builtin_constant_p(n)) {
16204 unsigned long ret;
16205
16206 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
16207 const void __user *from, unsigned long n)
16208 {
16209 might_fault();
16210 +
16211 + if ((long)n < 0)
16212 + return n;
16213 +
16214 if (__builtin_constant_p(n)) {
16215 unsigned long ret;
16216
16217 @@ -181,15 +200,19 @@ static __always_inline unsigned long
16218 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
16219 unsigned long n)
16220 {
16221 - return __copy_from_user_ll_nocache_nozero(to, from, n);
16222 + if ((long)n < 0)
16223 + return n;
16224 +
16225 + return __copy_from_user_ll_nocache_nozero(to, from, n);
16226 }
16227
16228 -unsigned long __must_check copy_to_user(void __user *to,
16229 - const void *from, unsigned long n);
16230 -unsigned long __must_check _copy_from_user(void *to,
16231 - const void __user *from,
16232 - unsigned long n);
16233 -
16234 +extern void copy_to_user_overflow(void)
16235 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16236 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16237 +#else
16238 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16239 +#endif
16240 +;
16241
16242 extern void copy_from_user_overflow(void)
16243 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16244 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
16245 #endif
16246 ;
16247
16248 -static inline unsigned long __must_check copy_from_user(void *to,
16249 - const void __user *from,
16250 - unsigned long n)
16251 +/**
16252 + * copy_to_user: - Copy a block of data into user space.
16253 + * @to: Destination address, in user space.
16254 + * @from: Source address, in kernel space.
16255 + * @n: Number of bytes to copy.
16256 + *
16257 + * Context: User context only. This function may sleep.
16258 + *
16259 + * Copy data from kernel space to user space.
16260 + *
16261 + * Returns number of bytes that could not be copied.
16262 + * On success, this will be zero.
16263 + */
16264 +static inline unsigned long __must_check
16265 +copy_to_user(void __user *to, const void *from, unsigned long n)
16266 {
16267 - int sz = __compiletime_object_size(to);
16268 + size_t sz = __compiletime_object_size(from);
16269
16270 - if (likely(sz == -1 || sz >= n))
16271 - n = _copy_from_user(to, from, n);
16272 - else
16273 + if (unlikely(sz != (size_t)-1 && sz < n))
16274 + copy_to_user_overflow();
16275 + else if (access_ok(VERIFY_WRITE, to, n))
16276 + n = __copy_to_user(to, from, n);
16277 + return n;
16278 +}
16279 +
16280 +/**
16281 + * copy_from_user: - Copy a block of data from user space.
16282 + * @to: Destination address, in kernel space.
16283 + * @from: Source address, in user space.
16284 + * @n: Number of bytes to copy.
16285 + *
16286 + * Context: User context only. This function may sleep.
16287 + *
16288 + * Copy data from user space to kernel space.
16289 + *
16290 + * Returns number of bytes that could not be copied.
16291 + * On success, this will be zero.
16292 + *
16293 + * If some data could not be copied, this function will pad the copied
16294 + * data to the requested size using zero bytes.
16295 + */
16296 +static inline unsigned long __must_check
16297 +copy_from_user(void *to, const void __user *from, unsigned long n)
16298 +{
16299 + size_t sz = __compiletime_object_size(to);
16300 +
16301 + check_object_size(to, n, false);
16302 +
16303 + if (unlikely(sz != (size_t)-1 && sz < n))
16304 copy_from_user_overflow();
16305 -
16306 + else if (access_ok(VERIFY_READ, from, n))
16307 + n = __copy_from_user(to, from, n);
16308 + else if ((long)n > 0)
16309 + memset(to, 0, n);
16310 return n;
16311 }
16312
16313 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
16314 index 142810c..1f2a0a7 100644
16315 --- a/arch/x86/include/asm/uaccess_64.h
16316 +++ b/arch/x86/include/asm/uaccess_64.h
16317 @@ -10,6 +10,9 @@
16318 #include <asm/alternative.h>
16319 #include <asm/cpufeature.h>
16320 #include <asm/page.h>
16321 +#include <asm/pgtable.h>
16322 +
16323 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
16324
16325 /*
16326 * Copy To/From Userspace
16327 @@ -17,13 +20,13 @@
16328
16329 /* Handles exceptions in both to and from, but doesn't do access_ok */
16330 __must_check unsigned long
16331 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
16332 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
16333 __must_check unsigned long
16334 -copy_user_generic_string(void *to, const void *from, unsigned len);
16335 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
16336 __must_check unsigned long
16337 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
16338 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
16339
16340 -static __always_inline __must_check unsigned long
16341 +static __always_inline __must_check __size_overflow(3) unsigned long
16342 copy_user_generic(void *to, const void *from, unsigned len)
16343 {
16344 unsigned ret;
16345 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
16346 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
16347 "=d" (len)),
16348 "1" (to), "2" (from), "3" (len)
16349 - : "memory", "rcx", "r8", "r9", "r10", "r11");
16350 + : "memory", "rcx", "r8", "r9", "r11");
16351 return ret;
16352 }
16353
16354 +static __always_inline __must_check unsigned long
16355 +__copy_to_user(void __user *to, const void *from, unsigned long len);
16356 +static __always_inline __must_check unsigned long
16357 +__copy_from_user(void *to, const void __user *from, unsigned long len);
16358 __must_check unsigned long
16359 -_copy_to_user(void __user *to, const void *from, unsigned len);
16360 -__must_check unsigned long
16361 -_copy_from_user(void *to, const void __user *from, unsigned len);
16362 -__must_check unsigned long
16363 -copy_in_user(void __user *to, const void __user *from, unsigned len);
16364 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
16365 +
16366 +extern void copy_to_user_overflow(void)
16367 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16368 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16369 +#else
16370 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16371 +#endif
16372 +;
16373 +
16374 +extern void copy_from_user_overflow(void)
16375 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16376 + __compiletime_error("copy_from_user() buffer size is not provably correct")
16377 +#else
16378 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
16379 +#endif
16380 +;
16381
16382 static inline unsigned long __must_check copy_from_user(void *to,
16383 const void __user *from,
16384 unsigned long n)
16385 {
16386 - int sz = __compiletime_object_size(to);
16387 -
16388 might_fault();
16389 - if (likely(sz == -1 || sz >= n))
16390 - n = _copy_from_user(to, from, n);
16391 -#ifdef CONFIG_DEBUG_VM
16392 - else
16393 - WARN(1, "Buffer overflow detected!\n");
16394 -#endif
16395 +
16396 + check_object_size(to, n, false);
16397 +
16398 + if (access_ok(VERIFY_READ, from, n))
16399 + n = __copy_from_user(to, from, n);
16400 + else if (n < INT_MAX)
16401 + memset(to, 0, n);
16402 return n;
16403 }
16404
16405 static __always_inline __must_check
16406 -int copy_to_user(void __user *dst, const void *src, unsigned size)
16407 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
16408 {
16409 might_fault();
16410
16411 - return _copy_to_user(dst, src, size);
16412 + if (access_ok(VERIFY_WRITE, dst, size))
16413 + size = __copy_to_user(dst, src, size);
16414 + return size;
16415 }
16416
16417 static __always_inline __must_check
16418 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
16419 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
16420 {
16421 - int ret = 0;
16422 + size_t sz = __compiletime_object_size(dst);
16423 + unsigned ret = 0;
16424
16425 might_fault();
16426 +
16427 + if (size > INT_MAX)
16428 + return size;
16429 +
16430 + check_object_size(dst, size, false);
16431 +
16432 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16433 + if (!__access_ok(VERIFY_READ, src, size))
16434 + return size;
16435 +#endif
16436 +
16437 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16438 + copy_from_user_overflow();
16439 + return size;
16440 + }
16441 +
16442 if (!__builtin_constant_p(size))
16443 - return copy_user_generic(dst, (__force void *)src, size);
16444 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16445 switch (size) {
16446 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
16447 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
16448 ret, "b", "b", "=q", 1);
16449 return ret;
16450 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
16451 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
16452 ret, "w", "w", "=r", 2);
16453 return ret;
16454 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
16455 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
16456 ret, "l", "k", "=r", 4);
16457 return ret;
16458 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
16459 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16460 ret, "q", "", "=r", 8);
16461 return ret;
16462 case 10:
16463 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16464 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16465 ret, "q", "", "=r", 10);
16466 if (unlikely(ret))
16467 return ret;
16468 __get_user_asm(*(u16 *)(8 + (char *)dst),
16469 - (u16 __user *)(8 + (char __user *)src),
16470 + (const u16 __user *)(8 + (const char __user *)src),
16471 ret, "w", "w", "=r", 2);
16472 return ret;
16473 case 16:
16474 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16475 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16476 ret, "q", "", "=r", 16);
16477 if (unlikely(ret))
16478 return ret;
16479 __get_user_asm(*(u64 *)(8 + (char *)dst),
16480 - (u64 __user *)(8 + (char __user *)src),
16481 + (const u64 __user *)(8 + (const char __user *)src),
16482 ret, "q", "", "=r", 8);
16483 return ret;
16484 default:
16485 - return copy_user_generic(dst, (__force void *)src, size);
16486 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16487 }
16488 }
16489
16490 static __always_inline __must_check
16491 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
16492 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
16493 {
16494 - int ret = 0;
16495 + size_t sz = __compiletime_object_size(src);
16496 + unsigned ret = 0;
16497
16498 might_fault();
16499 +
16500 + if (size > INT_MAX)
16501 + return size;
16502 +
16503 + check_object_size(src, size, true);
16504 +
16505 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16506 + if (!__access_ok(VERIFY_WRITE, dst, size))
16507 + return size;
16508 +#endif
16509 +
16510 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16511 + copy_to_user_overflow();
16512 + return size;
16513 + }
16514 +
16515 if (!__builtin_constant_p(size))
16516 - return copy_user_generic((__force void *)dst, src, size);
16517 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16518 switch (size) {
16519 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
16520 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
16521 ret, "b", "b", "iq", 1);
16522 return ret;
16523 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
16524 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
16525 ret, "w", "w", "ir", 2);
16526 return ret;
16527 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
16528 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
16529 ret, "l", "k", "ir", 4);
16530 return ret;
16531 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
16532 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16533 ret, "q", "", "er", 8);
16534 return ret;
16535 case 10:
16536 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16537 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16538 ret, "q", "", "er", 10);
16539 if (unlikely(ret))
16540 return ret;
16541 asm("":::"memory");
16542 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
16543 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
16544 ret, "w", "w", "ir", 2);
16545 return ret;
16546 case 16:
16547 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16548 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16549 ret, "q", "", "er", 16);
16550 if (unlikely(ret))
16551 return ret;
16552 asm("":::"memory");
16553 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
16554 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
16555 ret, "q", "", "er", 8);
16556 return ret;
16557 default:
16558 - return copy_user_generic((__force void *)dst, src, size);
16559 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16560 }
16561 }
16562
16563 static __always_inline __must_check
16564 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16565 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
16566 {
16567 - int ret = 0;
16568 + unsigned ret = 0;
16569
16570 might_fault();
16571 +
16572 + if (size > INT_MAX)
16573 + return size;
16574 +
16575 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16576 + if (!__access_ok(VERIFY_READ, src, size))
16577 + return size;
16578 + if (!__access_ok(VERIFY_WRITE, dst, size))
16579 + return size;
16580 +#endif
16581 +
16582 if (!__builtin_constant_p(size))
16583 - return copy_user_generic((__force void *)dst,
16584 - (__force void *)src, size);
16585 + return copy_user_generic((__force_kernel void *)____m(dst),
16586 + (__force_kernel const void *)____m(src), size);
16587 switch (size) {
16588 case 1: {
16589 u8 tmp;
16590 - __get_user_asm(tmp, (u8 __user *)src,
16591 + __get_user_asm(tmp, (const u8 __user *)src,
16592 ret, "b", "b", "=q", 1);
16593 if (likely(!ret))
16594 __put_user_asm(tmp, (u8 __user *)dst,
16595 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16596 }
16597 case 2: {
16598 u16 tmp;
16599 - __get_user_asm(tmp, (u16 __user *)src,
16600 + __get_user_asm(tmp, (const u16 __user *)src,
16601 ret, "w", "w", "=r", 2);
16602 if (likely(!ret))
16603 __put_user_asm(tmp, (u16 __user *)dst,
16604 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16605
16606 case 4: {
16607 u32 tmp;
16608 - __get_user_asm(tmp, (u32 __user *)src,
16609 + __get_user_asm(tmp, (const u32 __user *)src,
16610 ret, "l", "k", "=r", 4);
16611 if (likely(!ret))
16612 __put_user_asm(tmp, (u32 __user *)dst,
16613 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16614 }
16615 case 8: {
16616 u64 tmp;
16617 - __get_user_asm(tmp, (u64 __user *)src,
16618 + __get_user_asm(tmp, (const u64 __user *)src,
16619 ret, "q", "", "=r", 8);
16620 if (likely(!ret))
16621 __put_user_asm(tmp, (u64 __user *)dst,
16622 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16623 return ret;
16624 }
16625 default:
16626 - return copy_user_generic((__force void *)dst,
16627 - (__force void *)src, size);
16628 + return copy_user_generic((__force_kernel void *)____m(dst),
16629 + (__force_kernel const void *)____m(src), size);
16630 }
16631 }
16632
16633 static __must_check __always_inline int
16634 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
16635 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
16636 {
16637 - return copy_user_generic(dst, (__force const void *)src, size);
16638 + if (size > INT_MAX)
16639 + return size;
16640 +
16641 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16642 + if (!__access_ok(VERIFY_READ, src, size))
16643 + return size;
16644 +#endif
16645 +
16646 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16647 }
16648
16649 -static __must_check __always_inline int
16650 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
16651 +static __must_check __always_inline unsigned long
16652 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
16653 {
16654 - return copy_user_generic((__force void *)dst, src, size);
16655 + if (size > INT_MAX)
16656 + return size;
16657 +
16658 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16659 + if (!__access_ok(VERIFY_WRITE, dst, size))
16660 + return size;
16661 +#endif
16662 +
16663 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16664 }
16665
16666 -extern long __copy_user_nocache(void *dst, const void __user *src,
16667 - unsigned size, int zerorest);
16668 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
16669 + unsigned long size, int zerorest) __size_overflow(3);
16670
16671 -static inline int
16672 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
16673 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
16674 {
16675 might_sleep();
16676 +
16677 + if (size > INT_MAX)
16678 + return size;
16679 +
16680 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16681 + if (!__access_ok(VERIFY_READ, src, size))
16682 + return size;
16683 +#endif
16684 +
16685 return __copy_user_nocache(dst, src, size, 1);
16686 }
16687
16688 -static inline int
16689 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16690 - unsigned size)
16691 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16692 + unsigned long size)
16693 {
16694 + if (size > INT_MAX)
16695 + return size;
16696 +
16697 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16698 + if (!__access_ok(VERIFY_READ, src, size))
16699 + return size;
16700 +#endif
16701 +
16702 return __copy_user_nocache(dst, src, size, 0);
16703 }
16704
16705 -unsigned long
16706 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
16707 +extern unsigned long
16708 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
16709
16710 #endif /* _ASM_X86_UACCESS_64_H */
16711 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
16712 index 5b238981..77fdd78 100644
16713 --- a/arch/x86/include/asm/word-at-a-time.h
16714 +++ b/arch/x86/include/asm/word-at-a-time.h
16715 @@ -11,7 +11,7 @@
16716 * and shift, for example.
16717 */
16718 struct word_at_a_time {
16719 - const unsigned long one_bits, high_bits;
16720 + unsigned long one_bits, high_bits;
16721 };
16722
16723 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
16724 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
16725 index 5769349..a3d3e2a 100644
16726 --- a/arch/x86/include/asm/x86_init.h
16727 +++ b/arch/x86/include/asm/x86_init.h
16728 @@ -141,7 +141,7 @@ struct x86_init_ops {
16729 struct x86_init_timers timers;
16730 struct x86_init_iommu iommu;
16731 struct x86_init_pci pci;
16732 -};
16733 +} __no_const;
16734
16735 /**
16736 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
16737 @@ -152,7 +152,7 @@ struct x86_cpuinit_ops {
16738 void (*setup_percpu_clockev)(void);
16739 void (*early_percpu_clock_init)(void);
16740 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
16741 -};
16742 +} __no_const;
16743
16744 /**
16745 * struct x86_platform_ops - platform specific runtime functions
16746 @@ -178,7 +178,7 @@ struct x86_platform_ops {
16747 void (*save_sched_clock_state)(void);
16748 void (*restore_sched_clock_state)(void);
16749 void (*apic_post_init)(void);
16750 -};
16751 +} __no_const;
16752
16753 struct pci_dev;
16754
16755 @@ -187,14 +187,14 @@ struct x86_msi_ops {
16756 void (*teardown_msi_irq)(unsigned int irq);
16757 void (*teardown_msi_irqs)(struct pci_dev *dev);
16758 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
16759 -};
16760 +} __no_const;
16761
16762 struct x86_io_apic_ops {
16763 void (*init) (void);
16764 unsigned int (*read) (unsigned int apic, unsigned int reg);
16765 void (*write) (unsigned int apic, unsigned int reg, unsigned int value);
16766 void (*modify)(unsigned int apic, unsigned int reg, unsigned int value);
16767 -};
16768 +} __no_const;
16769
16770 extern struct x86_init_ops x86_init;
16771 extern struct x86_cpuinit_ops x86_cpuinit;
16772 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
16773 index 0415cda..b43d877 100644
16774 --- a/arch/x86/include/asm/xsave.h
16775 +++ b/arch/x86/include/asm/xsave.h
16776 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16777 return -EFAULT;
16778
16779 __asm__ __volatile__(ASM_STAC "\n"
16780 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
16781 + "1:"
16782 + __copyuser_seg
16783 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
16784 "2: " ASM_CLAC "\n"
16785 ".section .fixup,\"ax\"\n"
16786 "3: movl $-1,%[err]\n"
16787 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16788 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
16789 {
16790 int err;
16791 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
16792 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
16793 u32 lmask = mask;
16794 u32 hmask = mask >> 32;
16795
16796 __asm__ __volatile__(ASM_STAC "\n"
16797 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16798 + "1:"
16799 + __copyuser_seg
16800 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16801 "2: " ASM_CLAC "\n"
16802 ".section .fixup,\"ax\"\n"
16803 "3: movl $-1,%[err]\n"
16804 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
16805 index bbae024..e1528f9 100644
16806 --- a/arch/x86/include/uapi/asm/e820.h
16807 +++ b/arch/x86/include/uapi/asm/e820.h
16808 @@ -63,7 +63,7 @@ struct e820map {
16809 #define ISA_START_ADDRESS 0xa0000
16810 #define ISA_END_ADDRESS 0x100000
16811
16812 -#define BIOS_BEGIN 0x000a0000
16813 +#define BIOS_BEGIN 0x000c0000
16814 #define BIOS_END 0x00100000
16815
16816 #define BIOS_ROM_BASE 0xffe00000
16817 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
16818 index 34e923a..0c6bb6e 100644
16819 --- a/arch/x86/kernel/Makefile
16820 +++ b/arch/x86/kernel/Makefile
16821 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
16822 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
16823 obj-$(CONFIG_IRQ_WORK) += irq_work.o
16824 obj-y += probe_roms.o
16825 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
16826 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
16827 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
16828 obj-y += syscall_$(BITS).o
16829 obj-$(CONFIG_X86_64) += vsyscall_64.o
16830 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
16831 index bacf4b0..4ede72e 100644
16832 --- a/arch/x86/kernel/acpi/boot.c
16833 +++ b/arch/x86/kernel/acpi/boot.c
16834 @@ -1358,7 +1358,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
16835 * If your system is blacklisted here, but you find that acpi=force
16836 * works for you, please contact linux-acpi@vger.kernel.org
16837 */
16838 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
16839 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
16840 /*
16841 * Boxes that need ACPI disabled
16842 */
16843 @@ -1433,7 +1433,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
16844 };
16845
16846 /* second table for DMI checks that should run after early-quirks */
16847 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
16848 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
16849 /*
16850 * HP laptops which use a DSDT reporting as HP/SB400/10000,
16851 * which includes some code which overrides all temperature
16852 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
16853 index d5e0d71..6533e08 100644
16854 --- a/arch/x86/kernel/acpi/sleep.c
16855 +++ b/arch/x86/kernel/acpi/sleep.c
16856 @@ -74,8 +74,12 @@ int acpi_suspend_lowlevel(void)
16857 #else /* CONFIG_64BIT */
16858 #ifdef CONFIG_SMP
16859 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
16860 +
16861 + pax_open_kernel();
16862 early_gdt_descr.address =
16863 (unsigned long)get_cpu_gdt_table(smp_processor_id());
16864 + pax_close_kernel();
16865 +
16866 initial_gs = per_cpu_offset(smp_processor_id());
16867 #endif
16868 initial_code = (unsigned long)wakeup_long64;
16869 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
16870 index 13ab720..95d5442 100644
16871 --- a/arch/x86/kernel/acpi/wakeup_32.S
16872 +++ b/arch/x86/kernel/acpi/wakeup_32.S
16873 @@ -30,13 +30,11 @@ wakeup_pmode_return:
16874 # and restore the stack ... but you need gdt for this to work
16875 movl saved_context_esp, %esp
16876
16877 - movl %cs:saved_magic, %eax
16878 - cmpl $0x12345678, %eax
16879 + cmpl $0x12345678, saved_magic
16880 jne bogus_magic
16881
16882 # jump to place where we left off
16883 - movl saved_eip, %eax
16884 - jmp *%eax
16885 + jmp *(saved_eip)
16886
16887 bogus_magic:
16888 jmp bogus_magic
16889 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
16890 index ef5ccca..bd83949 100644
16891 --- a/arch/x86/kernel/alternative.c
16892 +++ b/arch/x86/kernel/alternative.c
16893 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
16894 */
16895 for (a = start; a < end; a++) {
16896 instr = (u8 *)&a->instr_offset + a->instr_offset;
16897 +
16898 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16899 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16900 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
16901 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16902 +#endif
16903 +
16904 replacement = (u8 *)&a->repl_offset + a->repl_offset;
16905 BUG_ON(a->replacementlen > a->instrlen);
16906 BUG_ON(a->instrlen > sizeof(insnbuf));
16907 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
16908 for (poff = start; poff < end; poff++) {
16909 u8 *ptr = (u8 *)poff + *poff;
16910
16911 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16912 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16913 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16914 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16915 +#endif
16916 +
16917 if (!*poff || ptr < text || ptr >= text_end)
16918 continue;
16919 /* turn DS segment override prefix into lock prefix */
16920 - if (*ptr == 0x3e)
16921 + if (*ktla_ktva(ptr) == 0x3e)
16922 text_poke(ptr, ((unsigned char []){0xf0}), 1);
16923 }
16924 mutex_unlock(&text_mutex);
16925 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
16926 for (poff = start; poff < end; poff++) {
16927 u8 *ptr = (u8 *)poff + *poff;
16928
16929 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16930 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16931 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16932 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16933 +#endif
16934 +
16935 if (!*poff || ptr < text || ptr >= text_end)
16936 continue;
16937 /* turn lock prefix into DS segment override prefix */
16938 - if (*ptr == 0xf0)
16939 + if (*ktla_ktva(ptr) == 0xf0)
16940 text_poke(ptr, ((unsigned char []){0x3E}), 1);
16941 }
16942 mutex_unlock(&text_mutex);
16943 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
16944
16945 BUG_ON(p->len > MAX_PATCH_LEN);
16946 /* prep the buffer with the original instructions */
16947 - memcpy(insnbuf, p->instr, p->len);
16948 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
16949 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
16950 (unsigned long)p->instr, p->len);
16951
16952 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
16953 if (!uniproc_patched || num_possible_cpus() == 1)
16954 free_init_pages("SMP alternatives",
16955 (unsigned long)__smp_locks,
16956 - (unsigned long)__smp_locks_end);
16957 + PAGE_ALIGN((unsigned long)__smp_locks_end));
16958 #endif
16959
16960 apply_paravirt(__parainstructions, __parainstructions_end);
16961 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
16962 * instructions. And on the local CPU you need to be protected again NMI or MCE
16963 * handlers seeing an inconsistent instruction while you patch.
16964 */
16965 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
16966 +void *__kprobes text_poke_early(void *addr, const void *opcode,
16967 size_t len)
16968 {
16969 unsigned long flags;
16970 local_irq_save(flags);
16971 - memcpy(addr, opcode, len);
16972 +
16973 + pax_open_kernel();
16974 + memcpy(ktla_ktva(addr), opcode, len);
16975 sync_core();
16976 + pax_close_kernel();
16977 +
16978 local_irq_restore(flags);
16979 /* Could also do a CLFLUSH here to speed up CPU recovery; but
16980 that causes hangs on some VIA CPUs. */
16981 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
16982 */
16983 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
16984 {
16985 - unsigned long flags;
16986 - char *vaddr;
16987 + unsigned char *vaddr = ktla_ktva(addr);
16988 struct page *pages[2];
16989 - int i;
16990 + size_t i;
16991
16992 if (!core_kernel_text((unsigned long)addr)) {
16993 - pages[0] = vmalloc_to_page(addr);
16994 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
16995 + pages[0] = vmalloc_to_page(vaddr);
16996 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
16997 } else {
16998 - pages[0] = virt_to_page(addr);
16999 + pages[0] = virt_to_page(vaddr);
17000 WARN_ON(!PageReserved(pages[0]));
17001 - pages[1] = virt_to_page(addr + PAGE_SIZE);
17002 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
17003 }
17004 BUG_ON(!pages[0]);
17005 - local_irq_save(flags);
17006 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
17007 - if (pages[1])
17008 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
17009 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
17010 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
17011 - clear_fixmap(FIX_TEXT_POKE0);
17012 - if (pages[1])
17013 - clear_fixmap(FIX_TEXT_POKE1);
17014 - local_flush_tlb();
17015 - sync_core();
17016 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
17017 - that causes hangs on some VIA CPUs. */
17018 + text_poke_early(addr, opcode, len);
17019 for (i = 0; i < len; i++)
17020 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
17021 - local_irq_restore(flags);
17022 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
17023 return addr;
17024 }
17025
17026 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
17027 index cbf5121..812b537 100644
17028 --- a/arch/x86/kernel/apic/apic.c
17029 +++ b/arch/x86/kernel/apic/apic.c
17030 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
17031 /*
17032 * Debug level, exported for io_apic.c
17033 */
17034 -unsigned int apic_verbosity;
17035 +int apic_verbosity;
17036
17037 int pic_mode;
17038
17039 @@ -1956,7 +1956,7 @@ void smp_error_interrupt(struct pt_regs *regs)
17040 apic_write(APIC_ESR, 0);
17041 v1 = apic_read(APIC_ESR);
17042 ack_APIC_irq();
17043 - atomic_inc(&irq_err_count);
17044 + atomic_inc_unchecked(&irq_err_count);
17045
17046 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
17047 smp_processor_id(), v0 , v1);
17048 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
17049 index 00c77cf..2dc6a2d 100644
17050 --- a/arch/x86/kernel/apic/apic_flat_64.c
17051 +++ b/arch/x86/kernel/apic/apic_flat_64.c
17052 @@ -157,7 +157,7 @@ static int flat_probe(void)
17053 return 1;
17054 }
17055
17056 -static struct apic apic_flat = {
17057 +static struct apic apic_flat __read_only = {
17058 .name = "flat",
17059 .probe = flat_probe,
17060 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
17061 @@ -271,7 +271,7 @@ static int physflat_probe(void)
17062 return 0;
17063 }
17064
17065 -static struct apic apic_physflat = {
17066 +static struct apic apic_physflat __read_only = {
17067
17068 .name = "physical flat",
17069 .probe = physflat_probe,
17070 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
17071 index e145f28..2752888 100644
17072 --- a/arch/x86/kernel/apic/apic_noop.c
17073 +++ b/arch/x86/kernel/apic/apic_noop.c
17074 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
17075 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
17076 }
17077
17078 -struct apic apic_noop = {
17079 +struct apic apic_noop __read_only = {
17080 .name = "noop",
17081 .probe = noop_probe,
17082 .acpi_madt_oem_check = NULL,
17083 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
17084 index d50e364..543bee3 100644
17085 --- a/arch/x86/kernel/apic/bigsmp_32.c
17086 +++ b/arch/x86/kernel/apic/bigsmp_32.c
17087 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
17088 return dmi_bigsmp;
17089 }
17090
17091 -static struct apic apic_bigsmp = {
17092 +static struct apic apic_bigsmp __read_only = {
17093
17094 .name = "bigsmp",
17095 .probe = probe_bigsmp,
17096 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
17097 index 0874799..a7a7892 100644
17098 --- a/arch/x86/kernel/apic/es7000_32.c
17099 +++ b/arch/x86/kernel/apic/es7000_32.c
17100 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
17101 return ret && es7000_apic_is_cluster();
17102 }
17103
17104 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
17105 -static struct apic __refdata apic_es7000_cluster = {
17106 +static struct apic apic_es7000_cluster __read_only = {
17107
17108 .name = "es7000",
17109 .probe = probe_es7000,
17110 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
17111 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
17112 };
17113
17114 -static struct apic __refdata apic_es7000 = {
17115 +static struct apic apic_es7000 __read_only = {
17116
17117 .name = "es7000",
17118 .probe = probe_es7000,
17119 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
17120 index b739d39..aebc14c 100644
17121 --- a/arch/x86/kernel/apic/io_apic.c
17122 +++ b/arch/x86/kernel/apic/io_apic.c
17123 @@ -1084,7 +1084,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
17124 }
17125 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
17126
17127 -void lock_vector_lock(void)
17128 +void lock_vector_lock(void) __acquires(vector_lock)
17129 {
17130 /* Used to the online set of cpus does not change
17131 * during assign_irq_vector.
17132 @@ -1092,7 +1092,7 @@ void lock_vector_lock(void)
17133 raw_spin_lock(&vector_lock);
17134 }
17135
17136 -void unlock_vector_lock(void)
17137 +void unlock_vector_lock(void) __releases(vector_lock)
17138 {
17139 raw_spin_unlock(&vector_lock);
17140 }
17141 @@ -2399,7 +2399,7 @@ static void ack_apic_edge(struct irq_data *data)
17142 ack_APIC_irq();
17143 }
17144
17145 -atomic_t irq_mis_count;
17146 +atomic_unchecked_t irq_mis_count;
17147
17148 #ifdef CONFIG_GENERIC_PENDING_IRQ
17149 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
17150 @@ -2540,7 +2540,7 @@ static void ack_apic_level(struct irq_data *data)
17151 * at the cpu.
17152 */
17153 if (!(v & (1 << (i & 0x1f)))) {
17154 - atomic_inc(&irq_mis_count);
17155 + atomic_inc_unchecked(&irq_mis_count);
17156
17157 eoi_ioapic_irq(irq, cfg);
17158 }
17159 @@ -2567,11 +2567,13 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
17160
17161 static void irq_remap_modify_chip_defaults(struct irq_chip *chip)
17162 {
17163 - chip->irq_print_chip = ir_print_prefix;
17164 - chip->irq_ack = ir_ack_apic_edge;
17165 - chip->irq_eoi = ir_ack_apic_level;
17166 + pax_open_kernel();
17167 + *(void **)&chip->irq_print_chip = ir_print_prefix;
17168 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
17169 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
17170
17171 - chip->irq_set_affinity = set_remapped_irq_affinity;
17172 + *(void **)&chip->irq_set_affinity = set_remapped_irq_affinity;
17173 + pax_close_kernel();
17174 }
17175 #endif /* CONFIG_IRQ_REMAP */
17176
17177 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
17178 index d661ee9..791fd33 100644
17179 --- a/arch/x86/kernel/apic/numaq_32.c
17180 +++ b/arch/x86/kernel/apic/numaq_32.c
17181 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
17182 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
17183 }
17184
17185 -/* Use __refdata to keep false positive warning calm. */
17186 -static struct apic __refdata apic_numaq = {
17187 +static struct apic apic_numaq __read_only = {
17188
17189 .name = "NUMAQ",
17190 .probe = probe_numaq,
17191 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
17192 index eb35ef9..f184a21 100644
17193 --- a/arch/x86/kernel/apic/probe_32.c
17194 +++ b/arch/x86/kernel/apic/probe_32.c
17195 @@ -72,7 +72,7 @@ static int probe_default(void)
17196 return 1;
17197 }
17198
17199 -static struct apic apic_default = {
17200 +static struct apic apic_default __read_only = {
17201
17202 .name = "default",
17203 .probe = probe_default,
17204 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
17205 index 77c95c0..434f8a4 100644
17206 --- a/arch/x86/kernel/apic/summit_32.c
17207 +++ b/arch/x86/kernel/apic/summit_32.c
17208 @@ -486,7 +486,7 @@ void setup_summit(void)
17209 }
17210 #endif
17211
17212 -static struct apic apic_summit = {
17213 +static struct apic apic_summit __read_only = {
17214
17215 .name = "summit",
17216 .probe = probe_summit,
17217 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
17218 index c88baa4..757aee1 100644
17219 --- a/arch/x86/kernel/apic/x2apic_cluster.c
17220 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
17221 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
17222 return notifier_from_errno(err);
17223 }
17224
17225 -static struct notifier_block __refdata x2apic_cpu_notifier = {
17226 +static struct notifier_block x2apic_cpu_notifier = {
17227 .notifier_call = update_clusterinfo,
17228 };
17229
17230 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
17231 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
17232 }
17233
17234 -static struct apic apic_x2apic_cluster = {
17235 +static struct apic apic_x2apic_cluster __read_only = {
17236
17237 .name = "cluster x2apic",
17238 .probe = x2apic_cluster_probe,
17239 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
17240 index 562a76d..a003c0f 100644
17241 --- a/arch/x86/kernel/apic/x2apic_phys.c
17242 +++ b/arch/x86/kernel/apic/x2apic_phys.c
17243 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
17244 return apic == &apic_x2apic_phys;
17245 }
17246
17247 -static struct apic apic_x2apic_phys = {
17248 +static struct apic apic_x2apic_phys __read_only = {
17249
17250 .name = "physical x2apic",
17251 .probe = x2apic_phys_probe,
17252 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
17253 index 8cfade9..b9d04fc 100644
17254 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
17255 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
17256 @@ -333,7 +333,7 @@ static int uv_probe(void)
17257 return apic == &apic_x2apic_uv_x;
17258 }
17259
17260 -static struct apic __refdata apic_x2apic_uv_x = {
17261 +static struct apic apic_x2apic_uv_x __read_only = {
17262
17263 .name = "UV large system",
17264 .probe = uv_probe,
17265 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
17266 index d65464e..1035d31 100644
17267 --- a/arch/x86/kernel/apm_32.c
17268 +++ b/arch/x86/kernel/apm_32.c
17269 @@ -412,7 +412,7 @@ static DEFINE_MUTEX(apm_mutex);
17270 * This is for buggy BIOS's that refer to (real mode) segment 0x40
17271 * even though they are called in protected mode.
17272 */
17273 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
17274 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
17275 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
17276
17277 static const char driver_version[] = "1.16ac"; /* no spaces */
17278 @@ -590,7 +590,10 @@ static long __apm_bios_call(void *_call)
17279 BUG_ON(cpu != 0);
17280 gdt = get_cpu_gdt_table(cpu);
17281 save_desc_40 = gdt[0x40 / 8];
17282 +
17283 + pax_open_kernel();
17284 gdt[0x40 / 8] = bad_bios_desc;
17285 + pax_close_kernel();
17286
17287 apm_irq_save(flags);
17288 APM_DO_SAVE_SEGS;
17289 @@ -599,7 +602,11 @@ static long __apm_bios_call(void *_call)
17290 &call->esi);
17291 APM_DO_RESTORE_SEGS;
17292 apm_irq_restore(flags);
17293 +
17294 + pax_open_kernel();
17295 gdt[0x40 / 8] = save_desc_40;
17296 + pax_close_kernel();
17297 +
17298 put_cpu();
17299
17300 return call->eax & 0xff;
17301 @@ -666,7 +673,10 @@ static long __apm_bios_call_simple(void *_call)
17302 BUG_ON(cpu != 0);
17303 gdt = get_cpu_gdt_table(cpu);
17304 save_desc_40 = gdt[0x40 / 8];
17305 +
17306 + pax_open_kernel();
17307 gdt[0x40 / 8] = bad_bios_desc;
17308 + pax_close_kernel();
17309
17310 apm_irq_save(flags);
17311 APM_DO_SAVE_SEGS;
17312 @@ -674,7 +684,11 @@ static long __apm_bios_call_simple(void *_call)
17313 &call->eax);
17314 APM_DO_RESTORE_SEGS;
17315 apm_irq_restore(flags);
17316 +
17317 + pax_open_kernel();
17318 gdt[0x40 / 8] = save_desc_40;
17319 + pax_close_kernel();
17320 +
17321 put_cpu();
17322 return error;
17323 }
17324 @@ -2345,12 +2359,15 @@ static int __init apm_init(void)
17325 * code to that CPU.
17326 */
17327 gdt = get_cpu_gdt_table(0);
17328 +
17329 + pax_open_kernel();
17330 set_desc_base(&gdt[APM_CS >> 3],
17331 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
17332 set_desc_base(&gdt[APM_CS_16 >> 3],
17333 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
17334 set_desc_base(&gdt[APM_DS >> 3],
17335 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
17336 + pax_close_kernel();
17337
17338 proc_create("apm", 0, NULL, &apm_file_ops);
17339
17340 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
17341 index 2861082..6d4718e 100644
17342 --- a/arch/x86/kernel/asm-offsets.c
17343 +++ b/arch/x86/kernel/asm-offsets.c
17344 @@ -33,6 +33,8 @@ void common(void) {
17345 OFFSET(TI_status, thread_info, status);
17346 OFFSET(TI_addr_limit, thread_info, addr_limit);
17347 OFFSET(TI_preempt_count, thread_info, preempt_count);
17348 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
17349 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
17350
17351 BLANK();
17352 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
17353 @@ -53,8 +55,26 @@ void common(void) {
17354 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
17355 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
17356 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
17357 +
17358 +#ifdef CONFIG_PAX_KERNEXEC
17359 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
17360 #endif
17361
17362 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17363 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
17364 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
17365 +#ifdef CONFIG_X86_64
17366 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
17367 +#endif
17368 +#endif
17369 +
17370 +#endif
17371 +
17372 + BLANK();
17373 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
17374 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
17375 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
17376 +
17377 #ifdef CONFIG_XEN
17378 BLANK();
17379 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
17380 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
17381 index 1b4754f..fbb4227 100644
17382 --- a/arch/x86/kernel/asm-offsets_64.c
17383 +++ b/arch/x86/kernel/asm-offsets_64.c
17384 @@ -76,6 +76,7 @@ int main(void)
17385 BLANK();
17386 #undef ENTRY
17387
17388 + DEFINE(TSS_size, sizeof(struct tss_struct));
17389 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
17390 BLANK();
17391
17392 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
17393 index a0e067d..9c7db16 100644
17394 --- a/arch/x86/kernel/cpu/Makefile
17395 +++ b/arch/x86/kernel/cpu/Makefile
17396 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
17397 CFLAGS_REMOVE_perf_event.o = -pg
17398 endif
17399
17400 -# Make sure load_percpu_segment has no stackprotector
17401 -nostackp := $(call cc-option, -fno-stack-protector)
17402 -CFLAGS_common.o := $(nostackp)
17403 -
17404 obj-y := intel_cacheinfo.o scattered.o topology.o
17405 obj-y += proc.o capflags.o powerflags.o common.o
17406 obj-y += vmware.o hypervisor.o mshyperv.o
17407 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
17408 index 15239ff..e23e04e 100644
17409 --- a/arch/x86/kernel/cpu/amd.c
17410 +++ b/arch/x86/kernel/cpu/amd.c
17411 @@ -733,7 +733,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
17412 unsigned int size)
17413 {
17414 /* AMD errata T13 (order #21922) */
17415 - if ((c->x86 == 6)) {
17416 + if (c->x86 == 6) {
17417 /* Duron Rev A0 */
17418 if (c->x86_model == 3 && c->x86_mask == 0)
17419 size = 64;
17420 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
17421 index 9c3ab43..51e6366 100644
17422 --- a/arch/x86/kernel/cpu/common.c
17423 +++ b/arch/x86/kernel/cpu/common.c
17424 @@ -86,60 +86,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
17425
17426 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
17427
17428 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
17429 -#ifdef CONFIG_X86_64
17430 - /*
17431 - * We need valid kernel segments for data and code in long mode too
17432 - * IRET will check the segment types kkeil 2000/10/28
17433 - * Also sysret mandates a special GDT layout
17434 - *
17435 - * TLS descriptors are currently at a different place compared to i386.
17436 - * Hopefully nobody expects them at a fixed place (Wine?)
17437 - */
17438 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
17439 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
17440 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
17441 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
17442 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
17443 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
17444 -#else
17445 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
17446 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17447 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
17448 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
17449 - /*
17450 - * Segments used for calling PnP BIOS have byte granularity.
17451 - * They code segments and data segments have fixed 64k limits,
17452 - * the transfer segment sizes are set at run time.
17453 - */
17454 - /* 32-bit code */
17455 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17456 - /* 16-bit code */
17457 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17458 - /* 16-bit data */
17459 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
17460 - /* 16-bit data */
17461 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
17462 - /* 16-bit data */
17463 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
17464 - /*
17465 - * The APM segments have byte granularity and their bases
17466 - * are set at run time. All have 64k limits.
17467 - */
17468 - /* 32-bit code */
17469 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17470 - /* 16-bit code */
17471 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17472 - /* data */
17473 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
17474 -
17475 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17476 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17477 - GDT_STACK_CANARY_INIT
17478 -#endif
17479 -} };
17480 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
17481 -
17482 static int __init x86_xsave_setup(char *s)
17483 {
17484 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
17485 @@ -389,7 +335,7 @@ void switch_to_new_gdt(int cpu)
17486 {
17487 struct desc_ptr gdt_descr;
17488
17489 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
17490 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
17491 gdt_descr.size = GDT_SIZE - 1;
17492 load_gdt(&gdt_descr);
17493 /* Reload the per-cpu base */
17494 @@ -885,6 +831,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
17495 /* Filter out anything that depends on CPUID levels we don't have */
17496 filter_cpuid_features(c, true);
17497
17498 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
17499 + setup_clear_cpu_cap(X86_FEATURE_SEP);
17500 +#endif
17501 +
17502 /* If the model name is still unset, do table lookup. */
17503 if (!c->x86_model_id[0]) {
17504 const char *p;
17505 @@ -1068,10 +1018,12 @@ static __init int setup_disablecpuid(char *arg)
17506 }
17507 __setup("clearcpuid=", setup_disablecpuid);
17508
17509 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
17510 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
17511 +
17512 #ifdef CONFIG_X86_64
17513 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
17514 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
17515 - (unsigned long) nmi_idt_table };
17516 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
17517
17518 DEFINE_PER_CPU_FIRST(union irq_stack_union,
17519 irq_stack_union) __aligned(PAGE_SIZE);
17520 @@ -1085,7 +1037,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
17521 EXPORT_PER_CPU_SYMBOL(current_task);
17522
17523 DEFINE_PER_CPU(unsigned long, kernel_stack) =
17524 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
17525 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
17526 EXPORT_PER_CPU_SYMBOL(kernel_stack);
17527
17528 DEFINE_PER_CPU(char *, irq_stack_ptr) =
17529 @@ -1224,7 +1176,7 @@ void __cpuinit cpu_init(void)
17530 int i;
17531
17532 cpu = stack_smp_processor_id();
17533 - t = &per_cpu(init_tss, cpu);
17534 + t = init_tss + cpu;
17535 oist = &per_cpu(orig_ist, cpu);
17536
17537 #ifdef CONFIG_NUMA
17538 @@ -1250,7 +1202,7 @@ void __cpuinit cpu_init(void)
17539 switch_to_new_gdt(cpu);
17540 loadsegment(fs, 0);
17541
17542 - load_idt((const struct desc_ptr *)&idt_descr);
17543 + load_idt(&idt_descr);
17544
17545 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
17546 syscall_init();
17547 @@ -1259,7 +1211,6 @@ void __cpuinit cpu_init(void)
17548 wrmsrl(MSR_KERNEL_GS_BASE, 0);
17549 barrier();
17550
17551 - x86_configure_nx();
17552 enable_x2apic();
17553
17554 /*
17555 @@ -1311,7 +1262,7 @@ void __cpuinit cpu_init(void)
17556 {
17557 int cpu = smp_processor_id();
17558 struct task_struct *curr = current;
17559 - struct tss_struct *t = &per_cpu(init_tss, cpu);
17560 + struct tss_struct *t = init_tss + cpu;
17561 struct thread_struct *thread = &curr->thread;
17562
17563 if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) {
17564 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
17565 index fcaabd0..7b55a26 100644
17566 --- a/arch/x86/kernel/cpu/intel.c
17567 +++ b/arch/x86/kernel/cpu/intel.c
17568 @@ -174,7 +174,7 @@ static void __cpuinit trap_init_f00f_bug(void)
17569 * Update the IDT descriptor and reload the IDT so that
17570 * it uses the read-only mapped virtual address.
17571 */
17572 - idt_descr.address = fix_to_virt(FIX_F00F_IDT);
17573 + idt_descr.address = (struct desc_struct *)fix_to_virt(FIX_F00F_IDT);
17574 load_idt(&idt_descr);
17575 }
17576 #endif
17577 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
17578 index 84c1309..39b7224 100644
17579 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
17580 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
17581 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
17582 };
17583
17584 #ifdef CONFIG_AMD_NB
17585 +static struct attribute *default_attrs_amd_nb[] = {
17586 + &type.attr,
17587 + &level.attr,
17588 + &coherency_line_size.attr,
17589 + &physical_line_partition.attr,
17590 + &ways_of_associativity.attr,
17591 + &number_of_sets.attr,
17592 + &size.attr,
17593 + &shared_cpu_map.attr,
17594 + &shared_cpu_list.attr,
17595 + NULL,
17596 + NULL,
17597 + NULL,
17598 + NULL
17599 +};
17600 +
17601 static struct attribute ** __cpuinit amd_l3_attrs(void)
17602 {
17603 static struct attribute **attrs;
17604 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
17605
17606 n = ARRAY_SIZE(default_attrs);
17607
17608 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
17609 - n += 2;
17610 -
17611 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
17612 - n += 1;
17613 -
17614 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
17615 - if (attrs == NULL)
17616 - return attrs = default_attrs;
17617 -
17618 - for (n = 0; default_attrs[n]; n++)
17619 - attrs[n] = default_attrs[n];
17620 + attrs = default_attrs_amd_nb;
17621
17622 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
17623 attrs[n++] = &cache_disable_0.attr;
17624 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
17625 .default_attrs = default_attrs,
17626 };
17627
17628 +#ifdef CONFIG_AMD_NB
17629 +static struct kobj_type ktype_cache_amd_nb = {
17630 + .sysfs_ops = &sysfs_ops,
17631 + .default_attrs = default_attrs_amd_nb,
17632 +};
17633 +#endif
17634 +
17635 static struct kobj_type ktype_percpu_entry = {
17636 .sysfs_ops = &sysfs_ops,
17637 };
17638 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
17639 return retval;
17640 }
17641
17642 +#ifdef CONFIG_AMD_NB
17643 + amd_l3_attrs();
17644 +#endif
17645 +
17646 for (i = 0; i < num_cache_leaves; i++) {
17647 + struct kobj_type *ktype;
17648 +
17649 this_object = INDEX_KOBJECT_PTR(cpu, i);
17650 this_object->cpu = cpu;
17651 this_object->index = i;
17652
17653 this_leaf = CPUID4_INFO_IDX(cpu, i);
17654
17655 - ktype_cache.default_attrs = default_attrs;
17656 + ktype = &ktype_cache;
17657 #ifdef CONFIG_AMD_NB
17658 if (this_leaf->base.nb)
17659 - ktype_cache.default_attrs = amd_l3_attrs();
17660 + ktype = &ktype_cache_amd_nb;
17661 #endif
17662 retval = kobject_init_and_add(&(this_object->kobj),
17663 - &ktype_cache,
17664 + ktype,
17665 per_cpu(ici_cache_kobject, cpu),
17666 "index%1lu", i);
17667 if (unlikely(retval)) {
17668 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
17669 return NOTIFY_OK;
17670 }
17671
17672 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
17673 +static struct notifier_block cacheinfo_cpu_notifier = {
17674 .notifier_call = cacheinfo_cpu_callback,
17675 };
17676
17677 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
17678 index 80dbda8..be16652 100644
17679 --- a/arch/x86/kernel/cpu/mcheck/mce.c
17680 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
17681 @@ -45,6 +45,7 @@
17682 #include <asm/processor.h>
17683 #include <asm/mce.h>
17684 #include <asm/msr.h>
17685 +#include <asm/local.h>
17686
17687 #include "mce-internal.h"
17688
17689 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
17690 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
17691 m->cs, m->ip);
17692
17693 - if (m->cs == __KERNEL_CS)
17694 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
17695 print_symbol("{%s}", m->ip);
17696 pr_cont("\n");
17697 }
17698 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
17699
17700 #define PANIC_TIMEOUT 5 /* 5 seconds */
17701
17702 -static atomic_t mce_paniced;
17703 +static atomic_unchecked_t mce_paniced;
17704
17705 static int fake_panic;
17706 -static atomic_t mce_fake_paniced;
17707 +static atomic_unchecked_t mce_fake_paniced;
17708
17709 /* Panic in progress. Enable interrupts and wait for final IPI */
17710 static void wait_for_panic(void)
17711 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17712 /*
17713 * Make sure only one CPU runs in machine check panic
17714 */
17715 - if (atomic_inc_return(&mce_paniced) > 1)
17716 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
17717 wait_for_panic();
17718 barrier();
17719
17720 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17721 console_verbose();
17722 } else {
17723 /* Don't log too much for fake panic */
17724 - if (atomic_inc_return(&mce_fake_paniced) > 1)
17725 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
17726 return;
17727 }
17728 /* First print corrected ones that are still unlogged */
17729 @@ -686,7 +687,7 @@ static int mce_timed_out(u64 *t)
17730 * might have been modified by someone else.
17731 */
17732 rmb();
17733 - if (atomic_read(&mce_paniced))
17734 + if (atomic_read_unchecked(&mce_paniced))
17735 wait_for_panic();
17736 if (!mca_cfg.monarch_timeout)
17737 goto out;
17738 @@ -1662,7 +1663,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17739 }
17740
17741 /* Call the installed machine check handler for this CPU setup. */
17742 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
17743 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
17744 unexpected_machine_check;
17745
17746 /*
17747 @@ -1685,7 +1686,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17748 return;
17749 }
17750
17751 + pax_open_kernel();
17752 machine_check_vector = do_machine_check;
17753 + pax_close_kernel();
17754
17755 __mcheck_cpu_init_generic();
17756 __mcheck_cpu_init_vendor(c);
17757 @@ -1699,7 +1702,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17758 */
17759
17760 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
17761 -static int mce_chrdev_open_count; /* #times opened */
17762 +static local_t mce_chrdev_open_count; /* #times opened */
17763 static int mce_chrdev_open_exclu; /* already open exclusive? */
17764
17765 static int mce_chrdev_open(struct inode *inode, struct file *file)
17766 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17767 spin_lock(&mce_chrdev_state_lock);
17768
17769 if (mce_chrdev_open_exclu ||
17770 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
17771 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
17772 spin_unlock(&mce_chrdev_state_lock);
17773
17774 return -EBUSY;
17775 @@ -1715,7 +1718,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17776
17777 if (file->f_flags & O_EXCL)
17778 mce_chrdev_open_exclu = 1;
17779 - mce_chrdev_open_count++;
17780 + local_inc(&mce_chrdev_open_count);
17781
17782 spin_unlock(&mce_chrdev_state_lock);
17783
17784 @@ -1726,7 +1729,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
17785 {
17786 spin_lock(&mce_chrdev_state_lock);
17787
17788 - mce_chrdev_open_count--;
17789 + local_dec(&mce_chrdev_open_count);
17790 mce_chrdev_open_exclu = 0;
17791
17792 spin_unlock(&mce_chrdev_state_lock);
17793 @@ -2372,7 +2375,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
17794 return NOTIFY_OK;
17795 }
17796
17797 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
17798 +static struct notifier_block mce_cpu_notifier = {
17799 .notifier_call = mce_cpu_callback,
17800 };
17801
17802 @@ -2382,7 +2385,7 @@ static __init void mce_init_banks(void)
17803
17804 for (i = 0; i < mca_cfg.banks; i++) {
17805 struct mce_bank *b = &mce_banks[i];
17806 - struct device_attribute *a = &b->attr;
17807 + device_attribute_no_const *a = &b->attr;
17808
17809 sysfs_attr_init(&a->attr);
17810 a->attr.name = b->attrname;
17811 @@ -2450,7 +2453,7 @@ struct dentry *mce_get_debugfs_dir(void)
17812 static void mce_reset(void)
17813 {
17814 cpu_missing = 0;
17815 - atomic_set(&mce_fake_paniced, 0);
17816 + atomic_set_unchecked(&mce_fake_paniced, 0);
17817 atomic_set(&mce_executing, 0);
17818 atomic_set(&mce_callin, 0);
17819 atomic_set(&global_nwo, 0);
17820 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
17821 index 2d5454c..51987eb 100644
17822 --- a/arch/x86/kernel/cpu/mcheck/p5.c
17823 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
17824 @@ -11,6 +11,7 @@
17825 #include <asm/processor.h>
17826 #include <asm/mce.h>
17827 #include <asm/msr.h>
17828 +#include <asm/pgtable.h>
17829
17830 /* By default disabled */
17831 int mce_p5_enabled __read_mostly;
17832 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
17833 if (!cpu_has(c, X86_FEATURE_MCE))
17834 return;
17835
17836 + pax_open_kernel();
17837 machine_check_vector = pentium_machine_check;
17838 + pax_close_kernel();
17839 /* Make sure the vector pointer is visible before we enable MCEs: */
17840 wmb();
17841
17842 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17843 index 47a1870..8c019a7 100644
17844 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
17845 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17846 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
17847 return notifier_from_errno(err);
17848 }
17849
17850 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
17851 +static struct notifier_block thermal_throttle_cpu_notifier =
17852 {
17853 .notifier_call = thermal_throttle_cpu_callback,
17854 };
17855 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
17856 index 2d7998f..17c9de1 100644
17857 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
17858 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
17859 @@ -10,6 +10,7 @@
17860 #include <asm/processor.h>
17861 #include <asm/mce.h>
17862 #include <asm/msr.h>
17863 +#include <asm/pgtable.h>
17864
17865 /* Machine check handler for WinChip C6: */
17866 static void winchip_machine_check(struct pt_regs *regs, long error_code)
17867 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
17868 {
17869 u32 lo, hi;
17870
17871 + pax_open_kernel();
17872 machine_check_vector = winchip_machine_check;
17873 + pax_close_kernel();
17874 /* Make sure the vector pointer is visible before we enable MCEs: */
17875 wmb();
17876
17877 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
17878 index 726bf96..81f0526 100644
17879 --- a/arch/x86/kernel/cpu/mtrr/main.c
17880 +++ b/arch/x86/kernel/cpu/mtrr/main.c
17881 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
17882 u64 size_or_mask, size_and_mask;
17883 static bool mtrr_aps_delayed_init;
17884
17885 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
17886 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
17887
17888 const struct mtrr_ops *mtrr_if;
17889
17890 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
17891 index df5e41f..816c719 100644
17892 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
17893 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
17894 @@ -25,7 +25,7 @@ struct mtrr_ops {
17895 int (*validate_add_page)(unsigned long base, unsigned long size,
17896 unsigned int type);
17897 int (*have_wrcomb)(void);
17898 -};
17899 +} __do_const;
17900
17901 extern int generic_get_free_region(unsigned long base, unsigned long size,
17902 int replace_reg);
17903 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
17904 index 6774c17..72c1b22 100644
17905 --- a/arch/x86/kernel/cpu/perf_event.c
17906 +++ b/arch/x86/kernel/cpu/perf_event.c
17907 @@ -1305,7 +1305,7 @@ static void __init pmu_check_apic(void)
17908 pr_info("no hardware sampling interrupt available.\n");
17909 }
17910
17911 -static struct attribute_group x86_pmu_format_group = {
17912 +static attribute_group_no_const x86_pmu_format_group = {
17913 .name = "format",
17914 .attrs = NULL,
17915 };
17916 @@ -1313,7 +1313,7 @@ static struct attribute_group x86_pmu_format_group = {
17917 struct perf_pmu_events_attr {
17918 struct device_attribute attr;
17919 u64 id;
17920 -};
17921 +} __do_const;
17922
17923 /*
17924 * Remove all undefined events (x86_pmu.event_map(id) == 0)
17925 @@ -1381,7 +1381,7 @@ static struct attribute *events_attr[] = {
17926 NULL,
17927 };
17928
17929 -static struct attribute_group x86_pmu_events_group = {
17930 +static attribute_group_no_const x86_pmu_events_group = {
17931 .name = "events",
17932 .attrs = events_attr,
17933 };
17934 @@ -1880,7 +1880,7 @@ static unsigned long get_segment_base(unsigned int segment)
17935 if (idx > GDT_ENTRIES)
17936 return 0;
17937
17938 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
17939 + desc = get_cpu_gdt_table(smp_processor_id());
17940 }
17941
17942 return get_desc_base(desc + idx);
17943 @@ -1970,7 +1970,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
17944 break;
17945
17946 perf_callchain_store(entry, frame.return_address);
17947 - fp = frame.next_frame;
17948 + fp = (const void __force_user *)frame.next_frame;
17949 }
17950 }
17951
17952 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
17953 index 4914e94..60b06e3 100644
17954 --- a/arch/x86/kernel/cpu/perf_event_intel.c
17955 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
17956 @@ -1958,10 +1958,10 @@ __init int intel_pmu_init(void)
17957 * v2 and above have a perf capabilities MSR
17958 */
17959 if (version > 1) {
17960 - u64 capabilities;
17961 + u64 capabilities = x86_pmu.intel_cap.capabilities;
17962
17963 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
17964 - x86_pmu.intel_cap.capabilities = capabilities;
17965 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
17966 + x86_pmu.intel_cap.capabilities = capabilities;
17967 }
17968
17969 intel_ds_init();
17970 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17971 index b43200d..d235b3e 100644
17972 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17973 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17974 @@ -2428,7 +2428,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
17975 static int __init uncore_type_init(struct intel_uncore_type *type)
17976 {
17977 struct intel_uncore_pmu *pmus;
17978 - struct attribute_group *events_group;
17979 + attribute_group_no_const *attr_group;
17980 struct attribute **attrs;
17981 int i, j;
17982
17983 @@ -2455,19 +2455,19 @@ static int __init uncore_type_init(struct intel_uncore_type *type)
17984 while (type->event_descs[i].attr.attr.name)
17985 i++;
17986
17987 - events_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
17988 - sizeof(*events_group), GFP_KERNEL);
17989 - if (!events_group)
17990 + attr_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
17991 + sizeof(*attr_group), GFP_KERNEL);
17992 + if (!attr_group)
17993 goto fail;
17994
17995 - attrs = (struct attribute **)(events_group + 1);
17996 - events_group->name = "events";
17997 - events_group->attrs = attrs;
17998 + attrs = (struct attribute **)(attr_group + 1);
17999 + attr_group->name = "events";
18000 + attr_group->attrs = attrs;
18001
18002 for (j = 0; j < i; j++)
18003 attrs[j] = &type->event_descs[j].attr.attr;
18004
18005 - type->events_group = events_group;
18006 + type->events_group = attr_group;
18007 }
18008
18009 type->pmu_group = &uncore_pmu_attr_group;
18010 @@ -2826,7 +2826,7 @@ static int
18011 return NOTIFY_OK;
18012 }
18013
18014 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
18015 +static struct notifier_block uncore_cpu_nb = {
18016 .notifier_call = uncore_cpu_notifier,
18017 /*
18018 * to migrate uncore events, our notifier should be executed
18019 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18020 index e68a455..975a932 100644
18021 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18022 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18023 @@ -428,7 +428,7 @@ struct intel_uncore_box {
18024 struct uncore_event_desc {
18025 struct kobj_attribute attr;
18026 const char *config;
18027 -};
18028 +} __do_const;
18029
18030 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
18031 { \
18032 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
18033 index 60c7891..9e911d3 100644
18034 --- a/arch/x86/kernel/cpuid.c
18035 +++ b/arch/x86/kernel/cpuid.c
18036 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
18037 return notifier_from_errno(err);
18038 }
18039
18040 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
18041 +static struct notifier_block cpuid_class_cpu_notifier =
18042 {
18043 .notifier_call = cpuid_class_cpu_callback,
18044 };
18045 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
18046 index 74467fe..18793d5 100644
18047 --- a/arch/x86/kernel/crash.c
18048 +++ b/arch/x86/kernel/crash.c
18049 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
18050 {
18051 #ifdef CONFIG_X86_32
18052 struct pt_regs fixed_regs;
18053 -#endif
18054
18055 -#ifdef CONFIG_X86_32
18056 - if (!user_mode_vm(regs)) {
18057 + if (!user_mode(regs)) {
18058 crash_fixup_ss_esp(&fixed_regs, regs);
18059 regs = &fixed_regs;
18060 }
18061 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
18062 index 37250fe..bf2ec74 100644
18063 --- a/arch/x86/kernel/doublefault_32.c
18064 +++ b/arch/x86/kernel/doublefault_32.c
18065 @@ -11,7 +11,7 @@
18066
18067 #define DOUBLEFAULT_STACKSIZE (1024)
18068 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
18069 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
18070 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
18071
18072 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
18073
18074 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
18075 unsigned long gdt, tss;
18076
18077 store_gdt(&gdt_desc);
18078 - gdt = gdt_desc.address;
18079 + gdt = (unsigned long)gdt_desc.address;
18080
18081 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
18082
18083 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
18084 /* 0x2 bit is always set */
18085 .flags = X86_EFLAGS_SF | 0x2,
18086 .sp = STACK_START,
18087 - .es = __USER_DS,
18088 + .es = __KERNEL_DS,
18089 .cs = __KERNEL_CS,
18090 .ss = __KERNEL_DS,
18091 - .ds = __USER_DS,
18092 + .ds = __KERNEL_DS,
18093 .fs = __KERNEL_PERCPU,
18094
18095 .__cr3 = __pa_nodebug(swapper_pg_dir),
18096 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
18097 index ae42418b..787c16b 100644
18098 --- a/arch/x86/kernel/dumpstack.c
18099 +++ b/arch/x86/kernel/dumpstack.c
18100 @@ -2,6 +2,9 @@
18101 * Copyright (C) 1991, 1992 Linus Torvalds
18102 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
18103 */
18104 +#ifdef CONFIG_GRKERNSEC_HIDESYM
18105 +#define __INCLUDED_BY_HIDESYM 1
18106 +#endif
18107 #include <linux/kallsyms.h>
18108 #include <linux/kprobes.h>
18109 #include <linux/uaccess.h>
18110 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
18111 static void
18112 print_ftrace_graph_addr(unsigned long addr, void *data,
18113 const struct stacktrace_ops *ops,
18114 - struct thread_info *tinfo, int *graph)
18115 + struct task_struct *task, int *graph)
18116 {
18117 - struct task_struct *task;
18118 unsigned long ret_addr;
18119 int index;
18120
18121 if (addr != (unsigned long)return_to_handler)
18122 return;
18123
18124 - task = tinfo->task;
18125 index = task->curr_ret_stack;
18126
18127 if (!task->ret_stack || index < *graph)
18128 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
18129 static inline void
18130 print_ftrace_graph_addr(unsigned long addr, void *data,
18131 const struct stacktrace_ops *ops,
18132 - struct thread_info *tinfo, int *graph)
18133 + struct task_struct *task, int *graph)
18134 { }
18135 #endif
18136
18137 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
18138 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
18139 */
18140
18141 -static inline int valid_stack_ptr(struct thread_info *tinfo,
18142 - void *p, unsigned int size, void *end)
18143 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
18144 {
18145 - void *t = tinfo;
18146 if (end) {
18147 if (p < end && p >= (end-THREAD_SIZE))
18148 return 1;
18149 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
18150 }
18151
18152 unsigned long
18153 -print_context_stack(struct thread_info *tinfo,
18154 +print_context_stack(struct task_struct *task, void *stack_start,
18155 unsigned long *stack, unsigned long bp,
18156 const struct stacktrace_ops *ops, void *data,
18157 unsigned long *end, int *graph)
18158 {
18159 struct stack_frame *frame = (struct stack_frame *)bp;
18160
18161 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
18162 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
18163 unsigned long addr;
18164
18165 addr = *stack;
18166 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
18167 } else {
18168 ops->address(data, addr, 0);
18169 }
18170 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
18171 + print_ftrace_graph_addr(addr, data, ops, task, graph);
18172 }
18173 stack++;
18174 }
18175 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
18176 EXPORT_SYMBOL_GPL(print_context_stack);
18177
18178 unsigned long
18179 -print_context_stack_bp(struct thread_info *tinfo,
18180 +print_context_stack_bp(struct task_struct *task, void *stack_start,
18181 unsigned long *stack, unsigned long bp,
18182 const struct stacktrace_ops *ops, void *data,
18183 unsigned long *end, int *graph)
18184 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
18185 struct stack_frame *frame = (struct stack_frame *)bp;
18186 unsigned long *ret_addr = &frame->return_address;
18187
18188 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
18189 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
18190 unsigned long addr = *ret_addr;
18191
18192 if (!__kernel_text_address(addr))
18193 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
18194 ops->address(data, addr, 1);
18195 frame = frame->next_frame;
18196 ret_addr = &frame->return_address;
18197 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
18198 + print_ftrace_graph_addr(addr, data, ops, task, graph);
18199 }
18200
18201 return (unsigned long)frame;
18202 @@ -189,7 +188,7 @@ void dump_stack(void)
18203
18204 bp = stack_frame(current, NULL);
18205 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
18206 - current->pid, current->comm, print_tainted(),
18207 + task_pid_nr(current), current->comm, print_tainted(),
18208 init_utsname()->release,
18209 (int)strcspn(init_utsname()->version, " "),
18210 init_utsname()->version);
18211 @@ -225,6 +224,8 @@ unsigned __kprobes long oops_begin(void)
18212 }
18213 EXPORT_SYMBOL_GPL(oops_begin);
18214
18215 +extern void gr_handle_kernel_exploit(void);
18216 +
18217 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
18218 {
18219 if (regs && kexec_should_crash(current))
18220 @@ -246,7 +247,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
18221 panic("Fatal exception in interrupt");
18222 if (panic_on_oops)
18223 panic("Fatal exception");
18224 - do_exit(signr);
18225 +
18226 + gr_handle_kernel_exploit();
18227 +
18228 + do_group_exit(signr);
18229 }
18230
18231 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
18232 @@ -274,7 +278,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
18233 print_modules();
18234 show_regs(regs);
18235 #ifdef CONFIG_X86_32
18236 - if (user_mode_vm(regs)) {
18237 + if (user_mode(regs)) {
18238 sp = regs->sp;
18239 ss = regs->ss & 0xffff;
18240 } else {
18241 @@ -302,7 +306,7 @@ void die(const char *str, struct pt_regs *regs, long err)
18242 unsigned long flags = oops_begin();
18243 int sig = SIGSEGV;
18244
18245 - if (!user_mode_vm(regs))
18246 + if (!user_mode(regs))
18247 report_bug(regs->ip, regs);
18248
18249 if (__die(str, regs, err))
18250 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
18251 index 1038a41..db2c12b 100644
18252 --- a/arch/x86/kernel/dumpstack_32.c
18253 +++ b/arch/x86/kernel/dumpstack_32.c
18254 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18255 bp = stack_frame(task, regs);
18256
18257 for (;;) {
18258 - struct thread_info *context;
18259 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18260
18261 - context = (struct thread_info *)
18262 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
18263 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
18264 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18265
18266 - stack = (unsigned long *)context->previous_esp;
18267 - if (!stack)
18268 + if (stack_start == task_stack_page(task))
18269 break;
18270 + stack = *(unsigned long **)stack_start;
18271 if (ops->stack(data, "IRQ") < 0)
18272 break;
18273 touch_nmi_watchdog();
18274 @@ -86,7 +84,7 @@ void show_regs(struct pt_regs *regs)
18275 {
18276 int i;
18277
18278 - __show_regs(regs, !user_mode_vm(regs));
18279 + __show_regs(regs, !user_mode(regs));
18280
18281 pr_emerg("Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)\n",
18282 TASK_COMM_LEN, current->comm, task_pid_nr(current),
18283 @@ -95,21 +93,22 @@ void show_regs(struct pt_regs *regs)
18284 * When in-kernel, we also print out the stack and code at the
18285 * time of the fault..
18286 */
18287 - if (!user_mode_vm(regs)) {
18288 + if (!user_mode(regs)) {
18289 unsigned int code_prologue = code_bytes * 43 / 64;
18290 unsigned int code_len = code_bytes;
18291 unsigned char c;
18292 u8 *ip;
18293 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
18294
18295 pr_emerg("Stack:\n");
18296 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
18297
18298 pr_emerg("Code:");
18299
18300 - ip = (u8 *)regs->ip - code_prologue;
18301 + ip = (u8 *)regs->ip - code_prologue + cs_base;
18302 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
18303 /* try starting at IP */
18304 - ip = (u8 *)regs->ip;
18305 + ip = (u8 *)regs->ip + cs_base;
18306 code_len = code_len - code_prologue + 1;
18307 }
18308 for (i = 0; i < code_len; i++, ip++) {
18309 @@ -118,7 +117,7 @@ void show_regs(struct pt_regs *regs)
18310 pr_cont(" Bad EIP value.");
18311 break;
18312 }
18313 - if (ip == (u8 *)regs->ip)
18314 + if (ip == (u8 *)regs->ip + cs_base)
18315 pr_cont(" <%02x>", c);
18316 else
18317 pr_cont(" %02x", c);
18318 @@ -131,6 +130,7 @@ int is_valid_bugaddr(unsigned long ip)
18319 {
18320 unsigned short ud2;
18321
18322 + ip = ktla_ktva(ip);
18323 if (ip < PAGE_OFFSET)
18324 return 0;
18325 if (probe_kernel_address((unsigned short *)ip, ud2))
18326 @@ -138,3 +138,15 @@ int is_valid_bugaddr(unsigned long ip)
18327
18328 return ud2 == 0x0b0f;
18329 }
18330 +
18331 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18332 +void pax_check_alloca(unsigned long size)
18333 +{
18334 + unsigned long sp = (unsigned long)&sp, stack_left;
18335 +
18336 + /* all kernel stacks are of the same size */
18337 + stack_left = sp & (THREAD_SIZE - 1);
18338 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18339 +}
18340 +EXPORT_SYMBOL(pax_check_alloca);
18341 +#endif
18342 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
18343 index b653675..51cc8c0 100644
18344 --- a/arch/x86/kernel/dumpstack_64.c
18345 +++ b/arch/x86/kernel/dumpstack_64.c
18346 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18347 unsigned long *irq_stack_end =
18348 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
18349 unsigned used = 0;
18350 - struct thread_info *tinfo;
18351 int graph = 0;
18352 unsigned long dummy;
18353 + void *stack_start;
18354
18355 if (!task)
18356 task = current;
18357 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18358 * current stack address. If the stacks consist of nested
18359 * exceptions
18360 */
18361 - tinfo = task_thread_info(task);
18362 for (;;) {
18363 char *id;
18364 unsigned long *estack_end;
18365 +
18366 estack_end = in_exception_stack(cpu, (unsigned long)stack,
18367 &used, &id);
18368
18369 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18370 if (ops->stack(data, id) < 0)
18371 break;
18372
18373 - bp = ops->walk_stack(tinfo, stack, bp, ops,
18374 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
18375 data, estack_end, &graph);
18376 ops->stack(data, "<EOE>");
18377 /*
18378 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18379 * second-to-last pointer (index -2 to end) in the
18380 * exception stack:
18381 */
18382 + if ((u16)estack_end[-1] != __KERNEL_DS)
18383 + goto out;
18384 stack = (unsigned long *) estack_end[-2];
18385 continue;
18386 }
18387 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18388 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
18389 if (ops->stack(data, "IRQ") < 0)
18390 break;
18391 - bp = ops->walk_stack(tinfo, stack, bp,
18392 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18393 ops, data, irq_stack_end, &graph);
18394 /*
18395 * We link to the next stack (which would be
18396 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18397 /*
18398 * This handles the process stack:
18399 */
18400 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18401 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18402 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18403 +out:
18404 put_cpu();
18405 }
18406 EXPORT_SYMBOL(dump_trace);
18407 @@ -249,7 +253,7 @@ void show_regs(struct pt_regs *regs)
18408 {
18409 int i;
18410 unsigned long sp;
18411 - const int cpu = smp_processor_id();
18412 + const int cpu = raw_smp_processor_id();
18413 struct task_struct *cur = current;
18414
18415 sp = regs->sp;
18416 @@ -304,3 +308,50 @@ int is_valid_bugaddr(unsigned long ip)
18417
18418 return ud2 == 0x0b0f;
18419 }
18420 +
18421 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18422 +void pax_check_alloca(unsigned long size)
18423 +{
18424 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18425 + unsigned cpu, used;
18426 + char *id;
18427 +
18428 + /* check the process stack first */
18429 + stack_start = (unsigned long)task_stack_page(current);
18430 + stack_end = stack_start + THREAD_SIZE;
18431 + if (likely(stack_start <= sp && sp < stack_end)) {
18432 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18433 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18434 + return;
18435 + }
18436 +
18437 + cpu = get_cpu();
18438 +
18439 + /* check the irq stacks */
18440 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18441 + stack_start = stack_end - IRQ_STACK_SIZE;
18442 + if (stack_start <= sp && sp < stack_end) {
18443 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18444 + put_cpu();
18445 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18446 + return;
18447 + }
18448 +
18449 + /* check the exception stacks */
18450 + used = 0;
18451 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18452 + stack_start = stack_end - EXCEPTION_STKSZ;
18453 + if (stack_end && stack_start <= sp && sp < stack_end) {
18454 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18455 + put_cpu();
18456 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18457 + return;
18458 + }
18459 +
18460 + put_cpu();
18461 +
18462 + /* unknown stack */
18463 + BUG();
18464 +}
18465 +EXPORT_SYMBOL(pax_check_alloca);
18466 +#endif
18467 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18468 index 9b9f18b..9fcaa04 100644
18469 --- a/arch/x86/kernel/early_printk.c
18470 +++ b/arch/x86/kernel/early_printk.c
18471 @@ -7,6 +7,7 @@
18472 #include <linux/pci_regs.h>
18473 #include <linux/pci_ids.h>
18474 #include <linux/errno.h>
18475 +#include <linux/sched.h>
18476 #include <asm/io.h>
18477 #include <asm/processor.h>
18478 #include <asm/fcntl.h>
18479 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18480 index 6ed91d9..6cc365b 100644
18481 --- a/arch/x86/kernel/entry_32.S
18482 +++ b/arch/x86/kernel/entry_32.S
18483 @@ -177,13 +177,153 @@
18484 /*CFI_REL_OFFSET gs, PT_GS*/
18485 .endm
18486 .macro SET_KERNEL_GS reg
18487 +
18488 +#ifdef CONFIG_CC_STACKPROTECTOR
18489 movl $(__KERNEL_STACK_CANARY), \reg
18490 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18491 + movl $(__USER_DS), \reg
18492 +#else
18493 + xorl \reg, \reg
18494 +#endif
18495 +
18496 movl \reg, %gs
18497 .endm
18498
18499 #endif /* CONFIG_X86_32_LAZY_GS */
18500
18501 -.macro SAVE_ALL
18502 +.macro pax_enter_kernel
18503 +#ifdef CONFIG_PAX_KERNEXEC
18504 + call pax_enter_kernel
18505 +#endif
18506 +.endm
18507 +
18508 +.macro pax_exit_kernel
18509 +#ifdef CONFIG_PAX_KERNEXEC
18510 + call pax_exit_kernel
18511 +#endif
18512 +.endm
18513 +
18514 +#ifdef CONFIG_PAX_KERNEXEC
18515 +ENTRY(pax_enter_kernel)
18516 +#ifdef CONFIG_PARAVIRT
18517 + pushl %eax
18518 + pushl %ecx
18519 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18520 + mov %eax, %esi
18521 +#else
18522 + mov %cr0, %esi
18523 +#endif
18524 + bts $16, %esi
18525 + jnc 1f
18526 + mov %cs, %esi
18527 + cmp $__KERNEL_CS, %esi
18528 + jz 3f
18529 + ljmp $__KERNEL_CS, $3f
18530 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18531 +2:
18532 +#ifdef CONFIG_PARAVIRT
18533 + mov %esi, %eax
18534 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18535 +#else
18536 + mov %esi, %cr0
18537 +#endif
18538 +3:
18539 +#ifdef CONFIG_PARAVIRT
18540 + popl %ecx
18541 + popl %eax
18542 +#endif
18543 + ret
18544 +ENDPROC(pax_enter_kernel)
18545 +
18546 +ENTRY(pax_exit_kernel)
18547 +#ifdef CONFIG_PARAVIRT
18548 + pushl %eax
18549 + pushl %ecx
18550 +#endif
18551 + mov %cs, %esi
18552 + cmp $__KERNEXEC_KERNEL_CS, %esi
18553 + jnz 2f
18554 +#ifdef CONFIG_PARAVIRT
18555 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18556 + mov %eax, %esi
18557 +#else
18558 + mov %cr0, %esi
18559 +#endif
18560 + btr $16, %esi
18561 + ljmp $__KERNEL_CS, $1f
18562 +1:
18563 +#ifdef CONFIG_PARAVIRT
18564 + mov %esi, %eax
18565 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18566 +#else
18567 + mov %esi, %cr0
18568 +#endif
18569 +2:
18570 +#ifdef CONFIG_PARAVIRT
18571 + popl %ecx
18572 + popl %eax
18573 +#endif
18574 + ret
18575 +ENDPROC(pax_exit_kernel)
18576 +#endif
18577 +
18578 +.macro pax_erase_kstack
18579 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18580 + call pax_erase_kstack
18581 +#endif
18582 +.endm
18583 +
18584 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18585 +/*
18586 + * ebp: thread_info
18587 + */
18588 +ENTRY(pax_erase_kstack)
18589 + pushl %edi
18590 + pushl %ecx
18591 + pushl %eax
18592 +
18593 + mov TI_lowest_stack(%ebp), %edi
18594 + mov $-0xBEEF, %eax
18595 + std
18596 +
18597 +1: mov %edi, %ecx
18598 + and $THREAD_SIZE_asm - 1, %ecx
18599 + shr $2, %ecx
18600 + repne scasl
18601 + jecxz 2f
18602 +
18603 + cmp $2*16, %ecx
18604 + jc 2f
18605 +
18606 + mov $2*16, %ecx
18607 + repe scasl
18608 + jecxz 2f
18609 + jne 1b
18610 +
18611 +2: cld
18612 + mov %esp, %ecx
18613 + sub %edi, %ecx
18614 +
18615 + cmp $THREAD_SIZE_asm, %ecx
18616 + jb 3f
18617 + ud2
18618 +3:
18619 +
18620 + shr $2, %ecx
18621 + rep stosl
18622 +
18623 + mov TI_task_thread_sp0(%ebp), %edi
18624 + sub $128, %edi
18625 + mov %edi, TI_lowest_stack(%ebp)
18626 +
18627 + popl %eax
18628 + popl %ecx
18629 + popl %edi
18630 + ret
18631 +ENDPROC(pax_erase_kstack)
18632 +#endif
18633 +
18634 +.macro __SAVE_ALL _DS
18635 cld
18636 PUSH_GS
18637 pushl_cfi %fs
18638 @@ -206,7 +346,7 @@
18639 CFI_REL_OFFSET ecx, 0
18640 pushl_cfi %ebx
18641 CFI_REL_OFFSET ebx, 0
18642 - movl $(__USER_DS), %edx
18643 + movl $\_DS, %edx
18644 movl %edx, %ds
18645 movl %edx, %es
18646 movl $(__KERNEL_PERCPU), %edx
18647 @@ -214,6 +354,15 @@
18648 SET_KERNEL_GS %edx
18649 .endm
18650
18651 +.macro SAVE_ALL
18652 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18653 + __SAVE_ALL __KERNEL_DS
18654 + pax_enter_kernel
18655 +#else
18656 + __SAVE_ALL __USER_DS
18657 +#endif
18658 +.endm
18659 +
18660 .macro RESTORE_INT_REGS
18661 popl_cfi %ebx
18662 CFI_RESTORE ebx
18663 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18664 popfl_cfi
18665 jmp syscall_exit
18666 CFI_ENDPROC
18667 -END(ret_from_fork)
18668 +ENDPROC(ret_from_fork)
18669
18670 ENTRY(ret_from_kernel_thread)
18671 CFI_STARTPROC
18672 @@ -344,7 +493,15 @@ ret_from_intr:
18673 andl $SEGMENT_RPL_MASK, %eax
18674 #endif
18675 cmpl $USER_RPL, %eax
18676 +
18677 +#ifdef CONFIG_PAX_KERNEXEC
18678 + jae resume_userspace
18679 +
18680 + pax_exit_kernel
18681 + jmp resume_kernel
18682 +#else
18683 jb resume_kernel # not returning to v8086 or userspace
18684 +#endif
18685
18686 ENTRY(resume_userspace)
18687 LOCKDEP_SYS_EXIT
18688 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18689 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18690 # int/exception return?
18691 jne work_pending
18692 - jmp restore_all
18693 -END(ret_from_exception)
18694 + jmp restore_all_pax
18695 +ENDPROC(ret_from_exception)
18696
18697 #ifdef CONFIG_PREEMPT
18698 ENTRY(resume_kernel)
18699 @@ -372,7 +529,7 @@ need_resched:
18700 jz restore_all
18701 call preempt_schedule_irq
18702 jmp need_resched
18703 -END(resume_kernel)
18704 +ENDPROC(resume_kernel)
18705 #endif
18706 CFI_ENDPROC
18707 /*
18708 @@ -406,30 +563,45 @@ sysenter_past_esp:
18709 /*CFI_REL_OFFSET cs, 0*/
18710 /*
18711 * Push current_thread_info()->sysenter_return to the stack.
18712 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18713 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18714 */
18715 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18716 + pushl_cfi $0
18717 CFI_REL_OFFSET eip, 0
18718
18719 pushl_cfi %eax
18720 SAVE_ALL
18721 + GET_THREAD_INFO(%ebp)
18722 + movl TI_sysenter_return(%ebp),%ebp
18723 + movl %ebp,PT_EIP(%esp)
18724 ENABLE_INTERRUPTS(CLBR_NONE)
18725
18726 /*
18727 * Load the potential sixth argument from user stack.
18728 * Careful about security.
18729 */
18730 + movl PT_OLDESP(%esp),%ebp
18731 +
18732 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18733 + mov PT_OLDSS(%esp),%ds
18734 +1: movl %ds:(%ebp),%ebp
18735 + push %ss
18736 + pop %ds
18737 +#else
18738 cmpl $__PAGE_OFFSET-3,%ebp
18739 jae syscall_fault
18740 ASM_STAC
18741 1: movl (%ebp),%ebp
18742 ASM_CLAC
18743 +#endif
18744 +
18745 movl %ebp,PT_EBP(%esp)
18746 _ASM_EXTABLE(1b,syscall_fault)
18747
18748 GET_THREAD_INFO(%ebp)
18749
18750 +#ifdef CONFIG_PAX_RANDKSTACK
18751 + pax_erase_kstack
18752 +#endif
18753 +
18754 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18755 jnz sysenter_audit
18756 sysenter_do_call:
18757 @@ -444,12 +616,24 @@ sysenter_do_call:
18758 testl $_TIF_ALLWORK_MASK, %ecx
18759 jne sysexit_audit
18760 sysenter_exit:
18761 +
18762 +#ifdef CONFIG_PAX_RANDKSTACK
18763 + pushl_cfi %eax
18764 + movl %esp, %eax
18765 + call pax_randomize_kstack
18766 + popl_cfi %eax
18767 +#endif
18768 +
18769 + pax_erase_kstack
18770 +
18771 /* if something modifies registers it must also disable sysexit */
18772 movl PT_EIP(%esp), %edx
18773 movl PT_OLDESP(%esp), %ecx
18774 xorl %ebp,%ebp
18775 TRACE_IRQS_ON
18776 1: mov PT_FS(%esp), %fs
18777 +2: mov PT_DS(%esp), %ds
18778 +3: mov PT_ES(%esp), %es
18779 PTGS_TO_GS
18780 ENABLE_INTERRUPTS_SYSEXIT
18781
18782 @@ -466,6 +650,9 @@ sysenter_audit:
18783 movl %eax,%edx /* 2nd arg: syscall number */
18784 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18785 call __audit_syscall_entry
18786 +
18787 + pax_erase_kstack
18788 +
18789 pushl_cfi %ebx
18790 movl PT_EAX(%esp),%eax /* reload syscall number */
18791 jmp sysenter_do_call
18792 @@ -491,10 +678,16 @@ sysexit_audit:
18793
18794 CFI_ENDPROC
18795 .pushsection .fixup,"ax"
18796 -2: movl $0,PT_FS(%esp)
18797 +4: movl $0,PT_FS(%esp)
18798 + jmp 1b
18799 +5: movl $0,PT_DS(%esp)
18800 + jmp 1b
18801 +6: movl $0,PT_ES(%esp)
18802 jmp 1b
18803 .popsection
18804 - _ASM_EXTABLE(1b,2b)
18805 + _ASM_EXTABLE(1b,4b)
18806 + _ASM_EXTABLE(2b,5b)
18807 + _ASM_EXTABLE(3b,6b)
18808 PTGS_TO_GS_EX
18809 ENDPROC(ia32_sysenter_target)
18810
18811 @@ -509,6 +702,11 @@ ENTRY(system_call)
18812 pushl_cfi %eax # save orig_eax
18813 SAVE_ALL
18814 GET_THREAD_INFO(%ebp)
18815 +
18816 +#ifdef CONFIG_PAX_RANDKSTACK
18817 + pax_erase_kstack
18818 +#endif
18819 +
18820 # system call tracing in operation / emulation
18821 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18822 jnz syscall_trace_entry
18823 @@ -527,6 +725,15 @@ syscall_exit:
18824 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18825 jne syscall_exit_work
18826
18827 +restore_all_pax:
18828 +
18829 +#ifdef CONFIG_PAX_RANDKSTACK
18830 + movl %esp, %eax
18831 + call pax_randomize_kstack
18832 +#endif
18833 +
18834 + pax_erase_kstack
18835 +
18836 restore_all:
18837 TRACE_IRQS_IRET
18838 restore_all_notrace:
18839 @@ -583,14 +790,34 @@ ldt_ss:
18840 * compensating for the offset by changing to the ESPFIX segment with
18841 * a base address that matches for the difference.
18842 */
18843 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18844 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18845 mov %esp, %edx /* load kernel esp */
18846 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18847 mov %dx, %ax /* eax: new kernel esp */
18848 sub %eax, %edx /* offset (low word is 0) */
18849 +#ifdef CONFIG_SMP
18850 + movl PER_CPU_VAR(cpu_number), %ebx
18851 + shll $PAGE_SHIFT_asm, %ebx
18852 + addl $cpu_gdt_table, %ebx
18853 +#else
18854 + movl $cpu_gdt_table, %ebx
18855 +#endif
18856 shr $16, %edx
18857 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18858 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18859 +
18860 +#ifdef CONFIG_PAX_KERNEXEC
18861 + mov %cr0, %esi
18862 + btr $16, %esi
18863 + mov %esi, %cr0
18864 +#endif
18865 +
18866 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18867 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18868 +
18869 +#ifdef CONFIG_PAX_KERNEXEC
18870 + bts $16, %esi
18871 + mov %esi, %cr0
18872 +#endif
18873 +
18874 pushl_cfi $__ESPFIX_SS
18875 pushl_cfi %eax /* new kernel esp */
18876 /* Disable interrupts, but do not irqtrace this section: we
18877 @@ -619,20 +846,18 @@ work_resched:
18878 movl TI_flags(%ebp), %ecx
18879 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18880 # than syscall tracing?
18881 - jz restore_all
18882 + jz restore_all_pax
18883 testb $_TIF_NEED_RESCHED, %cl
18884 jnz work_resched
18885
18886 work_notifysig: # deal with pending signals and
18887 # notify-resume requests
18888 + movl %esp, %eax
18889 #ifdef CONFIG_VM86
18890 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18891 - movl %esp, %eax
18892 jne work_notifysig_v86 # returning to kernel-space or
18893 # vm86-space
18894 1:
18895 -#else
18896 - movl %esp, %eax
18897 #endif
18898 TRACE_IRQS_ON
18899 ENABLE_INTERRUPTS(CLBR_NONE)
18900 @@ -653,7 +878,7 @@ work_notifysig_v86:
18901 movl %eax, %esp
18902 jmp 1b
18903 #endif
18904 -END(work_pending)
18905 +ENDPROC(work_pending)
18906
18907 # perform syscall exit tracing
18908 ALIGN
18909 @@ -661,11 +886,14 @@ syscall_trace_entry:
18910 movl $-ENOSYS,PT_EAX(%esp)
18911 movl %esp, %eax
18912 call syscall_trace_enter
18913 +
18914 + pax_erase_kstack
18915 +
18916 /* What it returned is what we'll actually use. */
18917 cmpl $(NR_syscalls), %eax
18918 jnae syscall_call
18919 jmp syscall_exit
18920 -END(syscall_trace_entry)
18921 +ENDPROC(syscall_trace_entry)
18922
18923 # perform syscall exit tracing
18924 ALIGN
18925 @@ -678,21 +906,25 @@ syscall_exit_work:
18926 movl %esp, %eax
18927 call syscall_trace_leave
18928 jmp resume_userspace
18929 -END(syscall_exit_work)
18930 +ENDPROC(syscall_exit_work)
18931 CFI_ENDPROC
18932
18933 RING0_INT_FRAME # can't unwind into user space anyway
18934 syscall_fault:
18935 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18936 + push %ss
18937 + pop %ds
18938 +#endif
18939 ASM_CLAC
18940 GET_THREAD_INFO(%ebp)
18941 movl $-EFAULT,PT_EAX(%esp)
18942 jmp resume_userspace
18943 -END(syscall_fault)
18944 +ENDPROC(syscall_fault)
18945
18946 syscall_badsys:
18947 movl $-ENOSYS,PT_EAX(%esp)
18948 jmp resume_userspace
18949 -END(syscall_badsys)
18950 +ENDPROC(syscall_badsys)
18951 CFI_ENDPROC
18952 /*
18953 * End of kprobes section
18954 @@ -753,8 +985,15 @@ PTREGSCALL1(vm86old)
18955 * normal stack and adjusts ESP with the matching offset.
18956 */
18957 /* fixup the stack */
18958 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
18959 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
18960 +#ifdef CONFIG_SMP
18961 + movl PER_CPU_VAR(cpu_number), %ebx
18962 + shll $PAGE_SHIFT_asm, %ebx
18963 + addl $cpu_gdt_table, %ebx
18964 +#else
18965 + movl $cpu_gdt_table, %ebx
18966 +#endif
18967 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
18968 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
18969 shl $16, %eax
18970 addl %esp, %eax /* the adjusted stack pointer */
18971 pushl_cfi $__KERNEL_DS
18972 @@ -807,7 +1046,7 @@ vector=vector+1
18973 .endr
18974 2: jmp common_interrupt
18975 .endr
18976 -END(irq_entries_start)
18977 +ENDPROC(irq_entries_start)
18978
18979 .previous
18980 END(interrupt)
18981 @@ -858,7 +1097,7 @@ ENTRY(coprocessor_error)
18982 pushl_cfi $do_coprocessor_error
18983 jmp error_code
18984 CFI_ENDPROC
18985 -END(coprocessor_error)
18986 +ENDPROC(coprocessor_error)
18987
18988 ENTRY(simd_coprocessor_error)
18989 RING0_INT_FRAME
18990 @@ -880,7 +1119,7 @@ ENTRY(simd_coprocessor_error)
18991 #endif
18992 jmp error_code
18993 CFI_ENDPROC
18994 -END(simd_coprocessor_error)
18995 +ENDPROC(simd_coprocessor_error)
18996
18997 ENTRY(device_not_available)
18998 RING0_INT_FRAME
18999 @@ -889,18 +1128,18 @@ ENTRY(device_not_available)
19000 pushl_cfi $do_device_not_available
19001 jmp error_code
19002 CFI_ENDPROC
19003 -END(device_not_available)
19004 +ENDPROC(device_not_available)
19005
19006 #ifdef CONFIG_PARAVIRT
19007 ENTRY(native_iret)
19008 iret
19009 _ASM_EXTABLE(native_iret, iret_exc)
19010 -END(native_iret)
19011 +ENDPROC(native_iret)
19012
19013 ENTRY(native_irq_enable_sysexit)
19014 sti
19015 sysexit
19016 -END(native_irq_enable_sysexit)
19017 +ENDPROC(native_irq_enable_sysexit)
19018 #endif
19019
19020 ENTRY(overflow)
19021 @@ -910,7 +1149,7 @@ ENTRY(overflow)
19022 pushl_cfi $do_overflow
19023 jmp error_code
19024 CFI_ENDPROC
19025 -END(overflow)
19026 +ENDPROC(overflow)
19027
19028 ENTRY(bounds)
19029 RING0_INT_FRAME
19030 @@ -919,7 +1158,7 @@ ENTRY(bounds)
19031 pushl_cfi $do_bounds
19032 jmp error_code
19033 CFI_ENDPROC
19034 -END(bounds)
19035 +ENDPROC(bounds)
19036
19037 ENTRY(invalid_op)
19038 RING0_INT_FRAME
19039 @@ -928,7 +1167,7 @@ ENTRY(invalid_op)
19040 pushl_cfi $do_invalid_op
19041 jmp error_code
19042 CFI_ENDPROC
19043 -END(invalid_op)
19044 +ENDPROC(invalid_op)
19045
19046 ENTRY(coprocessor_segment_overrun)
19047 RING0_INT_FRAME
19048 @@ -937,7 +1176,7 @@ ENTRY(coprocessor_segment_overrun)
19049 pushl_cfi $do_coprocessor_segment_overrun
19050 jmp error_code
19051 CFI_ENDPROC
19052 -END(coprocessor_segment_overrun)
19053 +ENDPROC(coprocessor_segment_overrun)
19054
19055 ENTRY(invalid_TSS)
19056 RING0_EC_FRAME
19057 @@ -945,7 +1184,7 @@ ENTRY(invalid_TSS)
19058 pushl_cfi $do_invalid_TSS
19059 jmp error_code
19060 CFI_ENDPROC
19061 -END(invalid_TSS)
19062 +ENDPROC(invalid_TSS)
19063
19064 ENTRY(segment_not_present)
19065 RING0_EC_FRAME
19066 @@ -953,7 +1192,7 @@ ENTRY(segment_not_present)
19067 pushl_cfi $do_segment_not_present
19068 jmp error_code
19069 CFI_ENDPROC
19070 -END(segment_not_present)
19071 +ENDPROC(segment_not_present)
19072
19073 ENTRY(stack_segment)
19074 RING0_EC_FRAME
19075 @@ -961,7 +1200,7 @@ ENTRY(stack_segment)
19076 pushl_cfi $do_stack_segment
19077 jmp error_code
19078 CFI_ENDPROC
19079 -END(stack_segment)
19080 +ENDPROC(stack_segment)
19081
19082 ENTRY(alignment_check)
19083 RING0_EC_FRAME
19084 @@ -969,7 +1208,7 @@ ENTRY(alignment_check)
19085 pushl_cfi $do_alignment_check
19086 jmp error_code
19087 CFI_ENDPROC
19088 -END(alignment_check)
19089 +ENDPROC(alignment_check)
19090
19091 ENTRY(divide_error)
19092 RING0_INT_FRAME
19093 @@ -978,7 +1217,7 @@ ENTRY(divide_error)
19094 pushl_cfi $do_divide_error
19095 jmp error_code
19096 CFI_ENDPROC
19097 -END(divide_error)
19098 +ENDPROC(divide_error)
19099
19100 #ifdef CONFIG_X86_MCE
19101 ENTRY(machine_check)
19102 @@ -988,7 +1227,7 @@ ENTRY(machine_check)
19103 pushl_cfi machine_check_vector
19104 jmp error_code
19105 CFI_ENDPROC
19106 -END(machine_check)
19107 +ENDPROC(machine_check)
19108 #endif
19109
19110 ENTRY(spurious_interrupt_bug)
19111 @@ -998,7 +1237,7 @@ ENTRY(spurious_interrupt_bug)
19112 pushl_cfi $do_spurious_interrupt_bug
19113 jmp error_code
19114 CFI_ENDPROC
19115 -END(spurious_interrupt_bug)
19116 +ENDPROC(spurious_interrupt_bug)
19117 /*
19118 * End of kprobes section
19119 */
19120 @@ -1101,7 +1340,7 @@ BUILD_INTERRUPT3(xen_hvm_callback_vector, XEN_HVM_EVTCHN_CALLBACK,
19121
19122 ENTRY(mcount)
19123 ret
19124 -END(mcount)
19125 +ENDPROC(mcount)
19126
19127 ENTRY(ftrace_caller)
19128 cmpl $0, function_trace_stop
19129 @@ -1134,7 +1373,7 @@ ftrace_graph_call:
19130 .globl ftrace_stub
19131 ftrace_stub:
19132 ret
19133 -END(ftrace_caller)
19134 +ENDPROC(ftrace_caller)
19135
19136 ENTRY(ftrace_regs_caller)
19137 pushf /* push flags before compare (in cs location) */
19138 @@ -1235,7 +1474,7 @@ trace:
19139 popl %ecx
19140 popl %eax
19141 jmp ftrace_stub
19142 -END(mcount)
19143 +ENDPROC(mcount)
19144 #endif /* CONFIG_DYNAMIC_FTRACE */
19145 #endif /* CONFIG_FUNCTION_TRACER */
19146
19147 @@ -1253,7 +1492,7 @@ ENTRY(ftrace_graph_caller)
19148 popl %ecx
19149 popl %eax
19150 ret
19151 -END(ftrace_graph_caller)
19152 +ENDPROC(ftrace_graph_caller)
19153
19154 .globl return_to_handler
19155 return_to_handler:
19156 @@ -1309,15 +1548,18 @@ error_code:
19157 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
19158 REG_TO_PTGS %ecx
19159 SET_KERNEL_GS %ecx
19160 - movl $(__USER_DS), %ecx
19161 + movl $(__KERNEL_DS), %ecx
19162 movl %ecx, %ds
19163 movl %ecx, %es
19164 +
19165 + pax_enter_kernel
19166 +
19167 TRACE_IRQS_OFF
19168 movl %esp,%eax # pt_regs pointer
19169 call *%edi
19170 jmp ret_from_exception
19171 CFI_ENDPROC
19172 -END(page_fault)
19173 +ENDPROC(page_fault)
19174
19175 /*
19176 * Debug traps and NMI can happen at the one SYSENTER instruction
19177 @@ -1360,7 +1602,7 @@ debug_stack_correct:
19178 call do_debug
19179 jmp ret_from_exception
19180 CFI_ENDPROC
19181 -END(debug)
19182 +ENDPROC(debug)
19183
19184 /*
19185 * NMI is doubly nasty. It can happen _while_ we're handling
19186 @@ -1398,6 +1640,9 @@ nmi_stack_correct:
19187 xorl %edx,%edx # zero error code
19188 movl %esp,%eax # pt_regs pointer
19189 call do_nmi
19190 +
19191 + pax_exit_kernel
19192 +
19193 jmp restore_all_notrace
19194 CFI_ENDPROC
19195
19196 @@ -1434,12 +1679,15 @@ nmi_espfix_stack:
19197 FIXUP_ESPFIX_STACK # %eax == %esp
19198 xorl %edx,%edx # zero error code
19199 call do_nmi
19200 +
19201 + pax_exit_kernel
19202 +
19203 RESTORE_REGS
19204 lss 12+4(%esp), %esp # back to espfix stack
19205 CFI_ADJUST_CFA_OFFSET -24
19206 jmp irq_return
19207 CFI_ENDPROC
19208 -END(nmi)
19209 +ENDPROC(nmi)
19210
19211 ENTRY(int3)
19212 RING0_INT_FRAME
19213 @@ -1452,14 +1700,14 @@ ENTRY(int3)
19214 call do_int3
19215 jmp ret_from_exception
19216 CFI_ENDPROC
19217 -END(int3)
19218 +ENDPROC(int3)
19219
19220 ENTRY(general_protection)
19221 RING0_EC_FRAME
19222 pushl_cfi $do_general_protection
19223 jmp error_code
19224 CFI_ENDPROC
19225 -END(general_protection)
19226 +ENDPROC(general_protection)
19227
19228 #ifdef CONFIG_KVM_GUEST
19229 ENTRY(async_page_fault)
19230 @@ -1468,7 +1716,7 @@ ENTRY(async_page_fault)
19231 pushl_cfi $do_async_page_fault
19232 jmp error_code
19233 CFI_ENDPROC
19234 -END(async_page_fault)
19235 +ENDPROC(async_page_fault)
19236 #endif
19237
19238 /*
19239 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
19240 index cb3c591..bc63707 100644
19241 --- a/arch/x86/kernel/entry_64.S
19242 +++ b/arch/x86/kernel/entry_64.S
19243 @@ -59,6 +59,8 @@
19244 #include <asm/context_tracking.h>
19245 #include <asm/smap.h>
19246 #include <linux/err.h>
19247 +#include <asm/pgtable.h>
19248 +#include <asm/alternative-asm.h>
19249
19250 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
19251 #include <linux/elf-em.h>
19252 @@ -80,8 +82,9 @@
19253 #ifdef CONFIG_DYNAMIC_FTRACE
19254
19255 ENTRY(function_hook)
19256 + pax_force_retaddr
19257 retq
19258 -END(function_hook)
19259 +ENDPROC(function_hook)
19260
19261 /* skip is set if stack has been adjusted */
19262 .macro ftrace_caller_setup skip=0
19263 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
19264 #endif
19265
19266 GLOBAL(ftrace_stub)
19267 + pax_force_retaddr
19268 retq
19269 -END(ftrace_caller)
19270 +ENDPROC(ftrace_caller)
19271
19272 ENTRY(ftrace_regs_caller)
19273 /* Save the current flags before compare (in SS location)*/
19274 @@ -191,7 +195,7 @@ ftrace_restore_flags:
19275 popfq
19276 jmp ftrace_stub
19277
19278 -END(ftrace_regs_caller)
19279 +ENDPROC(ftrace_regs_caller)
19280
19281
19282 #else /* ! CONFIG_DYNAMIC_FTRACE */
19283 @@ -212,6 +216,7 @@ ENTRY(function_hook)
19284 #endif
19285
19286 GLOBAL(ftrace_stub)
19287 + pax_force_retaddr
19288 retq
19289
19290 trace:
19291 @@ -225,12 +230,13 @@ trace:
19292 #endif
19293 subq $MCOUNT_INSN_SIZE, %rdi
19294
19295 + pax_force_fptr ftrace_trace_function
19296 call *ftrace_trace_function
19297
19298 MCOUNT_RESTORE_FRAME
19299
19300 jmp ftrace_stub
19301 -END(function_hook)
19302 +ENDPROC(function_hook)
19303 #endif /* CONFIG_DYNAMIC_FTRACE */
19304 #endif /* CONFIG_FUNCTION_TRACER */
19305
19306 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
19307
19308 MCOUNT_RESTORE_FRAME
19309
19310 + pax_force_retaddr
19311 retq
19312 -END(ftrace_graph_caller)
19313 +ENDPROC(ftrace_graph_caller)
19314
19315 GLOBAL(return_to_handler)
19316 subq $24, %rsp
19317 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
19318 movq 8(%rsp), %rdx
19319 movq (%rsp), %rax
19320 addq $24, %rsp
19321 + pax_force_fptr %rdi
19322 jmp *%rdi
19323 +ENDPROC(return_to_handler)
19324 #endif
19325
19326
19327 @@ -284,6 +293,273 @@ ENTRY(native_usergs_sysret64)
19328 ENDPROC(native_usergs_sysret64)
19329 #endif /* CONFIG_PARAVIRT */
19330
19331 + .macro ljmpq sel, off
19332 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
19333 + .byte 0x48; ljmp *1234f(%rip)
19334 + .pushsection .rodata
19335 + .align 16
19336 + 1234: .quad \off; .word \sel
19337 + .popsection
19338 +#else
19339 + pushq $\sel
19340 + pushq $\off
19341 + lretq
19342 +#endif
19343 + .endm
19344 +
19345 + .macro pax_enter_kernel
19346 + pax_set_fptr_mask
19347 +#ifdef CONFIG_PAX_KERNEXEC
19348 + call pax_enter_kernel
19349 +#endif
19350 + .endm
19351 +
19352 + .macro pax_exit_kernel
19353 +#ifdef CONFIG_PAX_KERNEXEC
19354 + call pax_exit_kernel
19355 +#endif
19356 + .endm
19357 +
19358 +#ifdef CONFIG_PAX_KERNEXEC
19359 +ENTRY(pax_enter_kernel)
19360 + pushq %rdi
19361 +
19362 +#ifdef CONFIG_PARAVIRT
19363 + PV_SAVE_REGS(CLBR_RDI)
19364 +#endif
19365 +
19366 + GET_CR0_INTO_RDI
19367 + bts $16,%rdi
19368 + jnc 3f
19369 + mov %cs,%edi
19370 + cmp $__KERNEL_CS,%edi
19371 + jnz 2f
19372 +1:
19373 +
19374 +#ifdef CONFIG_PARAVIRT
19375 + PV_RESTORE_REGS(CLBR_RDI)
19376 +#endif
19377 +
19378 + popq %rdi
19379 + pax_force_retaddr
19380 + retq
19381 +
19382 +2: ljmpq __KERNEL_CS,1f
19383 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
19384 +4: SET_RDI_INTO_CR0
19385 + jmp 1b
19386 +ENDPROC(pax_enter_kernel)
19387 +
19388 +ENTRY(pax_exit_kernel)
19389 + pushq %rdi
19390 +
19391 +#ifdef CONFIG_PARAVIRT
19392 + PV_SAVE_REGS(CLBR_RDI)
19393 +#endif
19394 +
19395 + mov %cs,%rdi
19396 + cmp $__KERNEXEC_KERNEL_CS,%edi
19397 + jz 2f
19398 +1:
19399 +
19400 +#ifdef CONFIG_PARAVIRT
19401 + PV_RESTORE_REGS(CLBR_RDI);
19402 +#endif
19403 +
19404 + popq %rdi
19405 + pax_force_retaddr
19406 + retq
19407 +
19408 +2: GET_CR0_INTO_RDI
19409 + btr $16,%rdi
19410 + ljmpq __KERNEL_CS,3f
19411 +3: SET_RDI_INTO_CR0
19412 + jmp 1b
19413 +ENDPROC(pax_exit_kernel)
19414 +#endif
19415 +
19416 + .macro pax_enter_kernel_user
19417 + pax_set_fptr_mask
19418 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19419 + call pax_enter_kernel_user
19420 +#endif
19421 + .endm
19422 +
19423 + .macro pax_exit_kernel_user
19424 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19425 + call pax_exit_kernel_user
19426 +#endif
19427 +#ifdef CONFIG_PAX_RANDKSTACK
19428 + pushq %rax
19429 + call pax_randomize_kstack
19430 + popq %rax
19431 +#endif
19432 + .endm
19433 +
19434 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19435 +ENTRY(pax_enter_kernel_user)
19436 + pushq %rdi
19437 + pushq %rbx
19438 +
19439 +#ifdef CONFIG_PARAVIRT
19440 + PV_SAVE_REGS(CLBR_RDI)
19441 +#endif
19442 +
19443 + GET_CR3_INTO_RDI
19444 + mov %rdi,%rbx
19445 + add $__START_KERNEL_map,%rbx
19446 + sub phys_base(%rip),%rbx
19447 +
19448 +#ifdef CONFIG_PARAVIRT
19449 + pushq %rdi
19450 + cmpl $0, pv_info+PARAVIRT_enabled
19451 + jz 1f
19452 + i = 0
19453 + .rept USER_PGD_PTRS
19454 + mov i*8(%rbx),%rsi
19455 + mov $0,%sil
19456 + lea i*8(%rbx),%rdi
19457 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19458 + i = i + 1
19459 + .endr
19460 + jmp 2f
19461 +1:
19462 +#endif
19463 +
19464 + i = 0
19465 + .rept USER_PGD_PTRS
19466 + movb $0,i*8(%rbx)
19467 + i = i + 1
19468 + .endr
19469 +
19470 +#ifdef CONFIG_PARAVIRT
19471 +2: popq %rdi
19472 +#endif
19473 + SET_RDI_INTO_CR3
19474 +
19475 +#ifdef CONFIG_PAX_KERNEXEC
19476 + GET_CR0_INTO_RDI
19477 + bts $16,%rdi
19478 + SET_RDI_INTO_CR0
19479 +#endif
19480 +
19481 +#ifdef CONFIG_PARAVIRT
19482 + PV_RESTORE_REGS(CLBR_RDI)
19483 +#endif
19484 +
19485 + popq %rbx
19486 + popq %rdi
19487 + pax_force_retaddr
19488 + retq
19489 +ENDPROC(pax_enter_kernel_user)
19490 +
19491 +ENTRY(pax_exit_kernel_user)
19492 + push %rdi
19493 +
19494 +#ifdef CONFIG_PARAVIRT
19495 + pushq %rbx
19496 + PV_SAVE_REGS(CLBR_RDI)
19497 +#endif
19498 +
19499 +#ifdef CONFIG_PAX_KERNEXEC
19500 + GET_CR0_INTO_RDI
19501 + btr $16,%rdi
19502 + SET_RDI_INTO_CR0
19503 +#endif
19504 +
19505 + GET_CR3_INTO_RDI
19506 + add $__START_KERNEL_map,%rdi
19507 + sub phys_base(%rip),%rdi
19508 +
19509 +#ifdef CONFIG_PARAVIRT
19510 + cmpl $0, pv_info+PARAVIRT_enabled
19511 + jz 1f
19512 + mov %rdi,%rbx
19513 + i = 0
19514 + .rept USER_PGD_PTRS
19515 + mov i*8(%rbx),%rsi
19516 + mov $0x67,%sil
19517 + lea i*8(%rbx),%rdi
19518 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19519 + i = i + 1
19520 + .endr
19521 + jmp 2f
19522 +1:
19523 +#endif
19524 +
19525 + i = 0
19526 + .rept USER_PGD_PTRS
19527 + movb $0x67,i*8(%rdi)
19528 + i = i + 1
19529 + .endr
19530 +
19531 +#ifdef CONFIG_PARAVIRT
19532 +2: PV_RESTORE_REGS(CLBR_RDI)
19533 + popq %rbx
19534 +#endif
19535 +
19536 + popq %rdi
19537 + pax_force_retaddr
19538 + retq
19539 +ENDPROC(pax_exit_kernel_user)
19540 +#endif
19541 +
19542 +.macro pax_erase_kstack
19543 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19544 + call pax_erase_kstack
19545 +#endif
19546 +.endm
19547 +
19548 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19549 +ENTRY(pax_erase_kstack)
19550 + pushq %rdi
19551 + pushq %rcx
19552 + pushq %rax
19553 + pushq %r11
19554 +
19555 + GET_THREAD_INFO(%r11)
19556 + mov TI_lowest_stack(%r11), %rdi
19557 + mov $-0xBEEF, %rax
19558 + std
19559 +
19560 +1: mov %edi, %ecx
19561 + and $THREAD_SIZE_asm - 1, %ecx
19562 + shr $3, %ecx
19563 + repne scasq
19564 + jecxz 2f
19565 +
19566 + cmp $2*8, %ecx
19567 + jc 2f
19568 +
19569 + mov $2*8, %ecx
19570 + repe scasq
19571 + jecxz 2f
19572 + jne 1b
19573 +
19574 +2: cld
19575 + mov %esp, %ecx
19576 + sub %edi, %ecx
19577 +
19578 + cmp $THREAD_SIZE_asm, %rcx
19579 + jb 3f
19580 + ud2
19581 +3:
19582 +
19583 + shr $3, %ecx
19584 + rep stosq
19585 +
19586 + mov TI_task_thread_sp0(%r11), %rdi
19587 + sub $256, %rdi
19588 + mov %rdi, TI_lowest_stack(%r11)
19589 +
19590 + popq %r11
19591 + popq %rax
19592 + popq %rcx
19593 + popq %rdi
19594 + pax_force_retaddr
19595 + ret
19596 +ENDPROC(pax_erase_kstack)
19597 +#endif
19598
19599 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19600 #ifdef CONFIG_TRACE_IRQFLAGS
19601 @@ -375,8 +651,8 @@ ENDPROC(native_usergs_sysret64)
19602 .endm
19603
19604 .macro UNFAKE_STACK_FRAME
19605 - addq $8*6, %rsp
19606 - CFI_ADJUST_CFA_OFFSET -(6*8)
19607 + addq $8*6 + ARG_SKIP, %rsp
19608 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19609 .endm
19610
19611 /*
19612 @@ -463,7 +739,7 @@ ENDPROC(native_usergs_sysret64)
19613 movq %rsp, %rsi
19614
19615 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19616 - testl $3, CS-RBP(%rsi)
19617 + testb $3, CS-RBP(%rsi)
19618 je 1f
19619 SWAPGS
19620 /*
19621 @@ -498,9 +774,10 @@ ENTRY(save_rest)
19622 movq_cfi r15, R15+16
19623 movq %r11, 8(%rsp) /* return address */
19624 FIXUP_TOP_OF_STACK %r11, 16
19625 + pax_force_retaddr
19626 ret
19627 CFI_ENDPROC
19628 -END(save_rest)
19629 +ENDPROC(save_rest)
19630
19631 /* save complete stack frame */
19632 .pushsection .kprobes.text, "ax"
19633 @@ -529,9 +806,10 @@ ENTRY(save_paranoid)
19634 js 1f /* negative -> in kernel */
19635 SWAPGS
19636 xorl %ebx,%ebx
19637 -1: ret
19638 +1: pax_force_retaddr_bts
19639 + ret
19640 CFI_ENDPROC
19641 -END(save_paranoid)
19642 +ENDPROC(save_paranoid)
19643 .popsection
19644
19645 /*
19646 @@ -553,7 +831,7 @@ ENTRY(ret_from_fork)
19647
19648 RESTORE_REST
19649
19650 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19651 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19652 jz 1f
19653
19654 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19655 @@ -571,7 +849,7 @@ ENTRY(ret_from_fork)
19656 RESTORE_REST
19657 jmp int_ret_from_sys_call
19658 CFI_ENDPROC
19659 -END(ret_from_fork)
19660 +ENDPROC(ret_from_fork)
19661
19662 /*
19663 * System call entry. Up to 6 arguments in registers are supported.
19664 @@ -608,7 +886,7 @@ END(ret_from_fork)
19665 ENTRY(system_call)
19666 CFI_STARTPROC simple
19667 CFI_SIGNAL_FRAME
19668 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19669 + CFI_DEF_CFA rsp,0
19670 CFI_REGISTER rip,rcx
19671 /*CFI_REGISTER rflags,r11*/
19672 SWAPGS_UNSAFE_STACK
19673 @@ -621,16 +899,23 @@ GLOBAL(system_call_after_swapgs)
19674
19675 movq %rsp,PER_CPU_VAR(old_rsp)
19676 movq PER_CPU_VAR(kernel_stack),%rsp
19677 + SAVE_ARGS 8*6,0
19678 + pax_enter_kernel_user
19679 +
19680 +#ifdef CONFIG_PAX_RANDKSTACK
19681 + pax_erase_kstack
19682 +#endif
19683 +
19684 /*
19685 * No need to follow this irqs off/on section - it's straight
19686 * and short:
19687 */
19688 ENABLE_INTERRUPTS(CLBR_NONE)
19689 - SAVE_ARGS 8,0
19690 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19691 movq %rcx,RIP-ARGOFFSET(%rsp)
19692 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19693 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19694 + GET_THREAD_INFO(%rcx)
19695 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19696 jnz tracesys
19697 system_call_fastpath:
19698 #if __SYSCALL_MASK == ~0
19699 @@ -640,7 +925,7 @@ system_call_fastpath:
19700 cmpl $__NR_syscall_max,%eax
19701 #endif
19702 ja badsys
19703 - movq %r10,%rcx
19704 + movq R10-ARGOFFSET(%rsp),%rcx
19705 call *sys_call_table(,%rax,8) # XXX: rip relative
19706 movq %rax,RAX-ARGOFFSET(%rsp)
19707 /*
19708 @@ -654,10 +939,13 @@ sysret_check:
19709 LOCKDEP_SYS_EXIT
19710 DISABLE_INTERRUPTS(CLBR_NONE)
19711 TRACE_IRQS_OFF
19712 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19713 + GET_THREAD_INFO(%rcx)
19714 + movl TI_flags(%rcx),%edx
19715 andl %edi,%edx
19716 jnz sysret_careful
19717 CFI_REMEMBER_STATE
19718 + pax_exit_kernel_user
19719 + pax_erase_kstack
19720 /*
19721 * sysretq will re-enable interrupts:
19722 */
19723 @@ -709,14 +997,18 @@ badsys:
19724 * jump back to the normal fast path.
19725 */
19726 auditsys:
19727 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19728 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19729 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19730 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19731 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19732 movq %rax,%rsi /* 2nd arg: syscall number */
19733 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19734 call __audit_syscall_entry
19735 +
19736 + pax_erase_kstack
19737 +
19738 LOAD_ARGS 0 /* reload call-clobbered registers */
19739 + pax_set_fptr_mask
19740 jmp system_call_fastpath
19741
19742 /*
19743 @@ -737,7 +1029,7 @@ sysret_audit:
19744 /* Do syscall tracing */
19745 tracesys:
19746 #ifdef CONFIG_AUDITSYSCALL
19747 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19748 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19749 jz auditsys
19750 #endif
19751 SAVE_REST
19752 @@ -745,12 +1037,16 @@ tracesys:
19753 FIXUP_TOP_OF_STACK %rdi
19754 movq %rsp,%rdi
19755 call syscall_trace_enter
19756 +
19757 + pax_erase_kstack
19758 +
19759 /*
19760 * Reload arg registers from stack in case ptrace changed them.
19761 * We don't reload %rax because syscall_trace_enter() returned
19762 * the value it wants us to use in the table lookup.
19763 */
19764 LOAD_ARGS ARGOFFSET, 1
19765 + pax_set_fptr_mask
19766 RESTORE_REST
19767 #if __SYSCALL_MASK == ~0
19768 cmpq $__NR_syscall_max,%rax
19769 @@ -759,7 +1055,7 @@ tracesys:
19770 cmpl $__NR_syscall_max,%eax
19771 #endif
19772 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19773 - movq %r10,%rcx /* fixup for C */
19774 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19775 call *sys_call_table(,%rax,8)
19776 movq %rax,RAX-ARGOFFSET(%rsp)
19777 /* Use IRET because user could have changed frame */
19778 @@ -780,7 +1076,9 @@ GLOBAL(int_with_check)
19779 andl %edi,%edx
19780 jnz int_careful
19781 andl $~TS_COMPAT,TI_status(%rcx)
19782 - jmp retint_swapgs
19783 + pax_exit_kernel_user
19784 + pax_erase_kstack
19785 + jmp retint_swapgs_pax
19786
19787 /* Either reschedule or signal or syscall exit tracking needed. */
19788 /* First do a reschedule test. */
19789 @@ -826,7 +1124,7 @@ int_restore_rest:
19790 TRACE_IRQS_OFF
19791 jmp int_with_check
19792 CFI_ENDPROC
19793 -END(system_call)
19794 +ENDPROC(system_call)
19795
19796 /*
19797 * Certain special system calls that need to save a complete full stack frame.
19798 @@ -842,7 +1140,7 @@ ENTRY(\label)
19799 call \func
19800 jmp ptregscall_common
19801 CFI_ENDPROC
19802 -END(\label)
19803 +ENDPROC(\label)
19804 .endm
19805
19806 .macro FORK_LIKE func
19807 @@ -856,9 +1154,10 @@ ENTRY(stub_\func)
19808 DEFAULT_FRAME 0 8 /* offset 8: return address */
19809 call sys_\func
19810 RESTORE_TOP_OF_STACK %r11, 8
19811 + pax_force_retaddr
19812 ret $REST_SKIP /* pop extended registers */
19813 CFI_ENDPROC
19814 -END(stub_\func)
19815 +ENDPROC(stub_\func)
19816 .endm
19817
19818 FORK_LIKE clone
19819 @@ -875,9 +1174,10 @@ ENTRY(ptregscall_common)
19820 movq_cfi_restore R12+8, r12
19821 movq_cfi_restore RBP+8, rbp
19822 movq_cfi_restore RBX+8, rbx
19823 + pax_force_retaddr
19824 ret $REST_SKIP /* pop extended registers */
19825 CFI_ENDPROC
19826 -END(ptregscall_common)
19827 +ENDPROC(ptregscall_common)
19828
19829 ENTRY(stub_execve)
19830 CFI_STARTPROC
19831 @@ -891,7 +1191,7 @@ ENTRY(stub_execve)
19832 RESTORE_REST
19833 jmp int_ret_from_sys_call
19834 CFI_ENDPROC
19835 -END(stub_execve)
19836 +ENDPROC(stub_execve)
19837
19838 /*
19839 * sigreturn is special because it needs to restore all registers on return.
19840 @@ -909,7 +1209,7 @@ ENTRY(stub_rt_sigreturn)
19841 RESTORE_REST
19842 jmp int_ret_from_sys_call
19843 CFI_ENDPROC
19844 -END(stub_rt_sigreturn)
19845 +ENDPROC(stub_rt_sigreturn)
19846
19847 #ifdef CONFIG_X86_X32_ABI
19848 ENTRY(stub_x32_rt_sigreturn)
19849 @@ -975,7 +1275,7 @@ vector=vector+1
19850 2: jmp common_interrupt
19851 .endr
19852 CFI_ENDPROC
19853 -END(irq_entries_start)
19854 +ENDPROC(irq_entries_start)
19855
19856 .previous
19857 END(interrupt)
19858 @@ -995,6 +1295,16 @@ END(interrupt)
19859 subq $ORIG_RAX-RBP, %rsp
19860 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19861 SAVE_ARGS_IRQ
19862 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19863 + testb $3, CS(%rdi)
19864 + jnz 1f
19865 + pax_enter_kernel
19866 + jmp 2f
19867 +1: pax_enter_kernel_user
19868 +2:
19869 +#else
19870 + pax_enter_kernel
19871 +#endif
19872 call \func
19873 .endm
19874
19875 @@ -1027,7 +1337,7 @@ ret_from_intr:
19876
19877 exit_intr:
19878 GET_THREAD_INFO(%rcx)
19879 - testl $3,CS-ARGOFFSET(%rsp)
19880 + testb $3,CS-ARGOFFSET(%rsp)
19881 je retint_kernel
19882
19883 /* Interrupt came from user space */
19884 @@ -1049,12 +1359,16 @@ retint_swapgs: /* return to user-space */
19885 * The iretq could re-enable interrupts:
19886 */
19887 DISABLE_INTERRUPTS(CLBR_ANY)
19888 + pax_exit_kernel_user
19889 +retint_swapgs_pax:
19890 TRACE_IRQS_IRETQ
19891 SWAPGS
19892 jmp restore_args
19893
19894 retint_restore_args: /* return to kernel space */
19895 DISABLE_INTERRUPTS(CLBR_ANY)
19896 + pax_exit_kernel
19897 + pax_force_retaddr (RIP-ARGOFFSET)
19898 /*
19899 * The iretq could re-enable interrupts:
19900 */
19901 @@ -1137,7 +1451,7 @@ ENTRY(retint_kernel)
19902 #endif
19903
19904 CFI_ENDPROC
19905 -END(common_interrupt)
19906 +ENDPROC(common_interrupt)
19907 /*
19908 * End of kprobes section
19909 */
19910 @@ -1155,7 +1469,7 @@ ENTRY(\sym)
19911 interrupt \do_sym
19912 jmp ret_from_intr
19913 CFI_ENDPROC
19914 -END(\sym)
19915 +ENDPROC(\sym)
19916 .endm
19917
19918 #ifdef CONFIG_SMP
19919 @@ -1211,12 +1525,22 @@ ENTRY(\sym)
19920 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19921 call error_entry
19922 DEFAULT_FRAME 0
19923 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19924 + testb $3, CS(%rsp)
19925 + jnz 1f
19926 + pax_enter_kernel
19927 + jmp 2f
19928 +1: pax_enter_kernel_user
19929 +2:
19930 +#else
19931 + pax_enter_kernel
19932 +#endif
19933 movq %rsp,%rdi /* pt_regs pointer */
19934 xorl %esi,%esi /* no error code */
19935 call \do_sym
19936 jmp error_exit /* %ebx: no swapgs flag */
19937 CFI_ENDPROC
19938 -END(\sym)
19939 +ENDPROC(\sym)
19940 .endm
19941
19942 .macro paranoidzeroentry sym do_sym
19943 @@ -1229,15 +1553,25 @@ ENTRY(\sym)
19944 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19945 call save_paranoid
19946 TRACE_IRQS_OFF
19947 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19948 + testb $3, CS(%rsp)
19949 + jnz 1f
19950 + pax_enter_kernel
19951 + jmp 2f
19952 +1: pax_enter_kernel_user
19953 +2:
19954 +#else
19955 + pax_enter_kernel
19956 +#endif
19957 movq %rsp,%rdi /* pt_regs pointer */
19958 xorl %esi,%esi /* no error code */
19959 call \do_sym
19960 jmp paranoid_exit /* %ebx: no swapgs flag */
19961 CFI_ENDPROC
19962 -END(\sym)
19963 +ENDPROC(\sym)
19964 .endm
19965
19966 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
19967 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
19968 .macro paranoidzeroentry_ist sym do_sym ist
19969 ENTRY(\sym)
19970 INTR_FRAME
19971 @@ -1248,14 +1582,30 @@ ENTRY(\sym)
19972 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19973 call save_paranoid
19974 TRACE_IRQS_OFF_DEBUG
19975 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19976 + testb $3, CS(%rsp)
19977 + jnz 1f
19978 + pax_enter_kernel
19979 + jmp 2f
19980 +1: pax_enter_kernel_user
19981 +2:
19982 +#else
19983 + pax_enter_kernel
19984 +#endif
19985 movq %rsp,%rdi /* pt_regs pointer */
19986 xorl %esi,%esi /* no error code */
19987 +#ifdef CONFIG_SMP
19988 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
19989 + lea init_tss(%r12), %r12
19990 +#else
19991 + lea init_tss(%rip), %r12
19992 +#endif
19993 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19994 call \do_sym
19995 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19996 jmp paranoid_exit /* %ebx: no swapgs flag */
19997 CFI_ENDPROC
19998 -END(\sym)
19999 +ENDPROC(\sym)
20000 .endm
20001
20002 .macro errorentry sym do_sym
20003 @@ -1267,13 +1617,23 @@ ENTRY(\sym)
20004 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
20005 call error_entry
20006 DEFAULT_FRAME 0
20007 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20008 + testb $3, CS(%rsp)
20009 + jnz 1f
20010 + pax_enter_kernel
20011 + jmp 2f
20012 +1: pax_enter_kernel_user
20013 +2:
20014 +#else
20015 + pax_enter_kernel
20016 +#endif
20017 movq %rsp,%rdi /* pt_regs pointer */
20018 movq ORIG_RAX(%rsp),%rsi /* get error code */
20019 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
20020 call \do_sym
20021 jmp error_exit /* %ebx: no swapgs flag */
20022 CFI_ENDPROC
20023 -END(\sym)
20024 +ENDPROC(\sym)
20025 .endm
20026
20027 /* error code is on the stack already */
20028 @@ -1287,13 +1647,23 @@ ENTRY(\sym)
20029 call save_paranoid
20030 DEFAULT_FRAME 0
20031 TRACE_IRQS_OFF
20032 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20033 + testb $3, CS(%rsp)
20034 + jnz 1f
20035 + pax_enter_kernel
20036 + jmp 2f
20037 +1: pax_enter_kernel_user
20038 +2:
20039 +#else
20040 + pax_enter_kernel
20041 +#endif
20042 movq %rsp,%rdi /* pt_regs pointer */
20043 movq ORIG_RAX(%rsp),%rsi /* get error code */
20044 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
20045 call \do_sym
20046 jmp paranoid_exit /* %ebx: no swapgs flag */
20047 CFI_ENDPROC
20048 -END(\sym)
20049 +ENDPROC(\sym)
20050 .endm
20051
20052 zeroentry divide_error do_divide_error
20053 @@ -1323,9 +1693,10 @@ gs_change:
20054 2: mfence /* workaround */
20055 SWAPGS
20056 popfq_cfi
20057 + pax_force_retaddr
20058 ret
20059 CFI_ENDPROC
20060 -END(native_load_gs_index)
20061 +ENDPROC(native_load_gs_index)
20062
20063 _ASM_EXTABLE(gs_change,bad_gs)
20064 .section .fixup,"ax"
20065 @@ -1353,9 +1724,10 @@ ENTRY(call_softirq)
20066 CFI_DEF_CFA_REGISTER rsp
20067 CFI_ADJUST_CFA_OFFSET -8
20068 decl PER_CPU_VAR(irq_count)
20069 + pax_force_retaddr
20070 ret
20071 CFI_ENDPROC
20072 -END(call_softirq)
20073 +ENDPROC(call_softirq)
20074
20075 #ifdef CONFIG_XEN
20076 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
20077 @@ -1393,7 +1765,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
20078 decl PER_CPU_VAR(irq_count)
20079 jmp error_exit
20080 CFI_ENDPROC
20081 -END(xen_do_hypervisor_callback)
20082 +ENDPROC(xen_do_hypervisor_callback)
20083
20084 /*
20085 * Hypervisor uses this for application faults while it executes.
20086 @@ -1452,7 +1824,7 @@ ENTRY(xen_failsafe_callback)
20087 SAVE_ALL
20088 jmp error_exit
20089 CFI_ENDPROC
20090 -END(xen_failsafe_callback)
20091 +ENDPROC(xen_failsafe_callback)
20092
20093 apicinterrupt XEN_HVM_EVTCHN_CALLBACK \
20094 xen_hvm_callback_vector xen_evtchn_do_upcall
20095 @@ -1501,16 +1873,31 @@ ENTRY(paranoid_exit)
20096 TRACE_IRQS_OFF_DEBUG
20097 testl %ebx,%ebx /* swapgs needed? */
20098 jnz paranoid_restore
20099 - testl $3,CS(%rsp)
20100 + testb $3,CS(%rsp)
20101 jnz paranoid_userspace
20102 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20103 + pax_exit_kernel
20104 + TRACE_IRQS_IRETQ 0
20105 + SWAPGS_UNSAFE_STACK
20106 + RESTORE_ALL 8
20107 + pax_force_retaddr_bts
20108 + jmp irq_return
20109 +#endif
20110 paranoid_swapgs:
20111 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20112 + pax_exit_kernel_user
20113 +#else
20114 + pax_exit_kernel
20115 +#endif
20116 TRACE_IRQS_IRETQ 0
20117 SWAPGS_UNSAFE_STACK
20118 RESTORE_ALL 8
20119 jmp irq_return
20120 paranoid_restore:
20121 + pax_exit_kernel
20122 TRACE_IRQS_IRETQ_DEBUG 0
20123 RESTORE_ALL 8
20124 + pax_force_retaddr_bts
20125 jmp irq_return
20126 paranoid_userspace:
20127 GET_THREAD_INFO(%rcx)
20128 @@ -1539,7 +1926,7 @@ paranoid_schedule:
20129 TRACE_IRQS_OFF
20130 jmp paranoid_userspace
20131 CFI_ENDPROC
20132 -END(paranoid_exit)
20133 +ENDPROC(paranoid_exit)
20134
20135 /*
20136 * Exception entry point. This expects an error code/orig_rax on the stack.
20137 @@ -1566,12 +1953,13 @@ ENTRY(error_entry)
20138 movq_cfi r14, R14+8
20139 movq_cfi r15, R15+8
20140 xorl %ebx,%ebx
20141 - testl $3,CS+8(%rsp)
20142 + testb $3,CS+8(%rsp)
20143 je error_kernelspace
20144 error_swapgs:
20145 SWAPGS
20146 error_sti:
20147 TRACE_IRQS_OFF
20148 + pax_force_retaddr_bts
20149 ret
20150
20151 /*
20152 @@ -1598,7 +1986,7 @@ bstep_iret:
20153 movq %rcx,RIP+8(%rsp)
20154 jmp error_swapgs
20155 CFI_ENDPROC
20156 -END(error_entry)
20157 +ENDPROC(error_entry)
20158
20159
20160 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
20161 @@ -1618,7 +2006,7 @@ ENTRY(error_exit)
20162 jnz retint_careful
20163 jmp retint_swapgs
20164 CFI_ENDPROC
20165 -END(error_exit)
20166 +ENDPROC(error_exit)
20167
20168 /*
20169 * Test if a given stack is an NMI stack or not.
20170 @@ -1676,9 +2064,11 @@ ENTRY(nmi)
20171 * If %cs was not the kernel segment, then the NMI triggered in user
20172 * space, which means it is definitely not nested.
20173 */
20174 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
20175 + je 1f
20176 cmpl $__KERNEL_CS, 16(%rsp)
20177 jne first_nmi
20178 -
20179 +1:
20180 /*
20181 * Check the special variable on the stack to see if NMIs are
20182 * executing.
20183 @@ -1847,6 +2237,17 @@ end_repeat_nmi:
20184 */
20185 movq %cr2, %r12
20186
20187 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20188 + testb $3, CS(%rsp)
20189 + jnz 1f
20190 + pax_enter_kernel
20191 + jmp 2f
20192 +1: pax_enter_kernel_user
20193 +2:
20194 +#else
20195 + pax_enter_kernel
20196 +#endif
20197 +
20198 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
20199 movq %rsp,%rdi
20200 movq $-1,%rsi
20201 @@ -1862,23 +2263,34 @@ end_repeat_nmi:
20202 testl %ebx,%ebx /* swapgs needed? */
20203 jnz nmi_restore
20204 nmi_swapgs:
20205 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20206 + pax_exit_kernel_user
20207 +#else
20208 + pax_exit_kernel
20209 +#endif
20210 SWAPGS_UNSAFE_STACK
20211 + RESTORE_ALL 6*8
20212 + /* Clear the NMI executing stack variable */
20213 + movq $0, 5*8(%rsp)
20214 + jmp irq_return
20215 nmi_restore:
20216 + pax_exit_kernel
20217 /* Pop the extra iret frame at once */
20218 RESTORE_ALL 6*8
20219 + pax_force_retaddr_bts
20220
20221 /* Clear the NMI executing stack variable */
20222 movq $0, 5*8(%rsp)
20223 jmp irq_return
20224 CFI_ENDPROC
20225 -END(nmi)
20226 +ENDPROC(nmi)
20227
20228 ENTRY(ignore_sysret)
20229 CFI_STARTPROC
20230 mov $-ENOSYS,%eax
20231 sysret
20232 CFI_ENDPROC
20233 -END(ignore_sysret)
20234 +ENDPROC(ignore_sysret)
20235
20236 /*
20237 * End of kprobes section
20238 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
20239 index 1d41402..af9a46a 100644
20240 --- a/arch/x86/kernel/ftrace.c
20241 +++ b/arch/x86/kernel/ftrace.c
20242 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
20243 {
20244 unsigned char replaced[MCOUNT_INSN_SIZE];
20245
20246 + ip = ktla_ktva(ip);
20247 +
20248 /*
20249 * Note: Due to modules and __init, code can
20250 * disappear and change, we need to protect against faulting
20251 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20252 unsigned char old[MCOUNT_INSN_SIZE], *new;
20253 int ret;
20254
20255 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
20256 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
20257 new = ftrace_call_replace(ip, (unsigned long)func);
20258
20259 /* See comment above by declaration of modifying_ftrace_code */
20260 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20261 /* Also update the regs callback function */
20262 if (!ret) {
20263 ip = (unsigned long)(&ftrace_regs_call);
20264 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
20265 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
20266 new = ftrace_call_replace(ip, (unsigned long)func);
20267 ret = ftrace_modify_code(ip, old, new);
20268 }
20269 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
20270 * kernel identity mapping to modify code.
20271 */
20272 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
20273 - ip = (unsigned long)__va(__pa(ip));
20274 + ip = (unsigned long)__va(__pa(ktla_ktva(ip)));
20275
20276 return probe_kernel_write((void *)ip, val, size);
20277 }
20278 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
20279 unsigned char replaced[MCOUNT_INSN_SIZE];
20280 unsigned char brk = BREAKPOINT_INSTRUCTION;
20281
20282 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
20283 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
20284 return -EFAULT;
20285
20286 /* Make sure it is what we expect it to be */
20287 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
20288 return ret;
20289
20290 fail_update:
20291 - probe_kernel_write((void *)ip, &old_code[0], 1);
20292 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
20293 goto out;
20294 }
20295
20296 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
20297 {
20298 unsigned char code[MCOUNT_INSN_SIZE];
20299
20300 + ip = ktla_ktva(ip);
20301 +
20302 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
20303 return -EFAULT;
20304
20305 diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c
20306 index c18f59d..9c0c9f6 100644
20307 --- a/arch/x86/kernel/head32.c
20308 +++ b/arch/x86/kernel/head32.c
20309 @@ -18,6 +18,7 @@
20310 #include <asm/io_apic.h>
20311 #include <asm/bios_ebda.h>
20312 #include <asm/tlbflush.h>
20313 +#include <asm/boot.h>
20314
20315 static void __init i386_default_early_setup(void)
20316 {
20317 @@ -30,8 +31,7 @@ static void __init i386_default_early_setup(void)
20318
20319 void __init i386_start_kernel(void)
20320 {
20321 - memblock_reserve(__pa_symbol(&_text),
20322 - __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
20323 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(&__bss_stop) - LOAD_PHYSICAL_ADDR);
20324
20325 #ifdef CONFIG_BLK_DEV_INITRD
20326 /* Reserve INITRD */
20327 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
20328 index c8932c7..d56b622 100644
20329 --- a/arch/x86/kernel/head_32.S
20330 +++ b/arch/x86/kernel/head_32.S
20331 @@ -26,6 +26,12 @@
20332 /* Physical address */
20333 #define pa(X) ((X) - __PAGE_OFFSET)
20334
20335 +#ifdef CONFIG_PAX_KERNEXEC
20336 +#define ta(X) (X)
20337 +#else
20338 +#define ta(X) ((X) - __PAGE_OFFSET)
20339 +#endif
20340 +
20341 /*
20342 * References to members of the new_cpu_data structure.
20343 */
20344 @@ -55,11 +61,7 @@
20345 * and small than max_low_pfn, otherwise will waste some page table entries
20346 */
20347
20348 -#if PTRS_PER_PMD > 1
20349 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
20350 -#else
20351 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
20352 -#endif
20353 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
20354
20355 /* Number of possible pages in the lowmem region */
20356 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
20357 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
20358 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20359
20360 /*
20361 + * Real beginning of normal "text" segment
20362 + */
20363 +ENTRY(stext)
20364 +ENTRY(_stext)
20365 +
20366 +/*
20367 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
20368 * %esi points to the real-mode code as a 32-bit pointer.
20369 * CS and DS must be 4 GB flat segments, but we don't depend on
20370 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20371 * can.
20372 */
20373 __HEAD
20374 +
20375 +#ifdef CONFIG_PAX_KERNEXEC
20376 + jmp startup_32
20377 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
20378 +.fill PAGE_SIZE-5,1,0xcc
20379 +#endif
20380 +
20381 ENTRY(startup_32)
20382 movl pa(stack_start),%ecx
20383
20384 @@ -106,6 +121,59 @@ ENTRY(startup_32)
20385 2:
20386 leal -__PAGE_OFFSET(%ecx),%esp
20387
20388 +#ifdef CONFIG_SMP
20389 + movl $pa(cpu_gdt_table),%edi
20390 + movl $__per_cpu_load,%eax
20391 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20392 + rorl $16,%eax
20393 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20394 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20395 + movl $__per_cpu_end - 1,%eax
20396 + subl $__per_cpu_start,%eax
20397 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20398 +#endif
20399 +
20400 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20401 + movl $NR_CPUS,%ecx
20402 + movl $pa(cpu_gdt_table),%edi
20403 +1:
20404 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20405 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20406 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20407 + addl $PAGE_SIZE_asm,%edi
20408 + loop 1b
20409 +#endif
20410 +
20411 +#ifdef CONFIG_PAX_KERNEXEC
20412 + movl $pa(boot_gdt),%edi
20413 + movl $__LOAD_PHYSICAL_ADDR,%eax
20414 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20415 + rorl $16,%eax
20416 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20417 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20418 + rorl $16,%eax
20419 +
20420 + ljmp $(__BOOT_CS),$1f
20421 +1:
20422 +
20423 + movl $NR_CPUS,%ecx
20424 + movl $pa(cpu_gdt_table),%edi
20425 + addl $__PAGE_OFFSET,%eax
20426 +1:
20427 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20428 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20429 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20430 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20431 + rorl $16,%eax
20432 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20433 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20434 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20435 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20436 + rorl $16,%eax
20437 + addl $PAGE_SIZE_asm,%edi
20438 + loop 1b
20439 +#endif
20440 +
20441 /*
20442 * Clear BSS first so that there are no surprises...
20443 */
20444 @@ -196,8 +264,11 @@ ENTRY(startup_32)
20445 movl %eax, pa(max_pfn_mapped)
20446
20447 /* Do early initialization of the fixmap area */
20448 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20449 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20450 +#ifdef CONFIG_COMPAT_VDSO
20451 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20452 +#else
20453 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20454 +#endif
20455 #else /* Not PAE */
20456
20457 page_pde_offset = (__PAGE_OFFSET >> 20);
20458 @@ -227,8 +298,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20459 movl %eax, pa(max_pfn_mapped)
20460
20461 /* Do early initialization of the fixmap area */
20462 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20463 - movl %eax,pa(initial_page_table+0xffc)
20464 +#ifdef CONFIG_COMPAT_VDSO
20465 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20466 +#else
20467 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20468 +#endif
20469 #endif
20470
20471 #ifdef CONFIG_PARAVIRT
20472 @@ -242,9 +316,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20473 cmpl $num_subarch_entries, %eax
20474 jae bad_subarch
20475
20476 - movl pa(subarch_entries)(,%eax,4), %eax
20477 - subl $__PAGE_OFFSET, %eax
20478 - jmp *%eax
20479 + jmp *pa(subarch_entries)(,%eax,4)
20480
20481 bad_subarch:
20482 WEAK(lguest_entry)
20483 @@ -256,10 +328,10 @@ WEAK(xen_entry)
20484 __INITDATA
20485
20486 subarch_entries:
20487 - .long default_entry /* normal x86/PC */
20488 - .long lguest_entry /* lguest hypervisor */
20489 - .long xen_entry /* Xen hypervisor */
20490 - .long default_entry /* Moorestown MID */
20491 + .long ta(default_entry) /* normal x86/PC */
20492 + .long ta(lguest_entry) /* lguest hypervisor */
20493 + .long ta(xen_entry) /* Xen hypervisor */
20494 + .long ta(default_entry) /* Moorestown MID */
20495 num_subarch_entries = (. - subarch_entries) / 4
20496 .previous
20497 #else
20498 @@ -335,6 +407,7 @@ default_entry:
20499 movl pa(mmu_cr4_features),%eax
20500 movl %eax,%cr4
20501
20502 +#ifdef CONFIG_X86_PAE
20503 testb $X86_CR4_PAE, %al # check if PAE is enabled
20504 jz 6f
20505
20506 @@ -363,6 +436,9 @@ default_entry:
20507 /* Make changes effective */
20508 wrmsr
20509
20510 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20511 +#endif
20512 +
20513 6:
20514
20515 /*
20516 @@ -460,14 +536,20 @@ is386: movl $2,%ecx # set MP
20517 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20518 movl %eax,%ss # after changing gdt.
20519
20520 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20521 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20522 movl %eax,%ds
20523 movl %eax,%es
20524
20525 movl $(__KERNEL_PERCPU), %eax
20526 movl %eax,%fs # set this cpu's percpu
20527
20528 +#ifdef CONFIG_CC_STACKPROTECTOR
20529 movl $(__KERNEL_STACK_CANARY),%eax
20530 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20531 + movl $(__USER_DS),%eax
20532 +#else
20533 + xorl %eax,%eax
20534 +#endif
20535 movl %eax,%gs
20536
20537 xorl %eax,%eax # Clear LDT
20538 @@ -544,8 +626,11 @@ setup_once:
20539 * relocation. Manually set base address in stack canary
20540 * segment descriptor.
20541 */
20542 - movl $gdt_page,%eax
20543 + movl $cpu_gdt_table,%eax
20544 movl $stack_canary,%ecx
20545 +#ifdef CONFIG_SMP
20546 + addl $__per_cpu_load,%ecx
20547 +#endif
20548 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20549 shrl $16, %ecx
20550 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20551 @@ -576,7 +661,7 @@ ENDPROC(early_idt_handlers)
20552 /* This is global to keep gas from relaxing the jumps */
20553 ENTRY(early_idt_handler)
20554 cld
20555 - cmpl $2,%ss:early_recursion_flag
20556 + cmpl $1,%ss:early_recursion_flag
20557 je hlt_loop
20558 incl %ss:early_recursion_flag
20559
20560 @@ -614,8 +699,8 @@ ENTRY(early_idt_handler)
20561 pushl (20+6*4)(%esp) /* trapno */
20562 pushl $fault_msg
20563 call printk
20564 -#endif
20565 call dump_stack
20566 +#endif
20567 hlt_loop:
20568 hlt
20569 jmp hlt_loop
20570 @@ -634,8 +719,11 @@ ENDPROC(early_idt_handler)
20571 /* This is the default interrupt "handler" :-) */
20572 ALIGN
20573 ignore_int:
20574 - cld
20575 #ifdef CONFIG_PRINTK
20576 + cmpl $2,%ss:early_recursion_flag
20577 + je hlt_loop
20578 + incl %ss:early_recursion_flag
20579 + cld
20580 pushl %eax
20581 pushl %ecx
20582 pushl %edx
20583 @@ -644,9 +732,6 @@ ignore_int:
20584 movl $(__KERNEL_DS),%eax
20585 movl %eax,%ds
20586 movl %eax,%es
20587 - cmpl $2,early_recursion_flag
20588 - je hlt_loop
20589 - incl early_recursion_flag
20590 pushl 16(%esp)
20591 pushl 24(%esp)
20592 pushl 32(%esp)
20593 @@ -680,29 +765,43 @@ ENTRY(setup_once_ref)
20594 /*
20595 * BSS section
20596 */
20597 -__PAGE_ALIGNED_BSS
20598 - .align PAGE_SIZE
20599 #ifdef CONFIG_X86_PAE
20600 +.section .initial_pg_pmd,"a",@progbits
20601 initial_pg_pmd:
20602 .fill 1024*KPMDS,4,0
20603 #else
20604 +.section .initial_page_table,"a",@progbits
20605 ENTRY(initial_page_table)
20606 .fill 1024,4,0
20607 #endif
20608 +.section .initial_pg_fixmap,"a",@progbits
20609 initial_pg_fixmap:
20610 .fill 1024,4,0
20611 +.section .empty_zero_page,"a",@progbits
20612 ENTRY(empty_zero_page)
20613 .fill 4096,1,0
20614 +.section .swapper_pg_dir,"a",@progbits
20615 ENTRY(swapper_pg_dir)
20616 +#ifdef CONFIG_X86_PAE
20617 + .fill 4,8,0
20618 +#else
20619 .fill 1024,4,0
20620 +#endif
20621 +
20622 +/*
20623 + * The IDT has to be page-aligned to simplify the Pentium
20624 + * F0 0F bug workaround.. We have a special link segment
20625 + * for this.
20626 + */
20627 +.section .idt,"a",@progbits
20628 +ENTRY(idt_table)
20629 + .fill 256,8,0
20630
20631 /*
20632 * This starts the data section.
20633 */
20634 #ifdef CONFIG_X86_PAE
20635 -__PAGE_ALIGNED_DATA
20636 - /* Page-aligned for the benefit of paravirt? */
20637 - .align PAGE_SIZE
20638 +.section .initial_page_table,"a",@progbits
20639 ENTRY(initial_page_table)
20640 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20641 # if KPMDS == 3
20642 @@ -721,12 +820,20 @@ ENTRY(initial_page_table)
20643 # error "Kernel PMDs should be 1, 2 or 3"
20644 # endif
20645 .align PAGE_SIZE /* needs to be page-sized too */
20646 +
20647 +#ifdef CONFIG_PAX_PER_CPU_PGD
20648 +ENTRY(cpu_pgd)
20649 + .rept NR_CPUS
20650 + .fill 4,8,0
20651 + .endr
20652 +#endif
20653 +
20654 #endif
20655
20656 .data
20657 .balign 4
20658 ENTRY(stack_start)
20659 - .long init_thread_union+THREAD_SIZE
20660 + .long init_thread_union+THREAD_SIZE-8
20661
20662 __INITRODATA
20663 int_msg:
20664 @@ -754,7 +861,7 @@ fault_msg:
20665 * segment size, and 32-bit linear address value:
20666 */
20667
20668 - .data
20669 +.section .rodata,"a",@progbits
20670 .globl boot_gdt_descr
20671 .globl idt_descr
20672
20673 @@ -763,7 +870,7 @@ fault_msg:
20674 .word 0 # 32 bit align gdt_desc.address
20675 boot_gdt_descr:
20676 .word __BOOT_DS+7
20677 - .long boot_gdt - __PAGE_OFFSET
20678 + .long pa(boot_gdt)
20679
20680 .word 0 # 32-bit align idt_desc.address
20681 idt_descr:
20682 @@ -774,7 +881,7 @@ idt_descr:
20683 .word 0 # 32 bit align gdt_desc.address
20684 ENTRY(early_gdt_descr)
20685 .word GDT_ENTRIES*8-1
20686 - .long gdt_page /* Overwritten for secondary CPUs */
20687 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20688
20689 /*
20690 * The boot_gdt must mirror the equivalent in setup.S and is
20691 @@ -783,5 +890,65 @@ ENTRY(early_gdt_descr)
20692 .align L1_CACHE_BYTES
20693 ENTRY(boot_gdt)
20694 .fill GDT_ENTRY_BOOT_CS,8,0
20695 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20696 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20697 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20698 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20699 +
20700 + .align PAGE_SIZE_asm
20701 +ENTRY(cpu_gdt_table)
20702 + .rept NR_CPUS
20703 + .quad 0x0000000000000000 /* NULL descriptor */
20704 + .quad 0x0000000000000000 /* 0x0b reserved */
20705 + .quad 0x0000000000000000 /* 0x13 reserved */
20706 + .quad 0x0000000000000000 /* 0x1b reserved */
20707 +
20708 +#ifdef CONFIG_PAX_KERNEXEC
20709 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20710 +#else
20711 + .quad 0x0000000000000000 /* 0x20 unused */
20712 +#endif
20713 +
20714 + .quad 0x0000000000000000 /* 0x28 unused */
20715 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20716 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20717 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20718 + .quad 0x0000000000000000 /* 0x4b reserved */
20719 + .quad 0x0000000000000000 /* 0x53 reserved */
20720 + .quad 0x0000000000000000 /* 0x5b reserved */
20721 +
20722 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20723 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20724 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20725 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20726 +
20727 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20728 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20729 +
20730 + /*
20731 + * Segments used for calling PnP BIOS have byte granularity.
20732 + * The code segments and data segments have fixed 64k limits,
20733 + * the transfer segment sizes are set at run time.
20734 + */
20735 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20736 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20737 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20738 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20739 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20740 +
20741 + /*
20742 + * The APM segments have byte granularity and their bases
20743 + * are set at run time. All have 64k limits.
20744 + */
20745 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20746 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20747 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20748 +
20749 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20750 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20751 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20752 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20753 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20754 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20755 +
20756 + /* Be sure this is zeroed to avoid false validations in Xen */
20757 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20758 + .endr
20759 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20760 index 980053c..74d3b44 100644
20761 --- a/arch/x86/kernel/head_64.S
20762 +++ b/arch/x86/kernel/head_64.S
20763 @@ -20,6 +20,8 @@
20764 #include <asm/processor-flags.h>
20765 #include <asm/percpu.h>
20766 #include <asm/nops.h>
20767 +#include <asm/cpufeature.h>
20768 +#include <asm/alternative-asm.h>
20769
20770 #ifdef CONFIG_PARAVIRT
20771 #include <asm/asm-offsets.h>
20772 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20773 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20774 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20775 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20776 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20777 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20778 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20779 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20780 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20781 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20782
20783 .text
20784 __HEAD
20785 @@ -88,35 +96,23 @@ startup_64:
20786 */
20787 addq %rbp, init_level4_pgt + 0(%rip)
20788 addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
20789 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20790 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20791 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20792 addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
20793
20794 addq %rbp, level3_ident_pgt + 0(%rip)
20795 +#ifndef CONFIG_XEN
20796 + addq %rbp, level3_ident_pgt + 8(%rip)
20797 +#endif
20798
20799 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20800 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20801 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
20802 +
20803 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
20804 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8+8)(%rip)
20805
20806 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20807 -
20808 - /* Add an Identity mapping if I am above 1G */
20809 - leaq _text(%rip), %rdi
20810 - andq $PMD_PAGE_MASK, %rdi
20811 -
20812 - movq %rdi, %rax
20813 - shrq $PUD_SHIFT, %rax
20814 - andq $(PTRS_PER_PUD - 1), %rax
20815 - jz ident_complete
20816 -
20817 - leaq (level2_spare_pgt - __START_KERNEL_map + _KERNPG_TABLE)(%rbp), %rdx
20818 - leaq level3_ident_pgt(%rip), %rbx
20819 - movq %rdx, 0(%rbx, %rax, 8)
20820 -
20821 - movq %rdi, %rax
20822 - shrq $PMD_SHIFT, %rax
20823 - andq $(PTRS_PER_PMD - 1), %rax
20824 - leaq __PAGE_KERNEL_IDENT_LARGE_EXEC(%rdi), %rdx
20825 - leaq level2_spare_pgt(%rip), %rbx
20826 - movq %rdx, 0(%rbx, %rax, 8)
20827 -ident_complete:
20828 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20829
20830 /*
20831 * Fixup the kernel text+data virtual addresses. Note that
20832 @@ -159,8 +155,8 @@ ENTRY(secondary_startup_64)
20833 * after the boot processor executes this code.
20834 */
20835
20836 - /* Enable PAE mode and PGE */
20837 - movl $(X86_CR4_PAE | X86_CR4_PGE), %eax
20838 + /* Enable PAE mode and PSE/PGE */
20839 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %eax
20840 movq %rax, %cr4
20841
20842 /* Setup early boot stage 4 level pagetables. */
20843 @@ -182,9 +178,17 @@ ENTRY(secondary_startup_64)
20844 movl $MSR_EFER, %ecx
20845 rdmsr
20846 btsl $_EFER_SCE, %eax /* Enable System Call */
20847 - btl $20,%edi /* No Execute supported? */
20848 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20849 jnc 1f
20850 btsl $_EFER_NX, %eax
20851 + leaq init_level4_pgt(%rip), %rdi
20852 +#ifndef CONFIG_EFI
20853 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20854 +#endif
20855 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20856 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20857 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20858 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20859 1: wrmsr /* Make changes effective */
20860
20861 /* Setup cr0 */
20862 @@ -246,6 +250,7 @@ ENTRY(secondary_startup_64)
20863 * jump. In addition we need to ensure %cs is set so we make this
20864 * a far return.
20865 */
20866 + pax_set_fptr_mask
20867 movq initial_code(%rip),%rax
20868 pushq $0 # fake return address to stop unwinder
20869 pushq $__KERNEL_CS # set correct cs
20870 @@ -284,7 +289,7 @@ ENDPROC(start_cpu0)
20871 bad_address:
20872 jmp bad_address
20873
20874 - .section ".init.text","ax"
20875 + __INIT
20876 .globl early_idt_handlers
20877 early_idt_handlers:
20878 # 104(%rsp) %rflags
20879 @@ -343,7 +348,7 @@ ENTRY(early_idt_handler)
20880 call dump_stack
20881 #ifdef CONFIG_KALLSYMS
20882 leaq early_idt_ripmsg(%rip),%rdi
20883 - movq 40(%rsp),%rsi # %rip again
20884 + movq 88(%rsp),%rsi # %rip again
20885 call __print_symbol
20886 #endif
20887 #endif /* EARLY_PRINTK */
20888 @@ -363,11 +368,15 @@ ENTRY(early_idt_handler)
20889 addq $16,%rsp # drop vector number and error code
20890 decl early_recursion_flag(%rip)
20891 INTERRUPT_RETURN
20892 + .previous
20893
20894 + __INITDATA
20895 .balign 4
20896 early_recursion_flag:
20897 .long 0
20898 + .previous
20899
20900 + .section .rodata,"a",@progbits
20901 #ifdef CONFIG_EARLY_PRINTK
20902 early_idt_msg:
20903 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
20904 @@ -376,6 +385,7 @@ early_idt_ripmsg:
20905 #endif /* CONFIG_EARLY_PRINTK */
20906 .previous
20907
20908 + .section .rodata,"a",@progbits
20909 #define NEXT_PAGE(name) \
20910 .balign PAGE_SIZE; \
20911 ENTRY(name)
20912 @@ -388,7 +398,6 @@ ENTRY(name)
20913 i = i + 1 ; \
20914 .endr
20915
20916 - .data
20917 /*
20918 * This default setting generates an ident mapping at address 0x100000
20919 * and a mapping for the kernel that precisely maps virtual address
20920 @@ -399,13 +408,41 @@ NEXT_PAGE(init_level4_pgt)
20921 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20922 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
20923 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20924 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
20925 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
20926 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
20927 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
20928 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
20929 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20930 .org init_level4_pgt + L4_START_KERNEL*8, 0
20931 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
20932 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
20933
20934 +#ifdef CONFIG_PAX_PER_CPU_PGD
20935 +NEXT_PAGE(cpu_pgd)
20936 + .rept NR_CPUS
20937 + .fill 512,8,0
20938 + .endr
20939 +#endif
20940 +
20941 NEXT_PAGE(level3_ident_pgt)
20942 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20943 +#ifdef CONFIG_XEN
20944 .fill 511,8,0
20945 +#else
20946 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
20947 + .fill 510,8,0
20948 +#endif
20949 +
20950 +NEXT_PAGE(level3_vmalloc_start_pgt)
20951 + .fill 512,8,0
20952 +
20953 +NEXT_PAGE(level3_vmalloc_end_pgt)
20954 + .fill 512,8,0
20955 +
20956 +NEXT_PAGE(level3_vmemmap_pgt)
20957 + .fill L3_VMEMMAP_START,8,0
20958 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20959
20960 NEXT_PAGE(level3_kernel_pgt)
20961 .fill L3_START_KERNEL,8,0
20962 @@ -413,20 +450,23 @@ NEXT_PAGE(level3_kernel_pgt)
20963 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
20964 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20965
20966 +NEXT_PAGE(level2_vmemmap_pgt)
20967 + .fill 512,8,0
20968 +
20969 NEXT_PAGE(level2_fixmap_pgt)
20970 - .fill 506,8,0
20971 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20972 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
20973 - .fill 5,8,0
20974 + .fill 507,8,0
20975 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
20976 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
20977 + .fill 4,8,0
20978
20979 -NEXT_PAGE(level1_fixmap_pgt)
20980 +NEXT_PAGE(level1_vsyscall_pgt)
20981 .fill 512,8,0
20982
20983 -NEXT_PAGE(level2_ident_pgt)
20984 - /* Since I easily can, map the first 1G.
20985 + /* Since I easily can, map the first 2G.
20986 * Don't set NX because code runs from these pages.
20987 */
20988 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
20989 +NEXT_PAGE(level2_ident_pgt)
20990 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
20991
20992 NEXT_PAGE(level2_kernel_pgt)
20993 /*
20994 @@ -439,37 +479,59 @@ NEXT_PAGE(level2_kernel_pgt)
20995 * If you want to increase this then increase MODULES_VADDR
20996 * too.)
20997 */
20998 - PMDS(0, __PAGE_KERNEL_LARGE_EXEC,
20999 - KERNEL_IMAGE_SIZE/PMD_SIZE)
21000 -
21001 -NEXT_PAGE(level2_spare_pgt)
21002 - .fill 512, 8, 0
21003 + PMDS(0, __PAGE_KERNEL_LARGE_EXEC, KERNEL_IMAGE_SIZE/PMD_SIZE)
21004
21005 #undef PMDS
21006 #undef NEXT_PAGE
21007
21008 - .data
21009 + .align PAGE_SIZE
21010 +ENTRY(cpu_gdt_table)
21011 + .rept NR_CPUS
21012 + .quad 0x0000000000000000 /* NULL descriptor */
21013 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
21014 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
21015 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
21016 + .quad 0x00cffb000000ffff /* __USER32_CS */
21017 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
21018 + .quad 0x00affb000000ffff /* __USER_CS */
21019 +
21020 +#ifdef CONFIG_PAX_KERNEXEC
21021 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
21022 +#else
21023 + .quad 0x0 /* unused */
21024 +#endif
21025 +
21026 + .quad 0,0 /* TSS */
21027 + .quad 0,0 /* LDT */
21028 + .quad 0,0,0 /* three TLS descriptors */
21029 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
21030 + /* asm/segment.h:GDT_ENTRIES must match this */
21031 +
21032 + /* zero the remaining page */
21033 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
21034 + .endr
21035 +
21036 .align 16
21037 .globl early_gdt_descr
21038 early_gdt_descr:
21039 .word GDT_ENTRIES*8-1
21040 early_gdt_descr_base:
21041 - .quad INIT_PER_CPU_VAR(gdt_page)
21042 + .quad cpu_gdt_table
21043
21044 ENTRY(phys_base)
21045 /* This must match the first entry in level2_kernel_pgt */
21046 .quad 0x0000000000000000
21047
21048 #include "../../x86/xen/xen-head.S"
21049 -
21050 - .section .bss, "aw", @nobits
21051 +
21052 + .section .rodata,"a",@progbits
21053 .align L1_CACHE_BYTES
21054 ENTRY(idt_table)
21055 - .skip IDT_ENTRIES * 16
21056 + .fill 512,8,0
21057
21058 .align L1_CACHE_BYTES
21059 ENTRY(nmi_idt_table)
21060 - .skip IDT_ENTRIES * 16
21061 + .fill 512,8,0
21062
21063 __PAGE_ALIGNED_BSS
21064 .align PAGE_SIZE
21065 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
21066 index 9c3bd4a..e1d9b35 100644
21067 --- a/arch/x86/kernel/i386_ksyms_32.c
21068 +++ b/arch/x86/kernel/i386_ksyms_32.c
21069 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
21070 EXPORT_SYMBOL(cmpxchg8b_emu);
21071 #endif
21072
21073 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
21074 +
21075 /* Networking helper routines. */
21076 EXPORT_SYMBOL(csum_partial_copy_generic);
21077 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
21078 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
21079
21080 EXPORT_SYMBOL(__get_user_1);
21081 EXPORT_SYMBOL(__get_user_2);
21082 @@ -36,3 +40,7 @@ EXPORT_SYMBOL(strstr);
21083
21084 EXPORT_SYMBOL(csum_partial);
21085 EXPORT_SYMBOL(empty_zero_page);
21086 +
21087 +#ifdef CONFIG_PAX_KERNEXEC
21088 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
21089 +#endif
21090 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
21091 index 245a71d..89d9ce4 100644
21092 --- a/arch/x86/kernel/i387.c
21093 +++ b/arch/x86/kernel/i387.c
21094 @@ -55,7 +55,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
21095 static inline bool interrupted_user_mode(void)
21096 {
21097 struct pt_regs *regs = get_irq_regs();
21098 - return regs && user_mode_vm(regs);
21099 + return regs && user_mode(regs);
21100 }
21101
21102 /*
21103 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
21104 index 9a5c460..b332a4b 100644
21105 --- a/arch/x86/kernel/i8259.c
21106 +++ b/arch/x86/kernel/i8259.c
21107 @@ -209,7 +209,7 @@ spurious_8259A_irq:
21108 "spurious 8259A interrupt: IRQ%d.\n", irq);
21109 spurious_irq_mask |= irqmask;
21110 }
21111 - atomic_inc(&irq_err_count);
21112 + atomic_inc_unchecked(&irq_err_count);
21113 /*
21114 * Theoretically we do not have to handle this IRQ,
21115 * but in Linux this does not cause problems and is
21116 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
21117 /* (slave's support for AEOI in flat mode is to be investigated) */
21118 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
21119
21120 + pax_open_kernel();
21121 if (auto_eoi)
21122 /*
21123 * In AEOI mode we just have to mask the interrupt
21124 * when acking.
21125 */
21126 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
21127 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
21128 else
21129 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
21130 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
21131 + pax_close_kernel();
21132
21133 udelay(100); /* wait for 8259A to initialize */
21134
21135 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
21136 index a979b5b..1d6db75 100644
21137 --- a/arch/x86/kernel/io_delay.c
21138 +++ b/arch/x86/kernel/io_delay.c
21139 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
21140 * Quirk table for systems that misbehave (lock up, etc.) if port
21141 * 0x80 is used:
21142 */
21143 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
21144 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
21145 {
21146 .callback = dmi_io_delay_0xed_port,
21147 .ident = "Compaq Presario V6000",
21148 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
21149 index 8c96897..be66bfa 100644
21150 --- a/arch/x86/kernel/ioport.c
21151 +++ b/arch/x86/kernel/ioport.c
21152 @@ -6,6 +6,7 @@
21153 #include <linux/sched.h>
21154 #include <linux/kernel.h>
21155 #include <linux/capability.h>
21156 +#include <linux/security.h>
21157 #include <linux/errno.h>
21158 #include <linux/types.h>
21159 #include <linux/ioport.h>
21160 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
21161
21162 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
21163 return -EINVAL;
21164 +#ifdef CONFIG_GRKERNSEC_IO
21165 + if (turn_on && grsec_disable_privio) {
21166 + gr_handle_ioperm();
21167 + return -EPERM;
21168 + }
21169 +#endif
21170 if (turn_on && !capable(CAP_SYS_RAWIO))
21171 return -EPERM;
21172
21173 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
21174 * because the ->io_bitmap_max value must match the bitmap
21175 * contents:
21176 */
21177 - tss = &per_cpu(init_tss, get_cpu());
21178 + tss = init_tss + get_cpu();
21179
21180 if (turn_on)
21181 bitmap_clear(t->io_bitmap_ptr, from, num);
21182 @@ -102,6 +109,12 @@ long sys_iopl(unsigned int level, struct pt_regs *regs)
21183 return -EINVAL;
21184 /* Trying to gain more privileges? */
21185 if (level > old) {
21186 +#ifdef CONFIG_GRKERNSEC_IO
21187 + if (grsec_disable_privio) {
21188 + gr_handle_iopl();
21189 + return -EPERM;
21190 + }
21191 +#endif
21192 if (!capable(CAP_SYS_RAWIO))
21193 return -EPERM;
21194 }
21195 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
21196 index e4595f1..ee3bfb8 100644
21197 --- a/arch/x86/kernel/irq.c
21198 +++ b/arch/x86/kernel/irq.c
21199 @@ -18,7 +18,7 @@
21200 #include <asm/mce.h>
21201 #include <asm/hw_irq.h>
21202
21203 -atomic_t irq_err_count;
21204 +atomic_unchecked_t irq_err_count;
21205
21206 /* Function pointer for generic interrupt vector handling */
21207 void (*x86_platform_ipi_callback)(void) = NULL;
21208 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
21209 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
21210 seq_printf(p, " Machine check polls\n");
21211 #endif
21212 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
21213 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
21214 #if defined(CONFIG_X86_IO_APIC)
21215 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
21216 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
21217 #endif
21218 return 0;
21219 }
21220 @@ -164,10 +164,10 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
21221
21222 u64 arch_irq_stat(void)
21223 {
21224 - u64 sum = atomic_read(&irq_err_count);
21225 + u64 sum = atomic_read_unchecked(&irq_err_count);
21226
21227 #ifdef CONFIG_X86_IO_APIC
21228 - sum += atomic_read(&irq_mis_count);
21229 + sum += atomic_read_unchecked(&irq_mis_count);
21230 #endif
21231 return sum;
21232 }
21233 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
21234 index 344faf8..355f60d 100644
21235 --- a/arch/x86/kernel/irq_32.c
21236 +++ b/arch/x86/kernel/irq_32.c
21237 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
21238 __asm__ __volatile__("andl %%esp,%0" :
21239 "=r" (sp) : "0" (THREAD_SIZE - 1));
21240
21241 - return sp < (sizeof(struct thread_info) + STACK_WARN);
21242 + return sp < STACK_WARN;
21243 }
21244
21245 static void print_stack_overflow(void)
21246 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
21247 * per-CPU IRQ handling contexts (thread information and stack)
21248 */
21249 union irq_ctx {
21250 - struct thread_info tinfo;
21251 - u32 stack[THREAD_SIZE/sizeof(u32)];
21252 + unsigned long previous_esp;
21253 + u32 stack[THREAD_SIZE/sizeof(u32)];
21254 } __attribute__((aligned(THREAD_SIZE)));
21255
21256 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
21257 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
21258 static inline int
21259 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21260 {
21261 - union irq_ctx *curctx, *irqctx;
21262 + union irq_ctx *irqctx;
21263 u32 *isp, arg1, arg2;
21264
21265 - curctx = (union irq_ctx *) current_thread_info();
21266 irqctx = __this_cpu_read(hardirq_ctx);
21267
21268 /*
21269 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21270 * handler) we can't do that and just have to keep using the
21271 * current stack (which is the irq stack already after all)
21272 */
21273 - if (unlikely(curctx == irqctx))
21274 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
21275 return 0;
21276
21277 /* build the stack frame on the IRQ stack */
21278 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21279 - irqctx->tinfo.task = curctx->tinfo.task;
21280 - irqctx->tinfo.previous_esp = current_stack_pointer;
21281 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21282 + irqctx->previous_esp = current_stack_pointer;
21283
21284 - /* Copy the preempt_count so that the [soft]irq checks work. */
21285 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
21286 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21287 + __set_fs(MAKE_MM_SEG(0));
21288 +#endif
21289
21290 if (unlikely(overflow))
21291 call_on_stack(print_stack_overflow, isp);
21292 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21293 : "0" (irq), "1" (desc), "2" (isp),
21294 "D" (desc->handle_irq)
21295 : "memory", "cc", "ecx");
21296 +
21297 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21298 + __set_fs(current_thread_info()->addr_limit);
21299 +#endif
21300 +
21301 return 1;
21302 }
21303
21304 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21305 */
21306 void __cpuinit irq_ctx_init(int cpu)
21307 {
21308 - union irq_ctx *irqctx;
21309 -
21310 if (per_cpu(hardirq_ctx, cpu))
21311 return;
21312
21313 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21314 - THREADINFO_GFP,
21315 - THREAD_SIZE_ORDER));
21316 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21317 - irqctx->tinfo.cpu = cpu;
21318 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
21319 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21320 -
21321 - per_cpu(hardirq_ctx, cpu) = irqctx;
21322 -
21323 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21324 - THREADINFO_GFP,
21325 - THREAD_SIZE_ORDER));
21326 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21327 - irqctx->tinfo.cpu = cpu;
21328 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21329 -
21330 - per_cpu(softirq_ctx, cpu) = irqctx;
21331 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21332 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21333 +
21334 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21335 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21336
21337 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21338 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21339 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
21340 asmlinkage void do_softirq(void)
21341 {
21342 unsigned long flags;
21343 - struct thread_info *curctx;
21344 union irq_ctx *irqctx;
21345 u32 *isp;
21346
21347 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
21348 local_irq_save(flags);
21349
21350 if (local_softirq_pending()) {
21351 - curctx = current_thread_info();
21352 irqctx = __this_cpu_read(softirq_ctx);
21353 - irqctx->tinfo.task = curctx->task;
21354 - irqctx->tinfo.previous_esp = current_stack_pointer;
21355 + irqctx->previous_esp = current_stack_pointer;
21356
21357 /* build the stack frame on the softirq stack */
21358 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21359 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21360 +
21361 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21362 + __set_fs(MAKE_MM_SEG(0));
21363 +#endif
21364
21365 call_on_stack(__do_softirq, isp);
21366 +
21367 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21368 + __set_fs(current_thread_info()->addr_limit);
21369 +#endif
21370 +
21371 /*
21372 * Shouldn't happen, we returned above if in_interrupt():
21373 */
21374 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
21375 if (unlikely(!desc))
21376 return false;
21377
21378 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21379 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21380 if (unlikely(overflow))
21381 print_stack_overflow();
21382 desc->handle_irq(irq, desc);
21383 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
21384 index d04d3ec..ea4b374 100644
21385 --- a/arch/x86/kernel/irq_64.c
21386 +++ b/arch/x86/kernel/irq_64.c
21387 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
21388 u64 estack_top, estack_bottom;
21389 u64 curbase = (u64)task_stack_page(current);
21390
21391 - if (user_mode_vm(regs))
21392 + if (user_mode(regs))
21393 return;
21394
21395 if (regs->sp >= curbase + sizeof(struct thread_info) +
21396 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
21397 index dc1404b..bbc43e7 100644
21398 --- a/arch/x86/kernel/kdebugfs.c
21399 +++ b/arch/x86/kernel/kdebugfs.c
21400 @@ -27,7 +27,7 @@ struct setup_data_node {
21401 u32 len;
21402 };
21403
21404 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
21405 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
21406 size_t count, loff_t *ppos)
21407 {
21408 struct setup_data_node *node = file->private_data;
21409 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
21410 index 836f832..a8bda67 100644
21411 --- a/arch/x86/kernel/kgdb.c
21412 +++ b/arch/x86/kernel/kgdb.c
21413 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21414 #ifdef CONFIG_X86_32
21415 switch (regno) {
21416 case GDB_SS:
21417 - if (!user_mode_vm(regs))
21418 + if (!user_mode(regs))
21419 *(unsigned long *)mem = __KERNEL_DS;
21420 break;
21421 case GDB_SP:
21422 - if (!user_mode_vm(regs))
21423 + if (!user_mode(regs))
21424 *(unsigned long *)mem = kernel_stack_pointer(regs);
21425 break;
21426 case GDB_GS:
21427 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21428 bp->attr.bp_addr = breakinfo[breakno].addr;
21429 bp->attr.bp_len = breakinfo[breakno].len;
21430 bp->attr.bp_type = breakinfo[breakno].type;
21431 - info->address = breakinfo[breakno].addr;
21432 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21433 + info->address = ktla_ktva(breakinfo[breakno].addr);
21434 + else
21435 + info->address = breakinfo[breakno].addr;
21436 info->len = breakinfo[breakno].len;
21437 info->type = breakinfo[breakno].type;
21438 val = arch_install_hw_breakpoint(bp);
21439 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21440 case 'k':
21441 /* clear the trace bit */
21442 linux_regs->flags &= ~X86_EFLAGS_TF;
21443 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21444 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21445
21446 /* set the trace bit if we're stepping */
21447 if (remcomInBuffer[0] == 's') {
21448 linux_regs->flags |= X86_EFLAGS_TF;
21449 - atomic_set(&kgdb_cpu_doing_single_step,
21450 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21451 raw_smp_processor_id());
21452 }
21453
21454 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21455
21456 switch (cmd) {
21457 case DIE_DEBUG:
21458 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21459 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21460 if (user_mode(regs))
21461 return single_step_cont(regs, args);
21462 break;
21463 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21464 #endif /* CONFIG_DEBUG_RODATA */
21465
21466 bpt->type = BP_BREAKPOINT;
21467 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21468 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21469 BREAK_INSTR_SIZE);
21470 if (err)
21471 return err;
21472 - err = probe_kernel_write((char *)bpt->bpt_addr,
21473 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21474 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21475 #ifdef CONFIG_DEBUG_RODATA
21476 if (!err)
21477 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21478 return -EBUSY;
21479 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21480 BREAK_INSTR_SIZE);
21481 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21482 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21483 if (err)
21484 return err;
21485 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21486 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21487 if (mutex_is_locked(&text_mutex))
21488 goto knl_write;
21489 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21490 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21491 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21492 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21493 goto knl_write;
21494 return err;
21495 knl_write:
21496 #endif /* CONFIG_DEBUG_RODATA */
21497 - return probe_kernel_write((char *)bpt->bpt_addr,
21498 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21499 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21500 }
21501
21502 diff --git a/arch/x86/kernel/kprobes-opt.c b/arch/x86/kernel/kprobes-opt.c
21503 index c5e410e..ed5a7f0 100644
21504 --- a/arch/x86/kernel/kprobes-opt.c
21505 +++ b/arch/x86/kernel/kprobes-opt.c
21506 @@ -338,7 +338,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21507 * Verify if the address gap is in 2GB range, because this uses
21508 * a relative jump.
21509 */
21510 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21511 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21512 if (abs(rel) > 0x7fffffff)
21513 return -ERANGE;
21514
21515 @@ -353,16 +353,16 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21516 op->optinsn.size = ret;
21517
21518 /* Copy arch-dep-instance from template */
21519 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21520 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21521
21522 /* Set probe information */
21523 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21524
21525 /* Set probe function call */
21526 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21527 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21528
21529 /* Set returning jmp instruction at the tail of out-of-line buffer */
21530 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21531 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21532 (u8 *)op->kp.addr + op->optinsn.size);
21533
21534 flush_icache_range((unsigned long) buf,
21535 @@ -385,7 +385,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21536 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21537
21538 /* Backup instructions which will be replaced by jump address */
21539 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21540 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21541 RELATIVE_ADDR_SIZE);
21542
21543 insn_buf[0] = RELATIVEJUMP_OPCODE;
21544 @@ -483,7 +483,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21545 /* This kprobe is really able to run optimized path. */
21546 op = container_of(p, struct optimized_kprobe, kp);
21547 /* Detour through copied instructions */
21548 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21549 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21550 if (!reenter)
21551 reset_current_kprobe();
21552 preempt_enable_no_resched();
21553 diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
21554 index 57916c0..9e0b9d0 100644
21555 --- a/arch/x86/kernel/kprobes.c
21556 +++ b/arch/x86/kernel/kprobes.c
21557 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21558 s32 raddr;
21559 } __attribute__((packed)) *insn;
21560
21561 - insn = (struct __arch_relative_insn *)from;
21562 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21563 +
21564 + pax_open_kernel();
21565 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21566 insn->op = op;
21567 + pax_close_kernel();
21568 }
21569
21570 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21571 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21572 kprobe_opcode_t opcode;
21573 kprobe_opcode_t *orig_opcodes = opcodes;
21574
21575 - if (search_exception_tables((unsigned long)opcodes))
21576 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21577 return 0; /* Page fault may occur on this address. */
21578
21579 retry:
21580 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21581 * for the first byte, we can recover the original instruction
21582 * from it and kp->opcode.
21583 */
21584 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21585 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21586 buf[0] = kp->opcode;
21587 - return (unsigned long)buf;
21588 + return ktva_ktla((unsigned long)buf);
21589 }
21590
21591 /*
21592 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21593 /* Another subsystem puts a breakpoint, failed to recover */
21594 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21595 return 0;
21596 + pax_open_kernel();
21597 memcpy(dest, insn.kaddr, insn.length);
21598 + pax_close_kernel();
21599
21600 #ifdef CONFIG_X86_64
21601 if (insn_rip_relative(&insn)) {
21602 @@ -355,7 +360,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21603 newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
21604 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
21605 disp = (u8 *) dest + insn_offset_displacement(&insn);
21606 + pax_open_kernel();
21607 *(s32 *) disp = (s32) newdisp;
21608 + pax_close_kernel();
21609 }
21610 #endif
21611 return insn.length;
21612 @@ -485,7 +492,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21613 * nor set current_kprobe, because it doesn't use single
21614 * stepping.
21615 */
21616 - regs->ip = (unsigned long)p->ainsn.insn;
21617 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21618 preempt_enable_no_resched();
21619 return;
21620 }
21621 @@ -502,9 +509,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21622 regs->flags &= ~X86_EFLAGS_IF;
21623 /* single step inline if the instruction is an int3 */
21624 if (p->opcode == BREAKPOINT_INSTRUCTION)
21625 - regs->ip = (unsigned long)p->addr;
21626 + regs->ip = ktla_ktva((unsigned long)p->addr);
21627 else
21628 - regs->ip = (unsigned long)p->ainsn.insn;
21629 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21630 }
21631
21632 /*
21633 @@ -600,7 +607,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21634 setup_singlestep(p, regs, kcb, 0);
21635 return 1;
21636 }
21637 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21638 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21639 /*
21640 * The breakpoint instruction was removed right
21641 * after we hit it. Another cpu has removed
21642 @@ -651,6 +658,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21643 " movq %rax, 152(%rsp)\n"
21644 RESTORE_REGS_STRING
21645 " popfq\n"
21646 +#ifdef KERNEXEC_PLUGIN
21647 + " btsq $63,(%rsp)\n"
21648 +#endif
21649 #else
21650 " pushf\n"
21651 SAVE_REGS_STRING
21652 @@ -788,7 +798,7 @@ static void __kprobes
21653 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21654 {
21655 unsigned long *tos = stack_addr(regs);
21656 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21657 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21658 unsigned long orig_ip = (unsigned long)p->addr;
21659 kprobe_opcode_t *insn = p->ainsn.insn;
21660
21661 @@ -970,7 +980,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21662 struct die_args *args = data;
21663 int ret = NOTIFY_DONE;
21664
21665 - if (args->regs && user_mode_vm(args->regs))
21666 + if (args->regs && user_mode(args->regs))
21667 return ret;
21668
21669 switch (val) {
21670 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21671 index 9c2bd8b..bb1131c 100644
21672 --- a/arch/x86/kernel/kvm.c
21673 +++ b/arch/x86/kernel/kvm.c
21674 @@ -452,7 +452,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21675 return NOTIFY_OK;
21676 }
21677
21678 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21679 +static struct notifier_block kvm_cpu_notifier = {
21680 .notifier_call = kvm_cpu_notify,
21681 };
21682 #endif
21683 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21684 index ebc9873..1b9724b 100644
21685 --- a/arch/x86/kernel/ldt.c
21686 +++ b/arch/x86/kernel/ldt.c
21687 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21688 if (reload) {
21689 #ifdef CONFIG_SMP
21690 preempt_disable();
21691 - load_LDT(pc);
21692 + load_LDT_nolock(pc);
21693 if (!cpumask_equal(mm_cpumask(current->mm),
21694 cpumask_of(smp_processor_id())))
21695 smp_call_function(flush_ldt, current->mm, 1);
21696 preempt_enable();
21697 #else
21698 - load_LDT(pc);
21699 + load_LDT_nolock(pc);
21700 #endif
21701 }
21702 if (oldsize) {
21703 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21704 return err;
21705
21706 for (i = 0; i < old->size; i++)
21707 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21708 + write_ldt_entry(new->ldt, i, old->ldt + i);
21709 return 0;
21710 }
21711
21712 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21713 retval = copy_ldt(&mm->context, &old_mm->context);
21714 mutex_unlock(&old_mm->context.lock);
21715 }
21716 +
21717 + if (tsk == current) {
21718 + mm->context.vdso = 0;
21719 +
21720 +#ifdef CONFIG_X86_32
21721 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21722 + mm->context.user_cs_base = 0UL;
21723 + mm->context.user_cs_limit = ~0UL;
21724 +
21725 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21726 + cpus_clear(mm->context.cpu_user_cs_mask);
21727 +#endif
21728 +
21729 +#endif
21730 +#endif
21731 +
21732 + }
21733 +
21734 return retval;
21735 }
21736
21737 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21738 }
21739 }
21740
21741 +#ifdef CONFIG_PAX_SEGMEXEC
21742 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21743 + error = -EINVAL;
21744 + goto out_unlock;
21745 + }
21746 +#endif
21747 +
21748 fill_ldt(&ldt, &ldt_info);
21749 if (oldmode)
21750 ldt.avl = 0;
21751 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21752 index 5b19e4d..6476a76 100644
21753 --- a/arch/x86/kernel/machine_kexec_32.c
21754 +++ b/arch/x86/kernel/machine_kexec_32.c
21755 @@ -26,7 +26,7 @@
21756 #include <asm/cacheflush.h>
21757 #include <asm/debugreg.h>
21758
21759 -static void set_idt(void *newidt, __u16 limit)
21760 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21761 {
21762 struct desc_ptr curidt;
21763
21764 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21765 }
21766
21767
21768 -static void set_gdt(void *newgdt, __u16 limit)
21769 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21770 {
21771 struct desc_ptr curgdt;
21772
21773 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21774 }
21775
21776 control_page = page_address(image->control_code_page);
21777 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21778 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21779
21780 relocate_kernel_ptr = control_page;
21781 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21782 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21783 index 3a04b22..1d2eb09 100644
21784 --- a/arch/x86/kernel/microcode_core.c
21785 +++ b/arch/x86/kernel/microcode_core.c
21786 @@ -512,7 +512,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21787 return NOTIFY_OK;
21788 }
21789
21790 -static struct notifier_block __refdata mc_cpu_notifier = {
21791 +static struct notifier_block mc_cpu_notifier = {
21792 .notifier_call = mc_cpu_callback,
21793 };
21794
21795 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21796 index 3544aed..01ddc1c 100644
21797 --- a/arch/x86/kernel/microcode_intel.c
21798 +++ b/arch/x86/kernel/microcode_intel.c
21799 @@ -431,13 +431,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21800
21801 static int get_ucode_user(void *to, const void *from, size_t n)
21802 {
21803 - return copy_from_user(to, from, n);
21804 + return copy_from_user(to, (const void __force_user *)from, n);
21805 }
21806
21807 static enum ucode_state
21808 request_microcode_user(int cpu, const void __user *buf, size_t size)
21809 {
21810 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21811 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21812 }
21813
21814 static void microcode_fini_cpu(int cpu)
21815 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21816 index 216a4d7..228255a 100644
21817 --- a/arch/x86/kernel/module.c
21818 +++ b/arch/x86/kernel/module.c
21819 @@ -43,15 +43,60 @@ do { \
21820 } while (0)
21821 #endif
21822
21823 -void *module_alloc(unsigned long size)
21824 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21825 {
21826 - if (PAGE_ALIGN(size) > MODULES_LEN)
21827 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21828 return NULL;
21829 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21830 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21831 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21832 -1, __builtin_return_address(0));
21833 }
21834
21835 +void *module_alloc(unsigned long size)
21836 +{
21837 +
21838 +#ifdef CONFIG_PAX_KERNEXEC
21839 + return __module_alloc(size, PAGE_KERNEL);
21840 +#else
21841 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21842 +#endif
21843 +
21844 +}
21845 +
21846 +#ifdef CONFIG_PAX_KERNEXEC
21847 +#ifdef CONFIG_X86_32
21848 +void *module_alloc_exec(unsigned long size)
21849 +{
21850 + struct vm_struct *area;
21851 +
21852 + if (size == 0)
21853 + return NULL;
21854 +
21855 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21856 + return area ? area->addr : NULL;
21857 +}
21858 +EXPORT_SYMBOL(module_alloc_exec);
21859 +
21860 +void module_free_exec(struct module *mod, void *module_region)
21861 +{
21862 + vunmap(module_region);
21863 +}
21864 +EXPORT_SYMBOL(module_free_exec);
21865 +#else
21866 +void module_free_exec(struct module *mod, void *module_region)
21867 +{
21868 + module_free(mod, module_region);
21869 +}
21870 +EXPORT_SYMBOL(module_free_exec);
21871 +
21872 +void *module_alloc_exec(unsigned long size)
21873 +{
21874 + return __module_alloc(size, PAGE_KERNEL_RX);
21875 +}
21876 +EXPORT_SYMBOL(module_alloc_exec);
21877 +#endif
21878 +#endif
21879 +
21880 #ifdef CONFIG_X86_32
21881 int apply_relocate(Elf32_Shdr *sechdrs,
21882 const char *strtab,
21883 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21884 unsigned int i;
21885 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
21886 Elf32_Sym *sym;
21887 - uint32_t *location;
21888 + uint32_t *plocation, location;
21889
21890 DEBUGP("Applying relocate section %u to %u\n",
21891 relsec, sechdrs[relsec].sh_info);
21892 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
21893 /* This is where to make the change */
21894 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
21895 - + rel[i].r_offset;
21896 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
21897 + location = (uint32_t)plocation;
21898 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
21899 + plocation = ktla_ktva((void *)plocation);
21900 /* This is the symbol it is referring to. Note that all
21901 undefined symbols have been resolved. */
21902 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
21903 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21904 switch (ELF32_R_TYPE(rel[i].r_info)) {
21905 case R_386_32:
21906 /* We add the value into the location given */
21907 - *location += sym->st_value;
21908 + pax_open_kernel();
21909 + *plocation += sym->st_value;
21910 + pax_close_kernel();
21911 break;
21912 case R_386_PC32:
21913 /* Add the value, subtract its position */
21914 - *location += sym->st_value - (uint32_t)location;
21915 + pax_open_kernel();
21916 + *plocation += sym->st_value - location;
21917 + pax_close_kernel();
21918 break;
21919 default:
21920 pr_err("%s: Unknown relocation: %u\n",
21921 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
21922 case R_X86_64_NONE:
21923 break;
21924 case R_X86_64_64:
21925 + pax_open_kernel();
21926 *(u64 *)loc = val;
21927 + pax_close_kernel();
21928 break;
21929 case R_X86_64_32:
21930 + pax_open_kernel();
21931 *(u32 *)loc = val;
21932 + pax_close_kernel();
21933 if (val != *(u32 *)loc)
21934 goto overflow;
21935 break;
21936 case R_X86_64_32S:
21937 + pax_open_kernel();
21938 *(s32 *)loc = val;
21939 + pax_close_kernel();
21940 if ((s64)val != *(s32 *)loc)
21941 goto overflow;
21942 break;
21943 case R_X86_64_PC32:
21944 val -= (u64)loc;
21945 + pax_open_kernel();
21946 *(u32 *)loc = val;
21947 + pax_close_kernel();
21948 +
21949 #if 0
21950 if ((s64)val != *(s32 *)loc)
21951 goto overflow;
21952 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
21953 index 4929502..686c291 100644
21954 --- a/arch/x86/kernel/msr.c
21955 +++ b/arch/x86/kernel/msr.c
21956 @@ -234,7 +234,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
21957 return notifier_from_errno(err);
21958 }
21959
21960 -static struct notifier_block __refdata msr_class_cpu_notifier = {
21961 +static struct notifier_block msr_class_cpu_notifier = {
21962 .notifier_call = msr_class_cpu_callback,
21963 };
21964
21965 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
21966 index f84f5c5..f404e81 100644
21967 --- a/arch/x86/kernel/nmi.c
21968 +++ b/arch/x86/kernel/nmi.c
21969 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
21970 return handled;
21971 }
21972
21973 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21974 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
21975 {
21976 struct nmi_desc *desc = nmi_to_desc(type);
21977 unsigned long flags;
21978 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21979 * event confuses some handlers (kdump uses this flag)
21980 */
21981 if (action->flags & NMI_FLAG_FIRST)
21982 - list_add_rcu(&action->list, &desc->head);
21983 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
21984 else
21985 - list_add_tail_rcu(&action->list, &desc->head);
21986 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
21987
21988 spin_unlock_irqrestore(&desc->lock, flags);
21989 return 0;
21990 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
21991 if (!strcmp(n->name, name)) {
21992 WARN(in_nmi(),
21993 "Trying to free NMI (%s) from NMI context!\n", n->name);
21994 - list_del_rcu(&n->list);
21995 + pax_list_del_rcu((struct list_head *)&n->list);
21996 break;
21997 }
21998 }
21999 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
22000 dotraplinkage notrace __kprobes void
22001 do_nmi(struct pt_regs *regs, long error_code)
22002 {
22003 +
22004 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
22005 + if (!user_mode(regs)) {
22006 + unsigned long cs = regs->cs & 0xFFFF;
22007 + unsigned long ip = ktva_ktla(regs->ip);
22008 +
22009 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
22010 + regs->ip = ip;
22011 + }
22012 +#endif
22013 +
22014 nmi_nesting_preprocess(regs);
22015
22016 nmi_enter();
22017 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
22018 index 6d9582e..f746287 100644
22019 --- a/arch/x86/kernel/nmi_selftest.c
22020 +++ b/arch/x86/kernel/nmi_selftest.c
22021 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
22022 {
22023 /* trap all the unknown NMIs we may generate */
22024 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
22025 - __initdata);
22026 + __initconst);
22027 }
22028
22029 static void __init cleanup_nmi_testsuite(void)
22030 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
22031 unsigned long timeout;
22032
22033 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
22034 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
22035 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
22036 nmi_fail = FAILURE;
22037 return;
22038 }
22039 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
22040 index 676b8c7..870ba04 100644
22041 --- a/arch/x86/kernel/paravirt-spinlocks.c
22042 +++ b/arch/x86/kernel/paravirt-spinlocks.c
22043 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
22044 arch_spin_lock(lock);
22045 }
22046
22047 -struct pv_lock_ops pv_lock_ops = {
22048 +struct pv_lock_ops pv_lock_ops __read_only = {
22049 #ifdef CONFIG_SMP
22050 .spin_is_locked = __ticket_spin_is_locked,
22051 .spin_is_contended = __ticket_spin_is_contended,
22052 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
22053 index 17fff18..5cfa0f4 100644
22054 --- a/arch/x86/kernel/paravirt.c
22055 +++ b/arch/x86/kernel/paravirt.c
22056 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
22057 {
22058 return x;
22059 }
22060 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
22061 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
22062 +#endif
22063
22064 void __init default_banner(void)
22065 {
22066 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
22067 if (opfunc == NULL)
22068 /* If there's no function, patch it with a ud2a (BUG) */
22069 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
22070 - else if (opfunc == _paravirt_nop)
22071 + else if (opfunc == (void *)_paravirt_nop)
22072 /* If the operation is a nop, then nop the callsite */
22073 ret = paravirt_patch_nop();
22074
22075 /* identity functions just return their single argument */
22076 - else if (opfunc == _paravirt_ident_32)
22077 + else if (opfunc == (void *)_paravirt_ident_32)
22078 ret = paravirt_patch_ident_32(insnbuf, len);
22079 - else if (opfunc == _paravirt_ident_64)
22080 + else if (opfunc == (void *)_paravirt_ident_64)
22081 ret = paravirt_patch_ident_64(insnbuf, len);
22082 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
22083 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
22084 + ret = paravirt_patch_ident_64(insnbuf, len);
22085 +#endif
22086
22087 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
22088 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
22089 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
22090 if (insn_len > len || start == NULL)
22091 insn_len = len;
22092 else
22093 - memcpy(insnbuf, start, insn_len);
22094 + memcpy(insnbuf, ktla_ktva(start), insn_len);
22095
22096 return insn_len;
22097 }
22098 @@ -304,7 +311,7 @@ void arch_flush_lazy_mmu_mode(void)
22099 preempt_enable();
22100 }
22101
22102 -struct pv_info pv_info = {
22103 +struct pv_info pv_info __read_only = {
22104 .name = "bare hardware",
22105 .paravirt_enabled = 0,
22106 .kernel_rpl = 0,
22107 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
22108 #endif
22109 };
22110
22111 -struct pv_init_ops pv_init_ops = {
22112 +struct pv_init_ops pv_init_ops __read_only = {
22113 .patch = native_patch,
22114 };
22115
22116 -struct pv_time_ops pv_time_ops = {
22117 +struct pv_time_ops pv_time_ops __read_only = {
22118 .sched_clock = native_sched_clock,
22119 .steal_clock = native_steal_clock,
22120 };
22121
22122 -struct pv_irq_ops pv_irq_ops = {
22123 +struct pv_irq_ops pv_irq_ops __read_only = {
22124 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
22125 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
22126 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
22127 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
22128 #endif
22129 };
22130
22131 -struct pv_cpu_ops pv_cpu_ops = {
22132 +struct pv_cpu_ops pv_cpu_ops __read_only = {
22133 .cpuid = native_cpuid,
22134 .get_debugreg = native_get_debugreg,
22135 .set_debugreg = native_set_debugreg,
22136 @@ -395,21 +402,26 @@ struct pv_cpu_ops pv_cpu_ops = {
22137 .end_context_switch = paravirt_nop,
22138 };
22139
22140 -struct pv_apic_ops pv_apic_ops = {
22141 +struct pv_apic_ops pv_apic_ops __read_only= {
22142 #ifdef CONFIG_X86_LOCAL_APIC
22143 .startup_ipi_hook = paravirt_nop,
22144 #endif
22145 };
22146
22147 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
22148 +#ifdef CONFIG_X86_32
22149 +#ifdef CONFIG_X86_PAE
22150 +/* 64-bit pagetable entries */
22151 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
22152 +#else
22153 /* 32-bit pagetable entries */
22154 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
22155 +#endif
22156 #else
22157 /* 64-bit pagetable entries */
22158 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
22159 #endif
22160
22161 -struct pv_mmu_ops pv_mmu_ops = {
22162 +struct pv_mmu_ops pv_mmu_ops __read_only = {
22163
22164 .read_cr2 = native_read_cr2,
22165 .write_cr2 = native_write_cr2,
22166 @@ -459,6 +471,7 @@ struct pv_mmu_ops pv_mmu_ops = {
22167 .make_pud = PTE_IDENT,
22168
22169 .set_pgd = native_set_pgd,
22170 + .set_pgd_batched = native_set_pgd_batched,
22171 #endif
22172 #endif /* PAGETABLE_LEVELS >= 3 */
22173
22174 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
22175 },
22176
22177 .set_fixmap = native_set_fixmap,
22178 +
22179 +#ifdef CONFIG_PAX_KERNEXEC
22180 + .pax_open_kernel = native_pax_open_kernel,
22181 + .pax_close_kernel = native_pax_close_kernel,
22182 +#endif
22183 +
22184 };
22185
22186 EXPORT_SYMBOL_GPL(pv_time_ops);
22187 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
22188 index 35ccf75..7a15747 100644
22189 --- a/arch/x86/kernel/pci-iommu_table.c
22190 +++ b/arch/x86/kernel/pci-iommu_table.c
22191 @@ -2,7 +2,7 @@
22192 #include <asm/iommu_table.h>
22193 #include <linux/string.h>
22194 #include <linux/kallsyms.h>
22195 -
22196 +#include <linux/sched.h>
22197
22198 #define DEBUG 1
22199
22200 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
22201 index 6c483ba..d10ce2f 100644
22202 --- a/arch/x86/kernel/pci-swiotlb.c
22203 +++ b/arch/x86/kernel/pci-swiotlb.c
22204 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
22205 void *vaddr, dma_addr_t dma_addr,
22206 struct dma_attrs *attrs)
22207 {
22208 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
22209 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
22210 }
22211
22212 static struct dma_map_ops swiotlb_dma_ops = {
22213 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
22214 index 2ed787f..f70c9f6 100644
22215 --- a/arch/x86/kernel/process.c
22216 +++ b/arch/x86/kernel/process.c
22217 @@ -36,7 +36,8 @@
22218 * section. Since TSS's are completely CPU-local, we want them
22219 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
22220 */
22221 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
22222 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
22223 +EXPORT_SYMBOL(init_tss);
22224
22225 #ifdef CONFIG_X86_64
22226 static DEFINE_PER_CPU(unsigned char, is_idle);
22227 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
22228 task_xstate_cachep =
22229 kmem_cache_create("task_xstate", xstate_size,
22230 __alignof__(union thread_xstate),
22231 - SLAB_PANIC | SLAB_NOTRACK, NULL);
22232 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
22233 }
22234
22235 /*
22236 @@ -105,7 +106,7 @@ void exit_thread(void)
22237 unsigned long *bp = t->io_bitmap_ptr;
22238
22239 if (bp) {
22240 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
22241 + struct tss_struct *tss = init_tss + get_cpu();
22242
22243 t->io_bitmap_ptr = NULL;
22244 clear_thread_flag(TIF_IO_BITMAP);
22245 @@ -136,7 +137,7 @@ void show_regs_common(void)
22246 board = dmi_get_system_info(DMI_BOARD_NAME);
22247
22248 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
22249 - current->pid, current->comm, print_tainted(),
22250 + task_pid_nr(current), current->comm, print_tainted(),
22251 init_utsname()->release,
22252 (int)strcspn(init_utsname()->version, " "),
22253 init_utsname()->version,
22254 @@ -149,6 +150,9 @@ void flush_thread(void)
22255 {
22256 struct task_struct *tsk = current;
22257
22258 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
22259 + loadsegment(gs, 0);
22260 +#endif
22261 flush_ptrace_hw_breakpoint(tsk);
22262 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
22263 drop_init_fpu(tsk);
22264 @@ -301,7 +305,7 @@ static void __exit_idle(void)
22265 void exit_idle(void)
22266 {
22267 /* idle loop has pid 0 */
22268 - if (current->pid)
22269 + if (task_pid_nr(current))
22270 return;
22271 __exit_idle();
22272 }
22273 @@ -404,7 +408,7 @@ bool set_pm_idle_to_default(void)
22274
22275 return ret;
22276 }
22277 -void stop_this_cpu(void *dummy)
22278 +__noreturn void stop_this_cpu(void *dummy)
22279 {
22280 local_irq_disable();
22281 /*
22282 @@ -632,16 +636,37 @@ static int __init idle_setup(char *str)
22283 }
22284 early_param("idle", idle_setup);
22285
22286 -unsigned long arch_align_stack(unsigned long sp)
22287 +#ifdef CONFIG_PAX_RANDKSTACK
22288 +void pax_randomize_kstack(struct pt_regs *regs)
22289 {
22290 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
22291 - sp -= get_random_int() % 8192;
22292 - return sp & ~0xf;
22293 -}
22294 + struct thread_struct *thread = &current->thread;
22295 + unsigned long time;
22296
22297 -unsigned long arch_randomize_brk(struct mm_struct *mm)
22298 -{
22299 - unsigned long range_end = mm->brk + 0x02000000;
22300 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
22301 -}
22302 + if (!randomize_va_space)
22303 + return;
22304 +
22305 + if (v8086_mode(regs))
22306 + return;
22307
22308 + rdtscl(time);
22309 +
22310 + /* P4 seems to return a 0 LSB, ignore it */
22311 +#ifdef CONFIG_MPENTIUM4
22312 + time &= 0x3EUL;
22313 + time <<= 2;
22314 +#elif defined(CONFIG_X86_64)
22315 + time &= 0xFUL;
22316 + time <<= 4;
22317 +#else
22318 + time &= 0x1FUL;
22319 + time <<= 3;
22320 +#endif
22321 +
22322 + thread->sp0 ^= time;
22323 + load_sp0(init_tss + smp_processor_id(), thread);
22324 +
22325 +#ifdef CONFIG_X86_64
22326 + this_cpu_write(kernel_stack, thread->sp0);
22327 +#endif
22328 +}
22329 +#endif
22330 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
22331 index b5a8905..d9cacac 100644
22332 --- a/arch/x86/kernel/process_32.c
22333 +++ b/arch/x86/kernel/process_32.c
22334 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
22335 unsigned long thread_saved_pc(struct task_struct *tsk)
22336 {
22337 return ((unsigned long *)tsk->thread.sp)[3];
22338 +//XXX return tsk->thread.eip;
22339 }
22340
22341 void __show_regs(struct pt_regs *regs, int all)
22342 @@ -74,21 +75,20 @@ void __show_regs(struct pt_regs *regs, int all)
22343 unsigned long sp;
22344 unsigned short ss, gs;
22345
22346 - if (user_mode_vm(regs)) {
22347 + if (user_mode(regs)) {
22348 sp = regs->sp;
22349 ss = regs->ss & 0xffff;
22350 - gs = get_user_gs(regs);
22351 } else {
22352 sp = kernel_stack_pointer(regs);
22353 savesegment(ss, ss);
22354 - savesegment(gs, gs);
22355 }
22356 + gs = get_user_gs(regs);
22357
22358 show_regs_common();
22359
22360 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
22361 (u16)regs->cs, regs->ip, regs->flags,
22362 - smp_processor_id());
22363 + raw_smp_processor_id());
22364 print_symbol("EIP is at %s\n", regs->ip);
22365
22366 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
22367 @@ -130,20 +130,21 @@ void release_thread(struct task_struct *dead_task)
22368 int copy_thread(unsigned long clone_flags, unsigned long sp,
22369 unsigned long arg, struct task_struct *p)
22370 {
22371 - struct pt_regs *childregs = task_pt_regs(p);
22372 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
22373 struct task_struct *tsk;
22374 int err;
22375
22376 p->thread.sp = (unsigned long) childregs;
22377 p->thread.sp0 = (unsigned long) (childregs+1);
22378 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22379
22380 if (unlikely(p->flags & PF_KTHREAD)) {
22381 /* kernel thread */
22382 memset(childregs, 0, sizeof(struct pt_regs));
22383 p->thread.ip = (unsigned long) ret_from_kernel_thread;
22384 - task_user_gs(p) = __KERNEL_STACK_CANARY;
22385 - childregs->ds = __USER_DS;
22386 - childregs->es = __USER_DS;
22387 + savesegment(gs, childregs->gs);
22388 + childregs->ds = __KERNEL_DS;
22389 + childregs->es = __KERNEL_DS;
22390 childregs->fs = __KERNEL_PERCPU;
22391 childregs->bx = sp; /* function */
22392 childregs->bp = arg;
22393 @@ -250,7 +251,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22394 struct thread_struct *prev = &prev_p->thread,
22395 *next = &next_p->thread;
22396 int cpu = smp_processor_id();
22397 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22398 + struct tss_struct *tss = init_tss + cpu;
22399 fpu_switch_t fpu;
22400
22401 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22402 @@ -274,6 +275,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22403 */
22404 lazy_save_gs(prev->gs);
22405
22406 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22407 + __set_fs(task_thread_info(next_p)->addr_limit);
22408 +#endif
22409 +
22410 /*
22411 * Load the per-thread Thread-Local Storage descriptor.
22412 */
22413 @@ -304,6 +309,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22414 */
22415 arch_end_context_switch(next_p);
22416
22417 + this_cpu_write(current_task, next_p);
22418 + this_cpu_write(current_tinfo, &next_p->tinfo);
22419 +
22420 /*
22421 * Restore %gs if needed (which is common)
22422 */
22423 @@ -312,8 +320,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22424
22425 switch_fpu_finish(next_p, fpu);
22426
22427 - this_cpu_write(current_task, next_p);
22428 -
22429 return prev_p;
22430 }
22431
22432 @@ -343,4 +349,3 @@ unsigned long get_wchan(struct task_struct *p)
22433 } while (count++ < 16);
22434 return 0;
22435 }
22436 -
22437 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22438 index 6e68a61..955a9a5 100644
22439 --- a/arch/x86/kernel/process_64.c
22440 +++ b/arch/x86/kernel/process_64.c
22441 @@ -152,10 +152,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22442 struct pt_regs *childregs;
22443 struct task_struct *me = current;
22444
22445 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22446 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22447 childregs = task_pt_regs(p);
22448 p->thread.sp = (unsigned long) childregs;
22449 p->thread.usersp = me->thread.usersp;
22450 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22451 set_tsk_thread_flag(p, TIF_FORK);
22452 p->fpu_counter = 0;
22453 p->thread.io_bitmap_ptr = NULL;
22454 @@ -274,7 +275,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22455 struct thread_struct *prev = &prev_p->thread;
22456 struct thread_struct *next = &next_p->thread;
22457 int cpu = smp_processor_id();
22458 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22459 + struct tss_struct *tss = init_tss + cpu;
22460 unsigned fsindex, gsindex;
22461 fpu_switch_t fpu;
22462
22463 @@ -356,10 +357,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22464 prev->usersp = this_cpu_read(old_rsp);
22465 this_cpu_write(old_rsp, next->usersp);
22466 this_cpu_write(current_task, next_p);
22467 + this_cpu_write(current_tinfo, &next_p->tinfo);
22468
22469 - this_cpu_write(kernel_stack,
22470 - (unsigned long)task_stack_page(next_p) +
22471 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22472 + this_cpu_write(kernel_stack, next->sp0);
22473
22474 /*
22475 * Now maybe reload the debug registers and handle I/O bitmaps
22476 @@ -428,12 +428,11 @@ unsigned long get_wchan(struct task_struct *p)
22477 if (!p || p == current || p->state == TASK_RUNNING)
22478 return 0;
22479 stack = (unsigned long)task_stack_page(p);
22480 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22481 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22482 return 0;
22483 fp = *(u64 *)(p->thread.sp);
22484 do {
22485 - if (fp < (unsigned long)stack ||
22486 - fp >= (unsigned long)stack+THREAD_SIZE)
22487 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22488 return 0;
22489 ip = *(u64 *)(fp+8);
22490 if (!in_sched_functions(ip))
22491 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22492 index b629bbe..0fa615a 100644
22493 --- a/arch/x86/kernel/ptrace.c
22494 +++ b/arch/x86/kernel/ptrace.c
22495 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22496 {
22497 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22498 unsigned long sp = (unsigned long)&regs->sp;
22499 - struct thread_info *tinfo;
22500
22501 - if (context == (sp & ~(THREAD_SIZE - 1)))
22502 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22503 return sp;
22504
22505 - tinfo = (struct thread_info *)context;
22506 - if (tinfo->previous_esp)
22507 - return tinfo->previous_esp;
22508 + sp = *(unsigned long *)context;
22509 + if (sp)
22510 + return sp;
22511
22512 return (unsigned long)regs;
22513 }
22514 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22515 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22516 {
22517 int i;
22518 - int dr7 = 0;
22519 + unsigned long dr7 = 0;
22520 struct arch_hw_breakpoint *info;
22521
22522 for (i = 0; i < HBP_NUM; i++) {
22523 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22524 unsigned long addr, unsigned long data)
22525 {
22526 int ret;
22527 - unsigned long __user *datap = (unsigned long __user *)data;
22528 + unsigned long __user *datap = (__force unsigned long __user *)data;
22529
22530 switch (request) {
22531 /* read the word at location addr in the USER area. */
22532 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22533 if ((int) addr < 0)
22534 return -EIO;
22535 ret = do_get_thread_area(child, addr,
22536 - (struct user_desc __user *)data);
22537 + (__force struct user_desc __user *) data);
22538 break;
22539
22540 case PTRACE_SET_THREAD_AREA:
22541 if ((int) addr < 0)
22542 return -EIO;
22543 ret = do_set_thread_area(child, addr,
22544 - (struct user_desc __user *)data, 0);
22545 + (__force struct user_desc __user *) data, 0);
22546 break;
22547 #endif
22548
22549 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22550
22551 #ifdef CONFIG_X86_64
22552
22553 -static struct user_regset x86_64_regsets[] __read_mostly = {
22554 +static user_regset_no_const x86_64_regsets[] __read_only = {
22555 [REGSET_GENERAL] = {
22556 .core_note_type = NT_PRSTATUS,
22557 .n = sizeof(struct user_regs_struct) / sizeof(long),
22558 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22559 #endif /* CONFIG_X86_64 */
22560
22561 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22562 -static struct user_regset x86_32_regsets[] __read_mostly = {
22563 +static user_regset_no_const x86_32_regsets[] __read_only = {
22564 [REGSET_GENERAL] = {
22565 .core_note_type = NT_PRSTATUS,
22566 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22567 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22568 */
22569 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22570
22571 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22572 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22573 {
22574 #ifdef CONFIG_X86_64
22575 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22576 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22577 memset(info, 0, sizeof(*info));
22578 info->si_signo = SIGTRAP;
22579 info->si_code = si_code;
22580 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22581 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22582 }
22583
22584 void user_single_step_siginfo(struct task_struct *tsk,
22585 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22586 # define IS_IA32 0
22587 #endif
22588
22589 +#ifdef CONFIG_GRKERNSEC_SETXID
22590 +extern void gr_delayed_cred_worker(void);
22591 +#endif
22592 +
22593 /*
22594 * We must return the syscall number to actually look up in the table.
22595 * This can be -1L to skip running any syscall at all.
22596 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22597
22598 user_exit();
22599
22600 +#ifdef CONFIG_GRKERNSEC_SETXID
22601 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22602 + gr_delayed_cred_worker();
22603 +#endif
22604 +
22605 /*
22606 * If we stepped into a sysenter/syscall insn, it trapped in
22607 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22608 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22609 */
22610 user_exit();
22611
22612 +#ifdef CONFIG_GRKERNSEC_SETXID
22613 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22614 + gr_delayed_cred_worker();
22615 +#endif
22616 +
22617 audit_syscall_exit(regs);
22618
22619 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22620 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22621 index 2cb9470..ff1fd80 100644
22622 --- a/arch/x86/kernel/pvclock.c
22623 +++ b/arch/x86/kernel/pvclock.c
22624 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22625 return pv_tsc_khz;
22626 }
22627
22628 -static atomic64_t last_value = ATOMIC64_INIT(0);
22629 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22630
22631 void pvclock_resume(void)
22632 {
22633 - atomic64_set(&last_value, 0);
22634 + atomic64_set_unchecked(&last_value, 0);
22635 }
22636
22637 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22638 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22639 * updating at the same time, and one of them could be slightly behind,
22640 * making the assumption that last_value always go forward fail to hold.
22641 */
22642 - last = atomic64_read(&last_value);
22643 + last = atomic64_read_unchecked(&last_value);
22644 do {
22645 if (ret < last)
22646 return last;
22647 - last = atomic64_cmpxchg(&last_value, last, ret);
22648 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22649 } while (unlikely(last != ret));
22650
22651 return ret;
22652 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22653 index 76fa1e9..abf09ea 100644
22654 --- a/arch/x86/kernel/reboot.c
22655 +++ b/arch/x86/kernel/reboot.c
22656 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22657 EXPORT_SYMBOL(pm_power_off);
22658
22659 static const struct desc_ptr no_idt = {};
22660 -static int reboot_mode;
22661 +static unsigned short reboot_mode;
22662 enum reboot_type reboot_type = BOOT_ACPI;
22663 int reboot_force;
22664
22665 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22666
22667 void __noreturn machine_real_restart(unsigned int type)
22668 {
22669 +
22670 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22671 + struct desc_struct *gdt;
22672 +#endif
22673 +
22674 local_irq_disable();
22675
22676 /*
22677 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22678
22679 /* Jump to the identity-mapped low memory code */
22680 #ifdef CONFIG_X86_32
22681 - asm volatile("jmpl *%0" : :
22682 +
22683 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22684 + gdt = get_cpu_gdt_table(smp_processor_id());
22685 + pax_open_kernel();
22686 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22687 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22688 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22689 + loadsegment(ds, __KERNEL_DS);
22690 + loadsegment(es, __KERNEL_DS);
22691 + loadsegment(ss, __KERNEL_DS);
22692 +#endif
22693 +#ifdef CONFIG_PAX_KERNEXEC
22694 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22695 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22696 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22697 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22698 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22699 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22700 +#endif
22701 + pax_close_kernel();
22702 +#endif
22703 +
22704 + asm volatile("ljmpl *%0" : :
22705 "rm" (real_mode_header->machine_real_restart_asm),
22706 "a" (type));
22707 #else
22708 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22709 * try to force a triple fault and then cycle between hitting the keyboard
22710 * controller and doing that
22711 */
22712 -static void native_machine_emergency_restart(void)
22713 +static void __noreturn native_machine_emergency_restart(void)
22714 {
22715 int i;
22716 int attempt = 0;
22717 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22718 #endif
22719 }
22720
22721 -static void __machine_emergency_restart(int emergency)
22722 +static void __noreturn __machine_emergency_restart(int emergency)
22723 {
22724 reboot_emergency = emergency;
22725 machine_ops.emergency_restart();
22726 }
22727
22728 -static void native_machine_restart(char *__unused)
22729 +static void __noreturn native_machine_restart(char *__unused)
22730 {
22731 pr_notice("machine restart\n");
22732
22733 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22734 __machine_emergency_restart(0);
22735 }
22736
22737 -static void native_machine_halt(void)
22738 +static void __noreturn native_machine_halt(void)
22739 {
22740 /* Stop other cpus and apics */
22741 machine_shutdown();
22742 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22743 stop_this_cpu(NULL);
22744 }
22745
22746 -static void native_machine_power_off(void)
22747 +static void __noreturn native_machine_power_off(void)
22748 {
22749 if (pm_power_off) {
22750 if (!reboot_force)
22751 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22752 }
22753 /* A fallback in case there is no PM info available */
22754 tboot_shutdown(TB_SHUTDOWN_HALT);
22755 + unreachable();
22756 }
22757
22758 -struct machine_ops machine_ops = {
22759 +struct machine_ops machine_ops __read_only = {
22760 .power_off = native_machine_power_off,
22761 .shutdown = native_machine_shutdown,
22762 .emergency_restart = native_machine_emergency_restart,
22763 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22764 index 7a6f3b3..bed145d7 100644
22765 --- a/arch/x86/kernel/relocate_kernel_64.S
22766 +++ b/arch/x86/kernel/relocate_kernel_64.S
22767 @@ -11,6 +11,7 @@
22768 #include <asm/kexec.h>
22769 #include <asm/processor-flags.h>
22770 #include <asm/pgtable_types.h>
22771 +#include <asm/alternative-asm.h>
22772
22773 /*
22774 * Must be relocatable PIC code callable as a C function
22775 @@ -160,13 +161,14 @@ identity_mapped:
22776 xorq %rbp, %rbp
22777 xorq %r8, %r8
22778 xorq %r9, %r9
22779 - xorq %r10, %r9
22780 + xorq %r10, %r10
22781 xorq %r11, %r11
22782 xorq %r12, %r12
22783 xorq %r13, %r13
22784 xorq %r14, %r14
22785 xorq %r15, %r15
22786
22787 + pax_force_retaddr 0, 1
22788 ret
22789
22790 1:
22791 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22792 index 8b24289..d37b58b 100644
22793 --- a/arch/x86/kernel/setup.c
22794 +++ b/arch/x86/kernel/setup.c
22795 @@ -437,7 +437,7 @@ static void __init parse_setup_data(void)
22796
22797 switch (data->type) {
22798 case SETUP_E820_EXT:
22799 - parse_e820_ext(data);
22800 + parse_e820_ext((struct setup_data __force_kernel *)data);
22801 break;
22802 case SETUP_DTB:
22803 add_dtb(pa_data);
22804 @@ -706,7 +706,7 @@ static void __init trim_bios_range(void)
22805 * area (640->1Mb) as ram even though it is not.
22806 * take them out.
22807 */
22808 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22809 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22810
22811 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22812 }
22813 @@ -830,14 +830,14 @@ void __init setup_arch(char **cmdline_p)
22814
22815 if (!boot_params.hdr.root_flags)
22816 root_mountflags &= ~MS_RDONLY;
22817 - init_mm.start_code = (unsigned long) _text;
22818 - init_mm.end_code = (unsigned long) _etext;
22819 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22820 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22821 init_mm.end_data = (unsigned long) _edata;
22822 init_mm.brk = _brk_end;
22823
22824 - code_resource.start = virt_to_phys(_text);
22825 - code_resource.end = virt_to_phys(_etext)-1;
22826 - data_resource.start = virt_to_phys(_etext);
22827 + code_resource.start = virt_to_phys(ktla_ktva(_text));
22828 + code_resource.end = virt_to_phys(ktla_ktva(_etext))-1;
22829 + data_resource.start = virt_to_phys(_sdata);
22830 data_resource.end = virt_to_phys(_edata)-1;
22831 bss_resource.start = virt_to_phys(&__bss_start);
22832 bss_resource.end = virt_to_phys(&__bss_stop)-1;
22833 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22834 index 5cdff03..80fa283 100644
22835 --- a/arch/x86/kernel/setup_percpu.c
22836 +++ b/arch/x86/kernel/setup_percpu.c
22837 @@ -21,19 +21,17 @@
22838 #include <asm/cpu.h>
22839 #include <asm/stackprotector.h>
22840
22841 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22842 +#ifdef CONFIG_SMP
22843 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22844 EXPORT_PER_CPU_SYMBOL(cpu_number);
22845 +#endif
22846
22847 -#ifdef CONFIG_X86_64
22848 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
22849 -#else
22850 -#define BOOT_PERCPU_OFFSET 0
22851 -#endif
22852
22853 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
22854 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
22855
22856 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
22857 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
22858 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
22859 };
22860 EXPORT_SYMBOL(__per_cpu_offset);
22861 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
22862 {
22863 #ifdef CONFIG_NEED_MULTIPLE_NODES
22864 pg_data_t *last = NULL;
22865 - unsigned int cpu;
22866 + int cpu;
22867
22868 for_each_possible_cpu(cpu) {
22869 int node = early_cpu_to_node(cpu);
22870 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
22871 {
22872 #ifdef CONFIG_X86_32
22873 struct desc_struct gdt;
22874 + unsigned long base = per_cpu_offset(cpu);
22875
22876 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
22877 - 0x2 | DESCTYPE_S, 0x8);
22878 - gdt.s = 1;
22879 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
22880 + 0x83 | DESCTYPE_S, 0xC);
22881 write_gdt_entry(get_cpu_gdt_table(cpu),
22882 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
22883 #endif
22884 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
22885 /* alrighty, percpu areas up and running */
22886 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
22887 for_each_possible_cpu(cpu) {
22888 +#ifdef CONFIG_CC_STACKPROTECTOR
22889 +#ifdef CONFIG_X86_32
22890 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
22891 +#endif
22892 +#endif
22893 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
22894 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
22895 per_cpu(cpu_number, cpu) = cpu;
22896 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
22897 */
22898 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
22899 #endif
22900 +#ifdef CONFIG_CC_STACKPROTECTOR
22901 +#ifdef CONFIG_X86_32
22902 + if (!cpu)
22903 + per_cpu(stack_canary.canary, cpu) = canary;
22904 +#endif
22905 +#endif
22906 /*
22907 * Up to this point, the boot CPU has been using .init.data
22908 * area. Reload any changed state for the boot CPU.
22909 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
22910 index d6bf1f3..3ffce5a 100644
22911 --- a/arch/x86/kernel/signal.c
22912 +++ b/arch/x86/kernel/signal.c
22913 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
22914 * Align the stack pointer according to the i386 ABI,
22915 * i.e. so that on function entry ((sp + 4) & 15) == 0.
22916 */
22917 - sp = ((sp + 4) & -16ul) - 4;
22918 + sp = ((sp - 12) & -16ul) - 4;
22919 #else /* !CONFIG_X86_32 */
22920 sp = round_down(sp, 16) - 8;
22921 #endif
22922 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
22923 }
22924
22925 if (current->mm->context.vdso)
22926 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22927 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22928 else
22929 - restorer = &frame->retcode;
22930 + restorer = (void __user *)&frame->retcode;
22931 if (ka->sa.sa_flags & SA_RESTORER)
22932 restorer = ka->sa.sa_restorer;
22933
22934 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
22935 * reasons and because gdb uses it as a signature to notice
22936 * signal handler stack frames.
22937 */
22938 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
22939 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
22940
22941 if (err)
22942 return -EFAULT;
22943 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
22944 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
22945
22946 /* Set up to return from userspace. */
22947 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22948 + if (current->mm->context.vdso)
22949 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22950 + else
22951 + restorer = (void __user *)&frame->retcode;
22952 if (ka->sa.sa_flags & SA_RESTORER)
22953 restorer = ka->sa.sa_restorer;
22954 put_user_ex(restorer, &frame->pretcode);
22955 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
22956 * reasons and because gdb uses it as a signature to notice
22957 * signal handler stack frames.
22958 */
22959 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
22960 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
22961 } put_user_catch(err);
22962
22963 err |= copy_siginfo_to_user(&frame->info, info);
22964 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
22965 index 48d2b7d..90d328a 100644
22966 --- a/arch/x86/kernel/smp.c
22967 +++ b/arch/x86/kernel/smp.c
22968 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
22969
22970 __setup("nonmi_ipi", nonmi_ipi_setup);
22971
22972 -struct smp_ops smp_ops = {
22973 +struct smp_ops smp_ops __read_only = {
22974 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
22975 .smp_prepare_cpus = native_smp_prepare_cpus,
22976 .smp_cpus_done = native_smp_cpus_done,
22977 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
22978 index ed0fe38..87fc692 100644
22979 --- a/arch/x86/kernel/smpboot.c
22980 +++ b/arch/x86/kernel/smpboot.c
22981 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22982 idle->thread.sp = (unsigned long) (((struct pt_regs *)
22983 (THREAD_SIZE + task_stack_page(idle))) - 1);
22984 per_cpu(current_task, cpu) = idle;
22985 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
22986
22987 #ifdef CONFIG_X86_32
22988 /* Stack for startup_32 can be just as for start_secondary onwards */
22989 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22990 #else
22991 clear_tsk_thread_flag(idle, TIF_FORK);
22992 initial_gs = per_cpu_offset(cpu);
22993 - per_cpu(kernel_stack, cpu) =
22994 - (unsigned long)task_stack_page(idle) -
22995 - KERNEL_STACK_OFFSET + THREAD_SIZE;
22996 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
22997 #endif
22998 +
22999 + pax_open_kernel();
23000 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
23001 + pax_close_kernel();
23002 +
23003 initial_code = (unsigned long)start_secondary;
23004 stack_start = idle->thread.sp;
23005
23006 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
23007 /* the FPU context is blank, nobody can own it */
23008 __cpu_disable_lazy_restore(cpu);
23009
23010 +#ifdef CONFIG_PAX_PER_CPU_PGD
23011 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
23012 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
23013 + KERNEL_PGD_PTRS);
23014 +#endif
23015 +
23016 + /* the FPU context is blank, nobody can own it */
23017 + __cpu_disable_lazy_restore(cpu);
23018 +
23019 err = do_boot_cpu(apicid, cpu, tidle);
23020 if (err) {
23021 pr_debug("do_boot_cpu failed %d\n", err);
23022 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
23023 index 9b4d51d..5d28b58 100644
23024 --- a/arch/x86/kernel/step.c
23025 +++ b/arch/x86/kernel/step.c
23026 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
23027 struct desc_struct *desc;
23028 unsigned long base;
23029
23030 - seg &= ~7UL;
23031 + seg >>= 3;
23032
23033 mutex_lock(&child->mm->context.lock);
23034 - if (unlikely((seg >> 3) >= child->mm->context.size))
23035 + if (unlikely(seg >= child->mm->context.size))
23036 addr = -1L; /* bogus selector, access would fault */
23037 else {
23038 desc = child->mm->context.ldt + seg;
23039 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
23040 addr += base;
23041 }
23042 mutex_unlock(&child->mm->context.lock);
23043 - }
23044 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
23045 + addr = ktla_ktva(addr);
23046
23047 return addr;
23048 }
23049 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
23050 unsigned char opcode[15];
23051 unsigned long addr = convert_ip_to_linear(child, regs);
23052
23053 + if (addr == -EINVAL)
23054 + return 0;
23055 +
23056 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
23057 for (i = 0; i < copied; i++) {
23058 switch (opcode[i]) {
23059 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
23060 new file mode 100644
23061 index 0000000..207bec6
23062 --- /dev/null
23063 +++ b/arch/x86/kernel/sys_i386_32.c
23064 @@ -0,0 +1,250 @@
23065 +/*
23066 + * This file contains various random system calls that
23067 + * have a non-standard calling sequence on the Linux/i386
23068 + * platform.
23069 + */
23070 +
23071 +#include <linux/errno.h>
23072 +#include <linux/sched.h>
23073 +#include <linux/mm.h>
23074 +#include <linux/fs.h>
23075 +#include <linux/smp.h>
23076 +#include <linux/sem.h>
23077 +#include <linux/msg.h>
23078 +#include <linux/shm.h>
23079 +#include <linux/stat.h>
23080 +#include <linux/syscalls.h>
23081 +#include <linux/mman.h>
23082 +#include <linux/file.h>
23083 +#include <linux/utsname.h>
23084 +#include <linux/ipc.h>
23085 +
23086 +#include <linux/uaccess.h>
23087 +#include <linux/unistd.h>
23088 +
23089 +#include <asm/syscalls.h>
23090 +
23091 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
23092 +{
23093 + unsigned long pax_task_size = TASK_SIZE;
23094 +
23095 +#ifdef CONFIG_PAX_SEGMEXEC
23096 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
23097 + pax_task_size = SEGMEXEC_TASK_SIZE;
23098 +#endif
23099 +
23100 + if (flags & MAP_FIXED)
23101 + if (len > pax_task_size || addr > pax_task_size - len)
23102 + return -EINVAL;
23103 +
23104 + return 0;
23105 +}
23106 +
23107 +unsigned long
23108 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
23109 + unsigned long len, unsigned long pgoff, unsigned long flags)
23110 +{
23111 + struct mm_struct *mm = current->mm;
23112 + struct vm_area_struct *vma;
23113 + unsigned long start_addr, pax_task_size = TASK_SIZE;
23114 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23115 +
23116 +#ifdef CONFIG_PAX_SEGMEXEC
23117 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23118 + pax_task_size = SEGMEXEC_TASK_SIZE;
23119 +#endif
23120 +
23121 + pax_task_size -= PAGE_SIZE;
23122 +
23123 + if (len > pax_task_size)
23124 + return -ENOMEM;
23125 +
23126 + if (flags & MAP_FIXED)
23127 + return addr;
23128 +
23129 +#ifdef CONFIG_PAX_RANDMMAP
23130 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23131 +#endif
23132 +
23133 + if (addr) {
23134 + addr = PAGE_ALIGN(addr);
23135 + if (pax_task_size - len >= addr) {
23136 + vma = find_vma(mm, addr);
23137 + if (check_heap_stack_gap(vma, addr, len, offset))
23138 + return addr;
23139 + }
23140 + }
23141 + if (len > mm->cached_hole_size) {
23142 + start_addr = addr = mm->free_area_cache;
23143 + } else {
23144 + start_addr = addr = mm->mmap_base;
23145 + mm->cached_hole_size = 0;
23146 + }
23147 +
23148 +#ifdef CONFIG_PAX_PAGEEXEC
23149 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE) && start_addr >= mm->mmap_base) {
23150 + start_addr = 0x00110000UL;
23151 +
23152 +#ifdef CONFIG_PAX_RANDMMAP
23153 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23154 + start_addr += mm->delta_mmap & 0x03FFF000UL;
23155 +#endif
23156 +
23157 + if (mm->start_brk <= start_addr && start_addr < mm->mmap_base)
23158 + start_addr = addr = mm->mmap_base;
23159 + else
23160 + addr = start_addr;
23161 + }
23162 +#endif
23163 +
23164 +full_search:
23165 + for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
23166 + /* At this point: (!vma || addr < vma->vm_end). */
23167 + if (pax_task_size - len < addr) {
23168 + /*
23169 + * Start a new search - just in case we missed
23170 + * some holes.
23171 + */
23172 + if (start_addr != mm->mmap_base) {
23173 + start_addr = addr = mm->mmap_base;
23174 + mm->cached_hole_size = 0;
23175 + goto full_search;
23176 + }
23177 + return -ENOMEM;
23178 + }
23179 + if (check_heap_stack_gap(vma, addr, len, offset))
23180 + break;
23181 + if (addr + mm->cached_hole_size < vma->vm_start)
23182 + mm->cached_hole_size = vma->vm_start - addr;
23183 + addr = vma->vm_end;
23184 + if (mm->start_brk <= addr && addr < mm->mmap_base) {
23185 + start_addr = addr = mm->mmap_base;
23186 + mm->cached_hole_size = 0;
23187 + goto full_search;
23188 + }
23189 + }
23190 +
23191 + /*
23192 + * Remember the place where we stopped the search:
23193 + */
23194 + mm->free_area_cache = addr + len;
23195 + return addr;
23196 +}
23197 +
23198 +unsigned long
23199 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23200 + const unsigned long len, const unsigned long pgoff,
23201 + const unsigned long flags)
23202 +{
23203 + struct vm_area_struct *vma;
23204 + struct mm_struct *mm = current->mm;
23205 + unsigned long base = mm->mmap_base, addr = addr0, pax_task_size = TASK_SIZE;
23206 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23207 +
23208 +#ifdef CONFIG_PAX_SEGMEXEC
23209 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23210 + pax_task_size = SEGMEXEC_TASK_SIZE;
23211 +#endif
23212 +
23213 + pax_task_size -= PAGE_SIZE;
23214 +
23215 + /* requested length too big for entire address space */
23216 + if (len > pax_task_size)
23217 + return -ENOMEM;
23218 +
23219 + if (flags & MAP_FIXED)
23220 + return addr;
23221 +
23222 +#ifdef CONFIG_PAX_PAGEEXEC
23223 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
23224 + goto bottomup;
23225 +#endif
23226 +
23227 +#ifdef CONFIG_PAX_RANDMMAP
23228 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23229 +#endif
23230 +
23231 + /* requesting a specific address */
23232 + if (addr) {
23233 + addr = PAGE_ALIGN(addr);
23234 + if (pax_task_size - len >= addr) {
23235 + vma = find_vma(mm, addr);
23236 + if (check_heap_stack_gap(vma, addr, len, offset))
23237 + return addr;
23238 + }
23239 + }
23240 +
23241 + /* check if free_area_cache is useful for us */
23242 + if (len <= mm->cached_hole_size) {
23243 + mm->cached_hole_size = 0;
23244 + mm->free_area_cache = mm->mmap_base;
23245 + }
23246 +
23247 + /* either no address requested or can't fit in requested address hole */
23248 + addr = mm->free_area_cache;
23249 +
23250 + /* make sure it can fit in the remaining address space */
23251 + if (addr > len) {
23252 + vma = find_vma(mm, addr-len);
23253 + if (check_heap_stack_gap(vma, addr - len, len, offset))
23254 + /* remember the address as a hint for next time */
23255 + return (mm->free_area_cache = addr-len);
23256 + }
23257 +
23258 + if (mm->mmap_base < len)
23259 + goto bottomup;
23260 +
23261 + addr = mm->mmap_base-len;
23262 +
23263 + do {
23264 + /*
23265 + * Lookup failure means no vma is above this address,
23266 + * else if new region fits below vma->vm_start,
23267 + * return with success:
23268 + */
23269 + vma = find_vma(mm, addr);
23270 + if (check_heap_stack_gap(vma, addr, len, offset))
23271 + /* remember the address as a hint for next time */
23272 + return (mm->free_area_cache = addr);
23273 +
23274 + /* remember the largest hole we saw so far */
23275 + if (addr + mm->cached_hole_size < vma->vm_start)
23276 + mm->cached_hole_size = vma->vm_start - addr;
23277 +
23278 + /* try just below the current vma->vm_start */
23279 + addr = skip_heap_stack_gap(vma, len, offset);
23280 + } while (!IS_ERR_VALUE(addr));
23281 +
23282 +bottomup:
23283 + /*
23284 + * A failed mmap() very likely causes application failure,
23285 + * so fall back to the bottom-up function here. This scenario
23286 + * can happen with large stack limits and large mmap()
23287 + * allocations.
23288 + */
23289 +
23290 +#ifdef CONFIG_PAX_SEGMEXEC
23291 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23292 + mm->mmap_base = SEGMEXEC_TASK_UNMAPPED_BASE;
23293 + else
23294 +#endif
23295 +
23296 + mm->mmap_base = TASK_UNMAPPED_BASE;
23297 +
23298 +#ifdef CONFIG_PAX_RANDMMAP
23299 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23300 + mm->mmap_base += mm->delta_mmap;
23301 +#endif
23302 +
23303 + mm->free_area_cache = mm->mmap_base;
23304 + mm->cached_hole_size = ~0UL;
23305 + addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
23306 + /*
23307 + * Restore the topdown base:
23308 + */
23309 + mm->mmap_base = base;
23310 + mm->free_area_cache = base;
23311 + mm->cached_hole_size = ~0UL;
23312 +
23313 + return addr;
23314 +}
23315 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
23316 index 97ef74b..57a1882 100644
23317 --- a/arch/x86/kernel/sys_x86_64.c
23318 +++ b/arch/x86/kernel/sys_x86_64.c
23319 @@ -81,8 +81,8 @@ out:
23320 return error;
23321 }
23322
23323 -static void find_start_end(unsigned long flags, unsigned long *begin,
23324 - unsigned long *end)
23325 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
23326 + unsigned long *begin, unsigned long *end)
23327 {
23328 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
23329 unsigned long new_begin;
23330 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
23331 *begin = new_begin;
23332 }
23333 } else {
23334 - *begin = TASK_UNMAPPED_BASE;
23335 + *begin = mm->mmap_base;
23336 *end = TASK_SIZE;
23337 }
23338 }
23339 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23340 struct vm_area_struct *vma;
23341 struct vm_unmapped_area_info info;
23342 unsigned long begin, end;
23343 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23344
23345 if (flags & MAP_FIXED)
23346 return addr;
23347
23348 - find_start_end(flags, &begin, &end);
23349 + find_start_end(mm, flags, &begin, &end);
23350
23351 if (len > end)
23352 return -ENOMEM;
23353
23354 +#ifdef CONFIG_PAX_RANDMMAP
23355 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23356 +#endif
23357 +
23358 if (addr) {
23359 addr = PAGE_ALIGN(addr);
23360 vma = find_vma(mm, addr);
23361 - if (end - len >= addr &&
23362 - (!vma || addr + len <= vma->vm_start))
23363 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23364 return addr;
23365 }
23366
23367 @@ -161,6 +165,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23368 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
23369 goto bottomup;
23370
23371 +#ifdef CONFIG_PAX_RANDMMAP
23372 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23373 +#endif
23374 +
23375 /* requesting a specific address */
23376 if (addr) {
23377 addr = PAGE_ALIGN(addr);
23378 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
23379 index f84fe00..f41d9f1 100644
23380 --- a/arch/x86/kernel/tboot.c
23381 +++ b/arch/x86/kernel/tboot.c
23382 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
23383
23384 void tboot_shutdown(u32 shutdown_type)
23385 {
23386 - void (*shutdown)(void);
23387 + void (* __noreturn shutdown)(void);
23388
23389 if (!tboot_enabled())
23390 return;
23391 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23392
23393 switch_to_tboot_pt();
23394
23395 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23396 + shutdown = (void *)tboot->shutdown_entry;
23397 shutdown();
23398
23399 /* should not reach here */
23400 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23401 return 0;
23402 }
23403
23404 -static atomic_t ap_wfs_count;
23405 +static atomic_unchecked_t ap_wfs_count;
23406
23407 static int tboot_wait_for_aps(int num_aps)
23408 {
23409 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23410 {
23411 switch (action) {
23412 case CPU_DYING:
23413 - atomic_inc(&ap_wfs_count);
23414 + atomic_inc_unchecked(&ap_wfs_count);
23415 if (num_online_cpus() == 1)
23416 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23417 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23418 return NOTIFY_BAD;
23419 break;
23420 }
23421 return NOTIFY_OK;
23422 }
23423
23424 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23425 +static struct notifier_block tboot_cpu_notifier =
23426 {
23427 .notifier_call = tboot_cpu_callback,
23428 };
23429 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23430
23431 tboot_create_trampoline();
23432
23433 - atomic_set(&ap_wfs_count, 0);
23434 + atomic_set_unchecked(&ap_wfs_count, 0);
23435 register_hotcpu_notifier(&tboot_cpu_notifier);
23436
23437 acpi_os_set_prepare_sleep(&tboot_sleep);
23438 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23439 index 24d3c91..d06b473 100644
23440 --- a/arch/x86/kernel/time.c
23441 +++ b/arch/x86/kernel/time.c
23442 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23443 {
23444 unsigned long pc = instruction_pointer(regs);
23445
23446 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23447 + if (!user_mode(regs) && in_lock_functions(pc)) {
23448 #ifdef CONFIG_FRAME_POINTER
23449 - return *(unsigned long *)(regs->bp + sizeof(long));
23450 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23451 #else
23452 unsigned long *sp =
23453 (unsigned long *)kernel_stack_pointer(regs);
23454 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23455 * or above a saved flags. Eflags has bits 22-31 zero,
23456 * kernel addresses don't.
23457 */
23458 +
23459 +#ifdef CONFIG_PAX_KERNEXEC
23460 + return ktla_ktva(sp[0]);
23461 +#else
23462 if (sp[0] >> 22)
23463 return sp[0];
23464 if (sp[1] >> 22)
23465 return sp[1];
23466 #endif
23467 +
23468 +#endif
23469 }
23470 return pc;
23471 }
23472 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23473 index 9d9d2f9..cad418a 100644
23474 --- a/arch/x86/kernel/tls.c
23475 +++ b/arch/x86/kernel/tls.c
23476 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23477 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23478 return -EINVAL;
23479
23480 +#ifdef CONFIG_PAX_SEGMEXEC
23481 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23482 + return -EINVAL;
23483 +#endif
23484 +
23485 set_tls_desc(p, idx, &info, 1);
23486
23487 return 0;
23488 @@ -204,7 +209,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23489
23490 if (kbuf)
23491 info = kbuf;
23492 - else if (__copy_from_user(infobuf, ubuf, count))
23493 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23494 return -EFAULT;
23495 else
23496 info = infobuf;
23497 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23498 index ecffca1..95c4d13 100644
23499 --- a/arch/x86/kernel/traps.c
23500 +++ b/arch/x86/kernel/traps.c
23501 @@ -68,12 +68,6 @@
23502 #include <asm/setup.h>
23503
23504 asmlinkage int system_call(void);
23505 -
23506 -/*
23507 - * The IDT has to be page-aligned to simplify the Pentium
23508 - * F0 0F bug workaround.
23509 - */
23510 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23511 #endif
23512
23513 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23514 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23515 }
23516
23517 static int __kprobes
23518 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23519 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23520 struct pt_regs *regs, long error_code)
23521 {
23522 #ifdef CONFIG_X86_32
23523 - if (regs->flags & X86_VM_MASK) {
23524 + if (v8086_mode(regs)) {
23525 /*
23526 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23527 * On nmi (interrupt 2), do_trap should not be called.
23528 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23529 return -1;
23530 }
23531 #endif
23532 - if (!user_mode(regs)) {
23533 + if (!user_mode_novm(regs)) {
23534 if (!fixup_exception(regs)) {
23535 tsk->thread.error_code = error_code;
23536 tsk->thread.trap_nr = trapnr;
23537 +
23538 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23539 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23540 + str = "PAX: suspicious stack segment fault";
23541 +#endif
23542 +
23543 die(str, regs, error_code);
23544 }
23545 +
23546 +#ifdef CONFIG_PAX_REFCOUNT
23547 + if (trapnr == 4)
23548 + pax_report_refcount_overflow(regs);
23549 +#endif
23550 +
23551 return 0;
23552 }
23553
23554 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23555 }
23556
23557 static void __kprobes
23558 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23559 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23560 long error_code, siginfo_t *info)
23561 {
23562 struct task_struct *tsk = current;
23563 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23564 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23565 printk_ratelimit()) {
23566 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23567 - tsk->comm, tsk->pid, str,
23568 + tsk->comm, task_pid_nr(tsk), str,
23569 regs->ip, regs->sp, error_code);
23570 print_vma_addr(" in ", regs->ip);
23571 pr_cont("\n");
23572 @@ -266,7 +272,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23573 conditional_sti(regs);
23574
23575 #ifdef CONFIG_X86_32
23576 - if (regs->flags & X86_VM_MASK) {
23577 + if (v8086_mode(regs)) {
23578 local_irq_enable();
23579 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23580 goto exit;
23581 @@ -274,18 +280,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23582 #endif
23583
23584 tsk = current;
23585 - if (!user_mode(regs)) {
23586 + if (!user_mode_novm(regs)) {
23587 if (fixup_exception(regs))
23588 goto exit;
23589
23590 tsk->thread.error_code = error_code;
23591 tsk->thread.trap_nr = X86_TRAP_GP;
23592 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23593 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23594 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23595 +
23596 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23597 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23598 + die("PAX: suspicious general protection fault", regs, error_code);
23599 + else
23600 +#endif
23601 +
23602 die("general protection fault", regs, error_code);
23603 + }
23604 goto exit;
23605 }
23606
23607 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23608 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23609 + struct mm_struct *mm = tsk->mm;
23610 + unsigned long limit;
23611 +
23612 + down_write(&mm->mmap_sem);
23613 + limit = mm->context.user_cs_limit;
23614 + if (limit < TASK_SIZE) {
23615 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23616 + up_write(&mm->mmap_sem);
23617 + return;
23618 + }
23619 + up_write(&mm->mmap_sem);
23620 + }
23621 +#endif
23622 +
23623 tsk->thread.error_code = error_code;
23624 tsk->thread.trap_nr = X86_TRAP_GP;
23625
23626 @@ -440,7 +470,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23627 /* It's safe to allow irq's after DR6 has been saved */
23628 preempt_conditional_sti(regs);
23629
23630 - if (regs->flags & X86_VM_MASK) {
23631 + if (v8086_mode(regs)) {
23632 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23633 X86_TRAP_DB);
23634 preempt_conditional_cli(regs);
23635 @@ -455,7 +485,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23636 * We already checked v86 mode above, so we can check for kernel mode
23637 * by just checking the CPL of CS.
23638 */
23639 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23640 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23641 tsk->thread.debugreg6 &= ~DR_STEP;
23642 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23643 regs->flags &= ~X86_EFLAGS_TF;
23644 @@ -487,7 +517,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23645 return;
23646 conditional_sti(regs);
23647
23648 - if (!user_mode_vm(regs))
23649 + if (!user_mode(regs))
23650 {
23651 if (!fixup_exception(regs)) {
23652 task->thread.error_code = error_code;
23653 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23654 index c71025b..b117501 100644
23655 --- a/arch/x86/kernel/uprobes.c
23656 +++ b/arch/x86/kernel/uprobes.c
23657 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23658 int ret = NOTIFY_DONE;
23659
23660 /* We are only interested in userspace traps */
23661 - if (regs && !user_mode_vm(regs))
23662 + if (regs && !user_mode(regs))
23663 return NOTIFY_DONE;
23664
23665 switch (val) {
23666 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23667 index b9242ba..50c5edd 100644
23668 --- a/arch/x86/kernel/verify_cpu.S
23669 +++ b/arch/x86/kernel/verify_cpu.S
23670 @@ -20,6 +20,7 @@
23671 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23672 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23673 * arch/x86/kernel/head_32.S: processor startup
23674 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23675 *
23676 * verify_cpu, returns the status of longmode and SSE in register %eax.
23677 * 0: Success 1: Failure
23678 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23679 index 1dfe69c..a3df6f6 100644
23680 --- a/arch/x86/kernel/vm86_32.c
23681 +++ b/arch/x86/kernel/vm86_32.c
23682 @@ -43,6 +43,7 @@
23683 #include <linux/ptrace.h>
23684 #include <linux/audit.h>
23685 #include <linux/stddef.h>
23686 +#include <linux/grsecurity.h>
23687
23688 #include <asm/uaccess.h>
23689 #include <asm/io.h>
23690 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23691 do_exit(SIGSEGV);
23692 }
23693
23694 - tss = &per_cpu(init_tss, get_cpu());
23695 + tss = init_tss + get_cpu();
23696 current->thread.sp0 = current->thread.saved_sp0;
23697 current->thread.sysenter_cs = __KERNEL_CS;
23698 load_sp0(tss, &current->thread);
23699 @@ -212,6 +213,13 @@ int sys_vm86old(struct vm86_struct __user *v86, struct pt_regs *regs)
23700 struct task_struct *tsk;
23701 int tmp, ret = -EPERM;
23702
23703 +#ifdef CONFIG_GRKERNSEC_VM86
23704 + if (!capable(CAP_SYS_RAWIO)) {
23705 + gr_handle_vm86();
23706 + goto out;
23707 + }
23708 +#endif
23709 +
23710 tsk = current;
23711 if (tsk->thread.saved_sp0)
23712 goto out;
23713 @@ -242,6 +250,14 @@ int sys_vm86(unsigned long cmd, unsigned long arg, struct pt_regs *regs)
23714 int tmp, ret;
23715 struct vm86plus_struct __user *v86;
23716
23717 +#ifdef CONFIG_GRKERNSEC_VM86
23718 + if (!capable(CAP_SYS_RAWIO)) {
23719 + gr_handle_vm86();
23720 + ret = -EPERM;
23721 + goto out;
23722 + }
23723 +#endif
23724 +
23725 tsk = current;
23726 switch (cmd) {
23727 case VM86_REQUEST_IRQ:
23728 @@ -328,7 +344,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23729 tsk->thread.saved_fs = info->regs32->fs;
23730 tsk->thread.saved_gs = get_user_gs(info->regs32);
23731
23732 - tss = &per_cpu(init_tss, get_cpu());
23733 + tss = init_tss + get_cpu();
23734 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23735 if (cpu_has_sep)
23736 tsk->thread.sysenter_cs = 0;
23737 @@ -535,7 +551,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23738 goto cannot_handle;
23739 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23740 goto cannot_handle;
23741 - intr_ptr = (unsigned long __user *) (i << 2);
23742 + intr_ptr = (__force unsigned long __user *) (i << 2);
23743 if (get_user(segoffs, intr_ptr))
23744 goto cannot_handle;
23745 if ((segoffs >> 16) == BIOSSEG)
23746 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23747 index 22a1530..8fbaaad 100644
23748 --- a/arch/x86/kernel/vmlinux.lds.S
23749 +++ b/arch/x86/kernel/vmlinux.lds.S
23750 @@ -26,6 +26,13 @@
23751 #include <asm/page_types.h>
23752 #include <asm/cache.h>
23753 #include <asm/boot.h>
23754 +#include <asm/segment.h>
23755 +
23756 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23757 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23758 +#else
23759 +#define __KERNEL_TEXT_OFFSET 0
23760 +#endif
23761
23762 #undef i386 /* in case the preprocessor is a 32bit one */
23763
23764 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23765
23766 PHDRS {
23767 text PT_LOAD FLAGS(5); /* R_E */
23768 +#ifdef CONFIG_X86_32
23769 + module PT_LOAD FLAGS(5); /* R_E */
23770 +#endif
23771 +#ifdef CONFIG_XEN
23772 + rodata PT_LOAD FLAGS(5); /* R_E */
23773 +#else
23774 + rodata PT_LOAD FLAGS(4); /* R__ */
23775 +#endif
23776 data PT_LOAD FLAGS(6); /* RW_ */
23777 -#ifdef CONFIG_X86_64
23778 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23779 #ifdef CONFIG_SMP
23780 percpu PT_LOAD FLAGS(6); /* RW_ */
23781 #endif
23782 + text.init PT_LOAD FLAGS(5); /* R_E */
23783 + text.exit PT_LOAD FLAGS(5); /* R_E */
23784 init PT_LOAD FLAGS(7); /* RWE */
23785 -#endif
23786 note PT_NOTE FLAGS(0); /* ___ */
23787 }
23788
23789 SECTIONS
23790 {
23791 #ifdef CONFIG_X86_32
23792 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23793 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23794 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23795 #else
23796 - . = __START_KERNEL;
23797 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23798 + . = __START_KERNEL;
23799 #endif
23800
23801 /* Text and read-only data */
23802 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23803 - _text = .;
23804 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23805 /* bootstrapping code */
23806 +#ifdef CONFIG_X86_32
23807 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23808 +#else
23809 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23810 +#endif
23811 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23812 + _text = .;
23813 HEAD_TEXT
23814 #ifdef CONFIG_X86_32
23815 . = ALIGN(PAGE_SIZE);
23816 @@ -108,13 +128,48 @@ SECTIONS
23817 IRQENTRY_TEXT
23818 *(.fixup)
23819 *(.gnu.warning)
23820 - /* End of text section */
23821 - _etext = .;
23822 } :text = 0x9090
23823
23824 - NOTES :text :note
23825 + . += __KERNEL_TEXT_OFFSET;
23826
23827 - EXCEPTION_TABLE(16) :text = 0x9090
23828 +#ifdef CONFIG_X86_32
23829 + . = ALIGN(PAGE_SIZE);
23830 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23831 +
23832 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_MODULES)
23833 + MODULES_EXEC_VADDR = .;
23834 + BYTE(0)
23835 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23836 + . = ALIGN(HPAGE_SIZE) - 1;
23837 + MODULES_EXEC_END = .;
23838 +#endif
23839 +
23840 + } :module
23841 +#endif
23842 +
23843 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23844 + /* End of text section */
23845 + BYTE(0)
23846 + _etext = . - __KERNEL_TEXT_OFFSET;
23847 + }
23848 +
23849 +#ifdef CONFIG_X86_32
23850 + . = ALIGN(PAGE_SIZE);
23851 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
23852 + *(.idt)
23853 + . = ALIGN(PAGE_SIZE);
23854 + *(.empty_zero_page)
23855 + *(.initial_pg_fixmap)
23856 + *(.initial_pg_pmd)
23857 + *(.initial_page_table)
23858 + *(.swapper_pg_dir)
23859 + } :rodata
23860 +#endif
23861 +
23862 + . = ALIGN(PAGE_SIZE);
23863 + NOTES :rodata :note
23864 +
23865 + EXCEPTION_TABLE(16) :rodata
23866
23867 #if defined(CONFIG_DEBUG_RODATA)
23868 /* .text should occupy whole number of pages */
23869 @@ -126,16 +181,20 @@ SECTIONS
23870
23871 /* Data */
23872 .data : AT(ADDR(.data) - LOAD_OFFSET) {
23873 +
23874 +#ifdef CONFIG_PAX_KERNEXEC
23875 + . = ALIGN(HPAGE_SIZE);
23876 +#else
23877 + . = ALIGN(PAGE_SIZE);
23878 +#endif
23879 +
23880 /* Start of data section */
23881 _sdata = .;
23882
23883 /* init_task */
23884 INIT_TASK_DATA(THREAD_SIZE)
23885
23886 -#ifdef CONFIG_X86_32
23887 - /* 32 bit has nosave before _edata */
23888 NOSAVE_DATA
23889 -#endif
23890
23891 PAGE_ALIGNED_DATA(PAGE_SIZE)
23892
23893 @@ -176,12 +235,19 @@ SECTIONS
23894 #endif /* CONFIG_X86_64 */
23895
23896 /* Init code and data - will be freed after init */
23897 - . = ALIGN(PAGE_SIZE);
23898 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
23899 + BYTE(0)
23900 +
23901 +#ifdef CONFIG_PAX_KERNEXEC
23902 + . = ALIGN(HPAGE_SIZE);
23903 +#else
23904 + . = ALIGN(PAGE_SIZE);
23905 +#endif
23906 +
23907 __init_begin = .; /* paired with __init_end */
23908 - }
23909 + } :init.begin
23910
23911 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
23912 +#ifdef CONFIG_SMP
23913 /*
23914 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
23915 * output PHDR, so the next output section - .init.text - should
23916 @@ -190,12 +256,27 @@ SECTIONS
23917 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
23918 #endif
23919
23920 - INIT_TEXT_SECTION(PAGE_SIZE)
23921 -#ifdef CONFIG_X86_64
23922 - :init
23923 -#endif
23924 + . = ALIGN(PAGE_SIZE);
23925 + init_begin = .;
23926 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
23927 + VMLINUX_SYMBOL(_sinittext) = .;
23928 + INIT_TEXT
23929 + VMLINUX_SYMBOL(_einittext) = .;
23930 + . = ALIGN(PAGE_SIZE);
23931 + } :text.init
23932
23933 - INIT_DATA_SECTION(16)
23934 + /*
23935 + * .exit.text is discard at runtime, not link time, to deal with
23936 + * references from .altinstructions and .eh_frame
23937 + */
23938 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23939 + EXIT_TEXT
23940 + . = ALIGN(16);
23941 + } :text.exit
23942 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
23943 +
23944 + . = ALIGN(PAGE_SIZE);
23945 + INIT_DATA_SECTION(16) :init
23946
23947 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
23948 __x86_cpu_dev_start = .;
23949 @@ -257,19 +338,12 @@ SECTIONS
23950 }
23951
23952 . = ALIGN(8);
23953 - /*
23954 - * .exit.text is discard at runtime, not link time, to deal with
23955 - * references from .altinstructions and .eh_frame
23956 - */
23957 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
23958 - EXIT_TEXT
23959 - }
23960
23961 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
23962 EXIT_DATA
23963 }
23964
23965 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
23966 +#ifndef CONFIG_SMP
23967 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
23968 #endif
23969
23970 @@ -288,16 +362,10 @@ SECTIONS
23971 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
23972 __smp_locks = .;
23973 *(.smp_locks)
23974 - . = ALIGN(PAGE_SIZE);
23975 __smp_locks_end = .;
23976 + . = ALIGN(PAGE_SIZE);
23977 }
23978
23979 -#ifdef CONFIG_X86_64
23980 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
23981 - NOSAVE_DATA
23982 - }
23983 -#endif
23984 -
23985 /* BSS */
23986 . = ALIGN(PAGE_SIZE);
23987 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
23988 @@ -313,6 +381,7 @@ SECTIONS
23989 __brk_base = .;
23990 . += 64 * 1024; /* 64k alignment slop space */
23991 *(.brk_reservation) /* areas brk users have reserved */
23992 + . = ALIGN(HPAGE_SIZE);
23993 __brk_limit = .;
23994 }
23995
23996 @@ -339,13 +408,12 @@ SECTIONS
23997 * for the boot processor.
23998 */
23999 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
24000 -INIT_PER_CPU(gdt_page);
24001 INIT_PER_CPU(irq_stack_union);
24002
24003 /*
24004 * Build-time check on the image size:
24005 */
24006 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
24007 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
24008 "kernel image bigger than KERNEL_IMAGE_SIZE");
24009
24010 #ifdef CONFIG_SMP
24011 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
24012 index 9a907a6..f83f921 100644
24013 --- a/arch/x86/kernel/vsyscall_64.c
24014 +++ b/arch/x86/kernel/vsyscall_64.c
24015 @@ -56,15 +56,13 @@
24016 DEFINE_VVAR(int, vgetcpu_mode);
24017 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
24018
24019 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
24020 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
24021
24022 static int __init vsyscall_setup(char *str)
24023 {
24024 if (str) {
24025 if (!strcmp("emulate", str))
24026 vsyscall_mode = EMULATE;
24027 - else if (!strcmp("native", str))
24028 - vsyscall_mode = NATIVE;
24029 else if (!strcmp("none", str))
24030 vsyscall_mode = NONE;
24031 else
24032 @@ -323,8 +321,7 @@ do_ret:
24033 return true;
24034
24035 sigsegv:
24036 - force_sig(SIGSEGV, current);
24037 - return true;
24038 + do_group_exit(SIGKILL);
24039 }
24040
24041 /*
24042 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
24043 extern char __vvar_page;
24044 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
24045
24046 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
24047 - vsyscall_mode == NATIVE
24048 - ? PAGE_KERNEL_VSYSCALL
24049 - : PAGE_KERNEL_VVAR);
24050 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
24051 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
24052 (unsigned long)VSYSCALL_START);
24053
24054 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
24055 index 1330dd1..d220b99 100644
24056 --- a/arch/x86/kernel/x8664_ksyms_64.c
24057 +++ b/arch/x86/kernel/x8664_ksyms_64.c
24058 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
24059 EXPORT_SYMBOL(copy_user_generic_unrolled);
24060 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
24061 EXPORT_SYMBOL(__copy_user_nocache);
24062 -EXPORT_SYMBOL(_copy_from_user);
24063 -EXPORT_SYMBOL(_copy_to_user);
24064
24065 EXPORT_SYMBOL(copy_page);
24066 EXPORT_SYMBOL(clear_page);
24067 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
24068 index 7a3d075..6cb373d 100644
24069 --- a/arch/x86/kernel/x86_init.c
24070 +++ b/arch/x86/kernel/x86_init.c
24071 @@ -88,7 +88,7 @@ struct x86_init_ops x86_init __initdata = {
24072 },
24073 };
24074
24075 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
24076 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
24077 .early_percpu_clock_init = x86_init_noop,
24078 .setup_percpu_clockev = setup_secondary_APIC_clock,
24079 };
24080 @@ -96,7 +96,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
24081 static void default_nmi_init(void) { };
24082 static int default_i8042_detect(void) { return 1; };
24083
24084 -struct x86_platform_ops x86_platform = {
24085 +struct x86_platform_ops x86_platform __read_only = {
24086 .calibrate_tsc = native_calibrate_tsc,
24087 .get_wallclock = mach_get_cmos_time,
24088 .set_wallclock = mach_set_rtc_mmss,
24089 @@ -110,14 +110,14 @@ struct x86_platform_ops x86_platform = {
24090 };
24091
24092 EXPORT_SYMBOL_GPL(x86_platform);
24093 -struct x86_msi_ops x86_msi = {
24094 +struct x86_msi_ops x86_msi __read_only = {
24095 .setup_msi_irqs = native_setup_msi_irqs,
24096 .teardown_msi_irq = native_teardown_msi_irq,
24097 .teardown_msi_irqs = default_teardown_msi_irqs,
24098 .restore_msi_irqs = default_restore_msi_irqs,
24099 };
24100
24101 -struct x86_io_apic_ops x86_io_apic_ops = {
24102 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
24103 .init = native_io_apic_init_mappings,
24104 .read = native_io_apic_read,
24105 .write = native_io_apic_write,
24106 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
24107 index ada87a3..afea76d 100644
24108 --- a/arch/x86/kernel/xsave.c
24109 +++ b/arch/x86/kernel/xsave.c
24110 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
24111 {
24112 int err;
24113
24114 + buf = (struct xsave_struct __user *)____m(buf);
24115 if (use_xsave())
24116 err = xsave_user(buf);
24117 else if (use_fxsr())
24118 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
24119 */
24120 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
24121 {
24122 + buf = (void __user *)____m(buf);
24123 if (use_xsave()) {
24124 if ((unsigned long)buf % 64 || fx_only) {
24125 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
24126 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
24127 index a20ecb5..d0e2194 100644
24128 --- a/arch/x86/kvm/cpuid.c
24129 +++ b/arch/x86/kvm/cpuid.c
24130 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
24131 struct kvm_cpuid2 *cpuid,
24132 struct kvm_cpuid_entry2 __user *entries)
24133 {
24134 - int r;
24135 + int r, i;
24136
24137 r = -E2BIG;
24138 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
24139 goto out;
24140 r = -EFAULT;
24141 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
24142 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
24143 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
24144 goto out;
24145 + for (i = 0; i < cpuid->nent; ++i) {
24146 + struct kvm_cpuid_entry2 cpuid_entry;
24147 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
24148 + goto out;
24149 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
24150 + }
24151 vcpu->arch.cpuid_nent = cpuid->nent;
24152 kvm_apic_set_version(vcpu);
24153 kvm_x86_ops->cpuid_update(vcpu);
24154 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
24155 struct kvm_cpuid2 *cpuid,
24156 struct kvm_cpuid_entry2 __user *entries)
24157 {
24158 - int r;
24159 + int r, i;
24160
24161 r = -E2BIG;
24162 if (cpuid->nent < vcpu->arch.cpuid_nent)
24163 goto out;
24164 r = -EFAULT;
24165 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
24166 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24167 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24168 goto out;
24169 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
24170 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
24171 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
24172 + goto out;
24173 + }
24174 return 0;
24175
24176 out:
24177 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
24178 index a27e763..54bfe43 100644
24179 --- a/arch/x86/kvm/emulate.c
24180 +++ b/arch/x86/kvm/emulate.c
24181 @@ -292,6 +292,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24182
24183 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
24184 do { \
24185 + unsigned long _tmp; \
24186 __asm__ __volatile__ ( \
24187 _PRE_EFLAGS("0", "4", "2") \
24188 _op _suffix " %"_x"3,%1; " \
24189 @@ -306,8 +307,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24190 /* Raw emulation: instruction has two explicit operands. */
24191 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
24192 do { \
24193 - unsigned long _tmp; \
24194 - \
24195 switch ((ctxt)->dst.bytes) { \
24196 case 2: \
24197 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
24198 @@ -323,7 +322,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24199
24200 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
24201 do { \
24202 - unsigned long _tmp; \
24203 switch ((ctxt)->dst.bytes) { \
24204 case 1: \
24205 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
24206 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
24207 index 9392f52..0e56d77 100644
24208 --- a/arch/x86/kvm/lapic.c
24209 +++ b/arch/x86/kvm/lapic.c
24210 @@ -55,7 +55,7 @@
24211 #define APIC_BUS_CYCLE_NS 1
24212
24213 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
24214 -#define apic_debug(fmt, arg...)
24215 +#define apic_debug(fmt, arg...) do {} while (0)
24216
24217 #define APIC_LVT_NUM 6
24218 /* 14 is the version for Xeon and Pentium 8.4.8*/
24219 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
24220 index 891eb6d..e027900 100644
24221 --- a/arch/x86/kvm/paging_tmpl.h
24222 +++ b/arch/x86/kvm/paging_tmpl.h
24223 @@ -208,7 +208,7 @@ retry_walk:
24224 if (unlikely(kvm_is_error_hva(host_addr)))
24225 goto error;
24226
24227 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
24228 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
24229 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
24230 goto error;
24231 walker->ptep_user[walker->level - 1] = ptep_user;
24232 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
24233 index d29d3cd..ec9d522 100644
24234 --- a/arch/x86/kvm/svm.c
24235 +++ b/arch/x86/kvm/svm.c
24236 @@ -3507,7 +3507,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
24237 int cpu = raw_smp_processor_id();
24238
24239 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
24240 +
24241 + pax_open_kernel();
24242 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
24243 + pax_close_kernel();
24244 +
24245 load_TR_desc();
24246 }
24247
24248 @@ -3881,6 +3885,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
24249 #endif
24250 #endif
24251
24252 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
24253 + __set_fs(current_thread_info()->addr_limit);
24254 +#endif
24255 +
24256 reload_tss(vcpu);
24257
24258 local_irq_disable();
24259 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
24260 index 9120ae1..238abc0 100644
24261 --- a/arch/x86/kvm/vmx.c
24262 +++ b/arch/x86/kvm/vmx.c
24263 @@ -1370,7 +1370,11 @@ static void reload_tss(void)
24264 struct desc_struct *descs;
24265
24266 descs = (void *)gdt->address;
24267 +
24268 + pax_open_kernel();
24269 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
24270 + pax_close_kernel();
24271 +
24272 load_TR_desc();
24273 }
24274
24275 @@ -1594,6 +1598,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
24276 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
24277 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
24278
24279 +#ifdef CONFIG_PAX_PER_CPU_PGD
24280 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24281 +#endif
24282 +
24283 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
24284 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
24285 vmx->loaded_vmcs->cpu = cpu;
24286 @@ -2738,8 +2746,11 @@ static __init int hardware_setup(void)
24287 if (!cpu_has_vmx_flexpriority())
24288 flexpriority_enabled = 0;
24289
24290 - if (!cpu_has_vmx_tpr_shadow())
24291 - kvm_x86_ops->update_cr8_intercept = NULL;
24292 + if (!cpu_has_vmx_tpr_shadow()) {
24293 + pax_open_kernel();
24294 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24295 + pax_close_kernel();
24296 + }
24297
24298 if (enable_ept && !cpu_has_vmx_ept_2m_page())
24299 kvm_disable_largepages();
24300 @@ -3782,7 +3793,10 @@ static void vmx_set_constant_host_state(void)
24301
24302 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
24303 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
24304 +
24305 +#ifndef CONFIG_PAX_PER_CPU_PGD
24306 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24307 +#endif
24308
24309 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
24310 #ifdef CONFIG_X86_64
24311 @@ -3803,7 +3817,7 @@ static void vmx_set_constant_host_state(void)
24312 native_store_idt(&dt);
24313 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
24314
24315 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
24316 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
24317
24318 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
24319 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
24320 @@ -6355,6 +6369,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24321 "jmp 2f \n\t"
24322 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
24323 "2: "
24324 +
24325 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24326 + "ljmp %[cs],$3f\n\t"
24327 + "3: "
24328 +#endif
24329 +
24330 /* Save guest registers, load host registers, keep flags */
24331 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
24332 "pop %0 \n\t"
24333 @@ -6407,6 +6427,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24334 #endif
24335 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
24336 [wordsize]"i"(sizeof(ulong))
24337 +
24338 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24339 + ,[cs]"i"(__KERNEL_CS)
24340 +#endif
24341 +
24342 : "cc", "memory"
24343 #ifdef CONFIG_X86_64
24344 , "rax", "rbx", "rdi", "rsi"
24345 @@ -6420,7 +6445,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24346 if (debugctlmsr)
24347 update_debugctlmsr(debugctlmsr);
24348
24349 -#ifndef CONFIG_X86_64
24350 +#ifdef CONFIG_X86_32
24351 /*
24352 * The sysexit path does not restore ds/es, so we must set them to
24353 * a reasonable value ourselves.
24354 @@ -6429,8 +6454,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24355 * may be executed in interrupt context, which saves and restore segments
24356 * around it, nullifying its effect.
24357 */
24358 - loadsegment(ds, __USER_DS);
24359 - loadsegment(es, __USER_DS);
24360 + loadsegment(ds, __KERNEL_DS);
24361 + loadsegment(es, __KERNEL_DS);
24362 + loadsegment(ss, __KERNEL_DS);
24363 +
24364 +#ifdef CONFIG_PAX_KERNEXEC
24365 + loadsegment(fs, __KERNEL_PERCPU);
24366 +#endif
24367 +
24368 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24369 + __set_fs(current_thread_info()->addr_limit);
24370 +#endif
24371 +
24372 #endif
24373
24374 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
24375 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
24376 index c243b81..b692af3 100644
24377 --- a/arch/x86/kvm/x86.c
24378 +++ b/arch/x86/kvm/x86.c
24379 @@ -1408,10 +1408,9 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24380 unsigned long flags, this_tsc_khz;
24381 struct kvm_vcpu_arch *vcpu = &v->arch;
24382 struct kvm_arch *ka = &v->kvm->arch;
24383 - void *shared_kaddr;
24384 s64 kernel_ns, max_kernel_ns;
24385 u64 tsc_timestamp, host_tsc;
24386 - struct pvclock_vcpu_time_info *guest_hv_clock;
24387 + struct pvclock_vcpu_time_info guest_hv_clock;
24388 u8 pvclock_flags;
24389 bool use_master_clock;
24390
24391 @@ -1465,7 +1464,7 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24392
24393 local_irq_restore(flags);
24394
24395 - if (!vcpu->time_page)
24396 + if (!vcpu->pv_time_enabled)
24397 return 0;
24398
24399 /*
24400 @@ -1527,12 +1526,12 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24401 */
24402 vcpu->hv_clock.version += 2;
24403
24404 - shared_kaddr = kmap_atomic(vcpu->time_page);
24405 -
24406 - guest_hv_clock = shared_kaddr + vcpu->time_offset;
24407 + if (unlikely(kvm_read_guest_cached(v->kvm, &vcpu->pv_time,
24408 + &guest_hv_clock, sizeof(guest_hv_clock))))
24409 + return 0;
24410
24411 /* retain PVCLOCK_GUEST_STOPPED if set in guest copy */
24412 - pvclock_flags = (guest_hv_clock->flags & PVCLOCK_GUEST_STOPPED);
24413 + pvclock_flags = (guest_hv_clock.flags & PVCLOCK_GUEST_STOPPED);
24414
24415 if (vcpu->pvclock_set_guest_stopped_request) {
24416 pvclock_flags |= PVCLOCK_GUEST_STOPPED;
24417 @@ -1545,12 +1544,9 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24418
24419 vcpu->hv_clock.flags = pvclock_flags;
24420
24421 - memcpy(shared_kaddr + vcpu->time_offset, &vcpu->hv_clock,
24422 - sizeof(vcpu->hv_clock));
24423 -
24424 - kunmap_atomic(shared_kaddr);
24425 -
24426 - mark_page_dirty(v->kvm, vcpu->time >> PAGE_SHIFT);
24427 + kvm_write_guest_cached(v->kvm, &vcpu->pv_time,
24428 + &vcpu->hv_clock,
24429 + sizeof(vcpu->hv_clock));
24430 return 0;
24431 }
24432
24433 @@ -1692,8 +1688,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
24434 {
24435 struct kvm *kvm = vcpu->kvm;
24436 int lm = is_long_mode(vcpu);
24437 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24438 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24439 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24440 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24441 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
24442 : kvm->arch.xen_hvm_config.blob_size_32;
24443 u32 page_num = data & ~PAGE_MASK;
24444 @@ -1839,10 +1835,7 @@ static int kvm_pv_enable_async_pf(struct kvm_vcpu *vcpu, u64 data)
24445
24446 static void kvmclock_reset(struct kvm_vcpu *vcpu)
24447 {
24448 - if (vcpu->arch.time_page) {
24449 - kvm_release_page_dirty(vcpu->arch.time_page);
24450 - vcpu->arch.time_page = NULL;
24451 - }
24452 + vcpu->arch.pv_time_enabled = false;
24453 }
24454
24455 static void accumulate_steal_time(struct kvm_vcpu *vcpu)
24456 @@ -1948,6 +1941,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
24457 break;
24458 case MSR_KVM_SYSTEM_TIME_NEW:
24459 case MSR_KVM_SYSTEM_TIME: {
24460 + u64 gpa_offset;
24461 kvmclock_reset(vcpu);
24462
24463 vcpu->arch.time = data;
24464 @@ -1957,14 +1951,17 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
24465 if (!(data & 1))
24466 break;
24467
24468 - /* ...but clean it before doing the actual write */
24469 - vcpu->arch.time_offset = data & ~(PAGE_MASK | 1);
24470 + gpa_offset = data & ~(PAGE_MASK | 1);
24471
24472 - vcpu->arch.time_page =
24473 - gfn_to_page(vcpu->kvm, data >> PAGE_SHIFT);
24474 + /* Check that the address is 32-byte aligned. */
24475 + if (gpa_offset & (sizeof(struct pvclock_vcpu_time_info) - 1))
24476 + break;
24477
24478 - if (is_error_page(vcpu->arch.time_page))
24479 - vcpu->arch.time_page = NULL;
24480 + if (kvm_gfn_to_hva_cache_init(vcpu->kvm,
24481 + &vcpu->arch.pv_time, data & ~1ULL))
24482 + vcpu->arch.pv_time_enabled = false;
24483 + else
24484 + vcpu->arch.pv_time_enabled = true;
24485
24486 break;
24487 }
24488 @@ -2571,6 +2568,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
24489 if (n < msr_list.nmsrs)
24490 goto out;
24491 r = -EFAULT;
24492 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24493 + goto out;
24494 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24495 num_msrs_to_save * sizeof(u32)))
24496 goto out;
24497 @@ -2700,7 +2699,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
24498 static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
24499 struct kvm_interrupt *irq)
24500 {
24501 - if (irq->irq < 0 || irq->irq >= KVM_NR_INTERRUPTS)
24502 + if (irq->irq >= KVM_NR_INTERRUPTS)
24503 return -EINVAL;
24504 if (irqchip_in_kernel(vcpu->kvm))
24505 return -ENXIO;
24506 @@ -2967,7 +2966,7 @@ static int kvm_vcpu_ioctl_x86_set_xcrs(struct kvm_vcpu *vcpu,
24507 */
24508 static int kvm_set_guest_paused(struct kvm_vcpu *vcpu)
24509 {
24510 - if (!vcpu->arch.time_page)
24511 + if (!vcpu->arch.pv_time_enabled)
24512 return -EINVAL;
24513 vcpu->arch.pvclock_set_guest_stopped_request = true;
24514 kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
24515 @@ -5213,7 +5212,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24516 };
24517 #endif
24518
24519 -int kvm_arch_init(void *opaque)
24520 +int kvm_arch_init(const void *opaque)
24521 {
24522 int r;
24523 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24524 @@ -6661,6 +6660,7 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
24525 goto fail_free_wbinvd_dirty_mask;
24526
24527 vcpu->arch.ia32_tsc_adjust_msr = 0x0;
24528 + vcpu->arch.pv_time_enabled = false;
24529 kvm_async_pf_hash_reset(vcpu);
24530 kvm_pmu_init(vcpu);
24531
24532 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24533 index df4176c..23ce092 100644
24534 --- a/arch/x86/lguest/boot.c
24535 +++ b/arch/x86/lguest/boot.c
24536 @@ -1200,9 +1200,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24537 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24538 * Launcher to reboot us.
24539 */
24540 -static void lguest_restart(char *reason)
24541 +static __noreturn void lguest_restart(char *reason)
24542 {
24543 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24544 + BUG();
24545 }
24546
24547 /*G:050
24548 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24549 index 00933d5..3a64af9 100644
24550 --- a/arch/x86/lib/atomic64_386_32.S
24551 +++ b/arch/x86/lib/atomic64_386_32.S
24552 @@ -48,6 +48,10 @@ BEGIN(read)
24553 movl (v), %eax
24554 movl 4(v), %edx
24555 RET_ENDP
24556 +BEGIN(read_unchecked)
24557 + movl (v), %eax
24558 + movl 4(v), %edx
24559 +RET_ENDP
24560 #undef v
24561
24562 #define v %esi
24563 @@ -55,6 +59,10 @@ BEGIN(set)
24564 movl %ebx, (v)
24565 movl %ecx, 4(v)
24566 RET_ENDP
24567 +BEGIN(set_unchecked)
24568 + movl %ebx, (v)
24569 + movl %ecx, 4(v)
24570 +RET_ENDP
24571 #undef v
24572
24573 #define v %esi
24574 @@ -70,6 +78,20 @@ RET_ENDP
24575 BEGIN(add)
24576 addl %eax, (v)
24577 adcl %edx, 4(v)
24578 +
24579 +#ifdef CONFIG_PAX_REFCOUNT
24580 + jno 0f
24581 + subl %eax, (v)
24582 + sbbl %edx, 4(v)
24583 + int $4
24584 +0:
24585 + _ASM_EXTABLE(0b, 0b)
24586 +#endif
24587 +
24588 +RET_ENDP
24589 +BEGIN(add_unchecked)
24590 + addl %eax, (v)
24591 + adcl %edx, 4(v)
24592 RET_ENDP
24593 #undef v
24594
24595 @@ -77,6 +99,24 @@ RET_ENDP
24596 BEGIN(add_return)
24597 addl (v), %eax
24598 adcl 4(v), %edx
24599 +
24600 +#ifdef CONFIG_PAX_REFCOUNT
24601 + into
24602 +1234:
24603 + _ASM_EXTABLE(1234b, 2f)
24604 +#endif
24605 +
24606 + movl %eax, (v)
24607 + movl %edx, 4(v)
24608 +
24609 +#ifdef CONFIG_PAX_REFCOUNT
24610 +2:
24611 +#endif
24612 +
24613 +RET_ENDP
24614 +BEGIN(add_return_unchecked)
24615 + addl (v), %eax
24616 + adcl 4(v), %edx
24617 movl %eax, (v)
24618 movl %edx, 4(v)
24619 RET_ENDP
24620 @@ -86,6 +126,20 @@ RET_ENDP
24621 BEGIN(sub)
24622 subl %eax, (v)
24623 sbbl %edx, 4(v)
24624 +
24625 +#ifdef CONFIG_PAX_REFCOUNT
24626 + jno 0f
24627 + addl %eax, (v)
24628 + adcl %edx, 4(v)
24629 + int $4
24630 +0:
24631 + _ASM_EXTABLE(0b, 0b)
24632 +#endif
24633 +
24634 +RET_ENDP
24635 +BEGIN(sub_unchecked)
24636 + subl %eax, (v)
24637 + sbbl %edx, 4(v)
24638 RET_ENDP
24639 #undef v
24640
24641 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24642 sbbl $0, %edx
24643 addl (v), %eax
24644 adcl 4(v), %edx
24645 +
24646 +#ifdef CONFIG_PAX_REFCOUNT
24647 + into
24648 +1234:
24649 + _ASM_EXTABLE(1234b, 2f)
24650 +#endif
24651 +
24652 + movl %eax, (v)
24653 + movl %edx, 4(v)
24654 +
24655 +#ifdef CONFIG_PAX_REFCOUNT
24656 +2:
24657 +#endif
24658 +
24659 +RET_ENDP
24660 +BEGIN(sub_return_unchecked)
24661 + negl %edx
24662 + negl %eax
24663 + sbbl $0, %edx
24664 + addl (v), %eax
24665 + adcl 4(v), %edx
24666 movl %eax, (v)
24667 movl %edx, 4(v)
24668 RET_ENDP
24669 @@ -105,6 +180,20 @@ RET_ENDP
24670 BEGIN(inc)
24671 addl $1, (v)
24672 adcl $0, 4(v)
24673 +
24674 +#ifdef CONFIG_PAX_REFCOUNT
24675 + jno 0f
24676 + subl $1, (v)
24677 + sbbl $0, 4(v)
24678 + int $4
24679 +0:
24680 + _ASM_EXTABLE(0b, 0b)
24681 +#endif
24682 +
24683 +RET_ENDP
24684 +BEGIN(inc_unchecked)
24685 + addl $1, (v)
24686 + adcl $0, 4(v)
24687 RET_ENDP
24688 #undef v
24689
24690 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24691 movl 4(v), %edx
24692 addl $1, %eax
24693 adcl $0, %edx
24694 +
24695 +#ifdef CONFIG_PAX_REFCOUNT
24696 + into
24697 +1234:
24698 + _ASM_EXTABLE(1234b, 2f)
24699 +#endif
24700 +
24701 + movl %eax, (v)
24702 + movl %edx, 4(v)
24703 +
24704 +#ifdef CONFIG_PAX_REFCOUNT
24705 +2:
24706 +#endif
24707 +
24708 +RET_ENDP
24709 +BEGIN(inc_return_unchecked)
24710 + movl (v), %eax
24711 + movl 4(v), %edx
24712 + addl $1, %eax
24713 + adcl $0, %edx
24714 movl %eax, (v)
24715 movl %edx, 4(v)
24716 RET_ENDP
24717 @@ -123,6 +232,20 @@ RET_ENDP
24718 BEGIN(dec)
24719 subl $1, (v)
24720 sbbl $0, 4(v)
24721 +
24722 +#ifdef CONFIG_PAX_REFCOUNT
24723 + jno 0f
24724 + addl $1, (v)
24725 + adcl $0, 4(v)
24726 + int $4
24727 +0:
24728 + _ASM_EXTABLE(0b, 0b)
24729 +#endif
24730 +
24731 +RET_ENDP
24732 +BEGIN(dec_unchecked)
24733 + subl $1, (v)
24734 + sbbl $0, 4(v)
24735 RET_ENDP
24736 #undef v
24737
24738 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24739 movl 4(v), %edx
24740 subl $1, %eax
24741 sbbl $0, %edx
24742 +
24743 +#ifdef CONFIG_PAX_REFCOUNT
24744 + into
24745 +1234:
24746 + _ASM_EXTABLE(1234b, 2f)
24747 +#endif
24748 +
24749 + movl %eax, (v)
24750 + movl %edx, 4(v)
24751 +
24752 +#ifdef CONFIG_PAX_REFCOUNT
24753 +2:
24754 +#endif
24755 +
24756 +RET_ENDP
24757 +BEGIN(dec_return_unchecked)
24758 + movl (v), %eax
24759 + movl 4(v), %edx
24760 + subl $1, %eax
24761 + sbbl $0, %edx
24762 movl %eax, (v)
24763 movl %edx, 4(v)
24764 RET_ENDP
24765 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24766 adcl %edx, %edi
24767 addl (v), %eax
24768 adcl 4(v), %edx
24769 +
24770 +#ifdef CONFIG_PAX_REFCOUNT
24771 + into
24772 +1234:
24773 + _ASM_EXTABLE(1234b, 2f)
24774 +#endif
24775 +
24776 cmpl %eax, %ecx
24777 je 3f
24778 1:
24779 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24780 1:
24781 addl $1, %eax
24782 adcl $0, %edx
24783 +
24784 +#ifdef CONFIG_PAX_REFCOUNT
24785 + into
24786 +1234:
24787 + _ASM_EXTABLE(1234b, 2f)
24788 +#endif
24789 +
24790 movl %eax, (v)
24791 movl %edx, 4(v)
24792 movl $1, %eax
24793 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24794 movl 4(v), %edx
24795 subl $1, %eax
24796 sbbl $0, %edx
24797 +
24798 +#ifdef CONFIG_PAX_REFCOUNT
24799 + into
24800 +1234:
24801 + _ASM_EXTABLE(1234b, 1f)
24802 +#endif
24803 +
24804 js 1f
24805 movl %eax, (v)
24806 movl %edx, 4(v)
24807 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24808 index f5cc9eb..51fa319 100644
24809 --- a/arch/x86/lib/atomic64_cx8_32.S
24810 +++ b/arch/x86/lib/atomic64_cx8_32.S
24811 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24812 CFI_STARTPROC
24813
24814 read64 %ecx
24815 + pax_force_retaddr
24816 ret
24817 CFI_ENDPROC
24818 ENDPROC(atomic64_read_cx8)
24819
24820 +ENTRY(atomic64_read_unchecked_cx8)
24821 + CFI_STARTPROC
24822 +
24823 + read64 %ecx
24824 + pax_force_retaddr
24825 + ret
24826 + CFI_ENDPROC
24827 +ENDPROC(atomic64_read_unchecked_cx8)
24828 +
24829 ENTRY(atomic64_set_cx8)
24830 CFI_STARTPROC
24831
24832 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24833 cmpxchg8b (%esi)
24834 jne 1b
24835
24836 + pax_force_retaddr
24837 ret
24838 CFI_ENDPROC
24839 ENDPROC(atomic64_set_cx8)
24840
24841 +ENTRY(atomic64_set_unchecked_cx8)
24842 + CFI_STARTPROC
24843 +
24844 +1:
24845 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24846 + * are atomic on 586 and newer */
24847 + cmpxchg8b (%esi)
24848 + jne 1b
24849 +
24850 + pax_force_retaddr
24851 + ret
24852 + CFI_ENDPROC
24853 +ENDPROC(atomic64_set_unchecked_cx8)
24854 +
24855 ENTRY(atomic64_xchg_cx8)
24856 CFI_STARTPROC
24857
24858 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24859 cmpxchg8b (%esi)
24860 jne 1b
24861
24862 + pax_force_retaddr
24863 ret
24864 CFI_ENDPROC
24865 ENDPROC(atomic64_xchg_cx8)
24866
24867 -.macro addsub_return func ins insc
24868 -ENTRY(atomic64_\func\()_return_cx8)
24869 +.macro addsub_return func ins insc unchecked=""
24870 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24871 CFI_STARTPROC
24872 SAVE ebp
24873 SAVE ebx
24874 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24875 movl %edx, %ecx
24876 \ins\()l %esi, %ebx
24877 \insc\()l %edi, %ecx
24878 +
24879 +.ifb \unchecked
24880 +#ifdef CONFIG_PAX_REFCOUNT
24881 + into
24882 +2:
24883 + _ASM_EXTABLE(2b, 3f)
24884 +#endif
24885 +.endif
24886 +
24887 LOCK_PREFIX
24888 cmpxchg8b (%ebp)
24889 jne 1b
24890 -
24891 -10:
24892 movl %ebx, %eax
24893 movl %ecx, %edx
24894 +
24895 +.ifb \unchecked
24896 +#ifdef CONFIG_PAX_REFCOUNT
24897 +3:
24898 +#endif
24899 +.endif
24900 +
24901 RESTORE edi
24902 RESTORE esi
24903 RESTORE ebx
24904 RESTORE ebp
24905 + pax_force_retaddr
24906 ret
24907 CFI_ENDPROC
24908 -ENDPROC(atomic64_\func\()_return_cx8)
24909 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24910 .endm
24911
24912 addsub_return add add adc
24913 addsub_return sub sub sbb
24914 +addsub_return add add adc _unchecked
24915 +addsub_return sub sub sbb _unchecked
24916
24917 -.macro incdec_return func ins insc
24918 -ENTRY(atomic64_\func\()_return_cx8)
24919 +.macro incdec_return func ins insc unchecked=""
24920 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24921 CFI_STARTPROC
24922 SAVE ebx
24923
24924 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24925 movl %edx, %ecx
24926 \ins\()l $1, %ebx
24927 \insc\()l $0, %ecx
24928 +
24929 +.ifb \unchecked
24930 +#ifdef CONFIG_PAX_REFCOUNT
24931 + into
24932 +2:
24933 + _ASM_EXTABLE(2b, 3f)
24934 +#endif
24935 +.endif
24936 +
24937 LOCK_PREFIX
24938 cmpxchg8b (%esi)
24939 jne 1b
24940
24941 -10:
24942 movl %ebx, %eax
24943 movl %ecx, %edx
24944 +
24945 +.ifb \unchecked
24946 +#ifdef CONFIG_PAX_REFCOUNT
24947 +3:
24948 +#endif
24949 +.endif
24950 +
24951 RESTORE ebx
24952 + pax_force_retaddr
24953 ret
24954 CFI_ENDPROC
24955 -ENDPROC(atomic64_\func\()_return_cx8)
24956 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24957 .endm
24958
24959 incdec_return inc add adc
24960 incdec_return dec sub sbb
24961 +incdec_return inc add adc _unchecked
24962 +incdec_return dec sub sbb _unchecked
24963
24964 ENTRY(atomic64_dec_if_positive_cx8)
24965 CFI_STARTPROC
24966 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
24967 movl %edx, %ecx
24968 subl $1, %ebx
24969 sbb $0, %ecx
24970 +
24971 +#ifdef CONFIG_PAX_REFCOUNT
24972 + into
24973 +1234:
24974 + _ASM_EXTABLE(1234b, 2f)
24975 +#endif
24976 +
24977 js 2f
24978 LOCK_PREFIX
24979 cmpxchg8b (%esi)
24980 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
24981 movl %ebx, %eax
24982 movl %ecx, %edx
24983 RESTORE ebx
24984 + pax_force_retaddr
24985 ret
24986 CFI_ENDPROC
24987 ENDPROC(atomic64_dec_if_positive_cx8)
24988 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
24989 movl %edx, %ecx
24990 addl %ebp, %ebx
24991 adcl %edi, %ecx
24992 +
24993 +#ifdef CONFIG_PAX_REFCOUNT
24994 + into
24995 +1234:
24996 + _ASM_EXTABLE(1234b, 3f)
24997 +#endif
24998 +
24999 LOCK_PREFIX
25000 cmpxchg8b (%esi)
25001 jne 1b
25002 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
25003 CFI_ADJUST_CFA_OFFSET -8
25004 RESTORE ebx
25005 RESTORE ebp
25006 + pax_force_retaddr
25007 ret
25008 4:
25009 cmpl %edx, 4(%esp)
25010 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
25011 xorl %ecx, %ecx
25012 addl $1, %ebx
25013 adcl %edx, %ecx
25014 +
25015 +#ifdef CONFIG_PAX_REFCOUNT
25016 + into
25017 +1234:
25018 + _ASM_EXTABLE(1234b, 3f)
25019 +#endif
25020 +
25021 LOCK_PREFIX
25022 cmpxchg8b (%esi)
25023 jne 1b
25024 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
25025 movl $1, %eax
25026 3:
25027 RESTORE ebx
25028 + pax_force_retaddr
25029 ret
25030 CFI_ENDPROC
25031 ENDPROC(atomic64_inc_not_zero_cx8)
25032 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
25033 index 2af5df3..62b1a5a 100644
25034 --- a/arch/x86/lib/checksum_32.S
25035 +++ b/arch/x86/lib/checksum_32.S
25036 @@ -29,7 +29,8 @@
25037 #include <asm/dwarf2.h>
25038 #include <asm/errno.h>
25039 #include <asm/asm.h>
25040 -
25041 +#include <asm/segment.h>
25042 +
25043 /*
25044 * computes a partial checksum, e.g. for TCP/UDP fragments
25045 */
25046 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
25047
25048 #define ARGBASE 16
25049 #define FP 12
25050 -
25051 -ENTRY(csum_partial_copy_generic)
25052 +
25053 +ENTRY(csum_partial_copy_generic_to_user)
25054 CFI_STARTPROC
25055 +
25056 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25057 + pushl_cfi %gs
25058 + popl_cfi %es
25059 + jmp csum_partial_copy_generic
25060 +#endif
25061 +
25062 +ENTRY(csum_partial_copy_generic_from_user)
25063 +
25064 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25065 + pushl_cfi %gs
25066 + popl_cfi %ds
25067 +#endif
25068 +
25069 +ENTRY(csum_partial_copy_generic)
25070 subl $4,%esp
25071 CFI_ADJUST_CFA_OFFSET 4
25072 pushl_cfi %edi
25073 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
25074 jmp 4f
25075 SRC(1: movw (%esi), %bx )
25076 addl $2, %esi
25077 -DST( movw %bx, (%edi) )
25078 +DST( movw %bx, %es:(%edi) )
25079 addl $2, %edi
25080 addw %bx, %ax
25081 adcl $0, %eax
25082 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
25083 SRC(1: movl (%esi), %ebx )
25084 SRC( movl 4(%esi), %edx )
25085 adcl %ebx, %eax
25086 -DST( movl %ebx, (%edi) )
25087 +DST( movl %ebx, %es:(%edi) )
25088 adcl %edx, %eax
25089 -DST( movl %edx, 4(%edi) )
25090 +DST( movl %edx, %es:4(%edi) )
25091
25092 SRC( movl 8(%esi), %ebx )
25093 SRC( movl 12(%esi), %edx )
25094 adcl %ebx, %eax
25095 -DST( movl %ebx, 8(%edi) )
25096 +DST( movl %ebx, %es:8(%edi) )
25097 adcl %edx, %eax
25098 -DST( movl %edx, 12(%edi) )
25099 +DST( movl %edx, %es:12(%edi) )
25100
25101 SRC( movl 16(%esi), %ebx )
25102 SRC( movl 20(%esi), %edx )
25103 adcl %ebx, %eax
25104 -DST( movl %ebx, 16(%edi) )
25105 +DST( movl %ebx, %es:16(%edi) )
25106 adcl %edx, %eax
25107 -DST( movl %edx, 20(%edi) )
25108 +DST( movl %edx, %es:20(%edi) )
25109
25110 SRC( movl 24(%esi), %ebx )
25111 SRC( movl 28(%esi), %edx )
25112 adcl %ebx, %eax
25113 -DST( movl %ebx, 24(%edi) )
25114 +DST( movl %ebx, %es:24(%edi) )
25115 adcl %edx, %eax
25116 -DST( movl %edx, 28(%edi) )
25117 +DST( movl %edx, %es:28(%edi) )
25118
25119 lea 32(%esi), %esi
25120 lea 32(%edi), %edi
25121 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
25122 shrl $2, %edx # This clears CF
25123 SRC(3: movl (%esi), %ebx )
25124 adcl %ebx, %eax
25125 -DST( movl %ebx, (%edi) )
25126 +DST( movl %ebx, %es:(%edi) )
25127 lea 4(%esi), %esi
25128 lea 4(%edi), %edi
25129 dec %edx
25130 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
25131 jb 5f
25132 SRC( movw (%esi), %cx )
25133 leal 2(%esi), %esi
25134 -DST( movw %cx, (%edi) )
25135 +DST( movw %cx, %es:(%edi) )
25136 leal 2(%edi), %edi
25137 je 6f
25138 shll $16,%ecx
25139 SRC(5: movb (%esi), %cl )
25140 -DST( movb %cl, (%edi) )
25141 +DST( movb %cl, %es:(%edi) )
25142 6: addl %ecx, %eax
25143 adcl $0, %eax
25144 7:
25145 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
25146
25147 6001:
25148 movl ARGBASE+20(%esp), %ebx # src_err_ptr
25149 - movl $-EFAULT, (%ebx)
25150 + movl $-EFAULT, %ss:(%ebx)
25151
25152 # zero the complete destination - computing the rest
25153 # is too much work
25154 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
25155
25156 6002:
25157 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
25158 - movl $-EFAULT,(%ebx)
25159 + movl $-EFAULT,%ss:(%ebx)
25160 jmp 5000b
25161
25162 .previous
25163
25164 + pushl_cfi %ss
25165 + popl_cfi %ds
25166 + pushl_cfi %ss
25167 + popl_cfi %es
25168 popl_cfi %ebx
25169 CFI_RESTORE ebx
25170 popl_cfi %esi
25171 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
25172 popl_cfi %ecx # equivalent to addl $4,%esp
25173 ret
25174 CFI_ENDPROC
25175 -ENDPROC(csum_partial_copy_generic)
25176 +ENDPROC(csum_partial_copy_generic_to_user)
25177
25178 #else
25179
25180 /* Version for PentiumII/PPro */
25181
25182 #define ROUND1(x) \
25183 + nop; nop; nop; \
25184 SRC(movl x(%esi), %ebx ) ; \
25185 addl %ebx, %eax ; \
25186 - DST(movl %ebx, x(%edi) ) ;
25187 + DST(movl %ebx, %es:x(%edi)) ;
25188
25189 #define ROUND(x) \
25190 + nop; nop; nop; \
25191 SRC(movl x(%esi), %ebx ) ; \
25192 adcl %ebx, %eax ; \
25193 - DST(movl %ebx, x(%edi) ) ;
25194 + DST(movl %ebx, %es:x(%edi)) ;
25195
25196 #define ARGBASE 12
25197 -
25198 -ENTRY(csum_partial_copy_generic)
25199 +
25200 +ENTRY(csum_partial_copy_generic_to_user)
25201 CFI_STARTPROC
25202 +
25203 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25204 + pushl_cfi %gs
25205 + popl_cfi %es
25206 + jmp csum_partial_copy_generic
25207 +#endif
25208 +
25209 +ENTRY(csum_partial_copy_generic_from_user)
25210 +
25211 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25212 + pushl_cfi %gs
25213 + popl_cfi %ds
25214 +#endif
25215 +
25216 +ENTRY(csum_partial_copy_generic)
25217 pushl_cfi %ebx
25218 CFI_REL_OFFSET ebx, 0
25219 pushl_cfi %edi
25220 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
25221 subl %ebx, %edi
25222 lea -1(%esi),%edx
25223 andl $-32,%edx
25224 - lea 3f(%ebx,%ebx), %ebx
25225 + lea 3f(%ebx,%ebx,2), %ebx
25226 testl %esi, %esi
25227 jmp *%ebx
25228 1: addl $64,%esi
25229 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
25230 jb 5f
25231 SRC( movw (%esi), %dx )
25232 leal 2(%esi), %esi
25233 -DST( movw %dx, (%edi) )
25234 +DST( movw %dx, %es:(%edi) )
25235 leal 2(%edi), %edi
25236 je 6f
25237 shll $16,%edx
25238 5:
25239 SRC( movb (%esi), %dl )
25240 -DST( movb %dl, (%edi) )
25241 +DST( movb %dl, %es:(%edi) )
25242 6: addl %edx, %eax
25243 adcl $0, %eax
25244 7:
25245 .section .fixup, "ax"
25246 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
25247 - movl $-EFAULT, (%ebx)
25248 + movl $-EFAULT, %ss:(%ebx)
25249 # zero the complete destination (computing the rest is too much work)
25250 movl ARGBASE+8(%esp),%edi # dst
25251 movl ARGBASE+12(%esp),%ecx # len
25252 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
25253 rep; stosb
25254 jmp 7b
25255 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
25256 - movl $-EFAULT, (%ebx)
25257 + movl $-EFAULT, %ss:(%ebx)
25258 jmp 7b
25259 .previous
25260
25261 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25262 + pushl_cfi %ss
25263 + popl_cfi %ds
25264 + pushl_cfi %ss
25265 + popl_cfi %es
25266 +#endif
25267 +
25268 popl_cfi %esi
25269 CFI_RESTORE esi
25270 popl_cfi %edi
25271 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
25272 CFI_RESTORE ebx
25273 ret
25274 CFI_ENDPROC
25275 -ENDPROC(csum_partial_copy_generic)
25276 +ENDPROC(csum_partial_copy_generic_to_user)
25277
25278 #undef ROUND
25279 #undef ROUND1
25280 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
25281 index f2145cf..cea889d 100644
25282 --- a/arch/x86/lib/clear_page_64.S
25283 +++ b/arch/x86/lib/clear_page_64.S
25284 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
25285 movl $4096/8,%ecx
25286 xorl %eax,%eax
25287 rep stosq
25288 + pax_force_retaddr
25289 ret
25290 CFI_ENDPROC
25291 ENDPROC(clear_page_c)
25292 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
25293 movl $4096,%ecx
25294 xorl %eax,%eax
25295 rep stosb
25296 + pax_force_retaddr
25297 ret
25298 CFI_ENDPROC
25299 ENDPROC(clear_page_c_e)
25300 @@ -43,6 +45,7 @@ ENTRY(clear_page)
25301 leaq 64(%rdi),%rdi
25302 jnz .Lloop
25303 nop
25304 + pax_force_retaddr
25305 ret
25306 CFI_ENDPROC
25307 .Lclear_page_end:
25308 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
25309
25310 #include <asm/cpufeature.h>
25311
25312 - .section .altinstr_replacement,"ax"
25313 + .section .altinstr_replacement,"a"
25314 1: .byte 0xeb /* jmp <disp8> */
25315 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
25316 2: .byte 0xeb /* jmp <disp8> */
25317 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
25318 index 1e572c5..2a162cd 100644
25319 --- a/arch/x86/lib/cmpxchg16b_emu.S
25320 +++ b/arch/x86/lib/cmpxchg16b_emu.S
25321 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
25322
25323 popf
25324 mov $1, %al
25325 + pax_force_retaddr
25326 ret
25327
25328 not_same:
25329 popf
25330 xor %al,%al
25331 + pax_force_retaddr
25332 ret
25333
25334 CFI_ENDPROC
25335 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
25336 index 176cca6..1166c50 100644
25337 --- a/arch/x86/lib/copy_page_64.S
25338 +++ b/arch/x86/lib/copy_page_64.S
25339 @@ -9,6 +9,7 @@ copy_page_rep:
25340 CFI_STARTPROC
25341 movl $4096/8, %ecx
25342 rep movsq
25343 + pax_force_retaddr
25344 ret
25345 CFI_ENDPROC
25346 ENDPROC(copy_page_rep)
25347 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
25348
25349 ENTRY(copy_page)
25350 CFI_STARTPROC
25351 - subq $2*8, %rsp
25352 - CFI_ADJUST_CFA_OFFSET 2*8
25353 + subq $3*8, %rsp
25354 + CFI_ADJUST_CFA_OFFSET 3*8
25355 movq %rbx, (%rsp)
25356 CFI_REL_OFFSET rbx, 0
25357 movq %r12, 1*8(%rsp)
25358 CFI_REL_OFFSET r12, 1*8
25359 + movq %r13, 2*8(%rsp)
25360 + CFI_REL_OFFSET r13, 2*8
25361
25362 movl $(4096/64)-5, %ecx
25363 .p2align 4
25364 @@ -36,7 +39,7 @@ ENTRY(copy_page)
25365 movq 0x8*2(%rsi), %rdx
25366 movq 0x8*3(%rsi), %r8
25367 movq 0x8*4(%rsi), %r9
25368 - movq 0x8*5(%rsi), %r10
25369 + movq 0x8*5(%rsi), %r13
25370 movq 0x8*6(%rsi), %r11
25371 movq 0x8*7(%rsi), %r12
25372
25373 @@ -47,7 +50,7 @@ ENTRY(copy_page)
25374 movq %rdx, 0x8*2(%rdi)
25375 movq %r8, 0x8*3(%rdi)
25376 movq %r9, 0x8*4(%rdi)
25377 - movq %r10, 0x8*5(%rdi)
25378 + movq %r13, 0x8*5(%rdi)
25379 movq %r11, 0x8*6(%rdi)
25380 movq %r12, 0x8*7(%rdi)
25381
25382 @@ -66,7 +69,7 @@ ENTRY(copy_page)
25383 movq 0x8*2(%rsi), %rdx
25384 movq 0x8*3(%rsi), %r8
25385 movq 0x8*4(%rsi), %r9
25386 - movq 0x8*5(%rsi), %r10
25387 + movq 0x8*5(%rsi), %r13
25388 movq 0x8*6(%rsi), %r11
25389 movq 0x8*7(%rsi), %r12
25390
25391 @@ -75,7 +78,7 @@ ENTRY(copy_page)
25392 movq %rdx, 0x8*2(%rdi)
25393 movq %r8, 0x8*3(%rdi)
25394 movq %r9, 0x8*4(%rdi)
25395 - movq %r10, 0x8*5(%rdi)
25396 + movq %r13, 0x8*5(%rdi)
25397 movq %r11, 0x8*6(%rdi)
25398 movq %r12, 0x8*7(%rdi)
25399
25400 @@ -87,8 +90,11 @@ ENTRY(copy_page)
25401 CFI_RESTORE rbx
25402 movq 1*8(%rsp), %r12
25403 CFI_RESTORE r12
25404 - addq $2*8, %rsp
25405 - CFI_ADJUST_CFA_OFFSET -2*8
25406 + movq 2*8(%rsp), %r13
25407 + CFI_RESTORE r13
25408 + addq $3*8, %rsp
25409 + CFI_ADJUST_CFA_OFFSET -3*8
25410 + pax_force_retaddr
25411 ret
25412 .Lcopy_page_end:
25413 CFI_ENDPROC
25414 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
25415
25416 #include <asm/cpufeature.h>
25417
25418 - .section .altinstr_replacement,"ax"
25419 + .section .altinstr_replacement,"a"
25420 1: .byte 0xeb /* jmp <disp8> */
25421 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25422 2:
25423 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25424 index a30ca15..d25fab6 100644
25425 --- a/arch/x86/lib/copy_user_64.S
25426 +++ b/arch/x86/lib/copy_user_64.S
25427 @@ -18,6 +18,7 @@
25428 #include <asm/alternative-asm.h>
25429 #include <asm/asm.h>
25430 #include <asm/smap.h>
25431 +#include <asm/pgtable.h>
25432
25433 /*
25434 * By placing feature2 after feature1 in altinstructions section, we logically
25435 @@ -31,7 +32,7 @@
25436 .byte 0xe9 /* 32bit jump */
25437 .long \orig-1f /* by default jump to orig */
25438 1:
25439 - .section .altinstr_replacement,"ax"
25440 + .section .altinstr_replacement,"a"
25441 2: .byte 0xe9 /* near jump with 32bit immediate */
25442 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
25443 3: .byte 0xe9 /* near jump with 32bit immediate */
25444 @@ -70,47 +71,20 @@
25445 #endif
25446 .endm
25447
25448 -/* Standard copy_to_user with segment limit checking */
25449 -ENTRY(_copy_to_user)
25450 - CFI_STARTPROC
25451 - GET_THREAD_INFO(%rax)
25452 - movq %rdi,%rcx
25453 - addq %rdx,%rcx
25454 - jc bad_to_user
25455 - cmpq TI_addr_limit(%rax),%rcx
25456 - ja bad_to_user
25457 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25458 - copy_user_generic_unrolled,copy_user_generic_string, \
25459 - copy_user_enhanced_fast_string
25460 - CFI_ENDPROC
25461 -ENDPROC(_copy_to_user)
25462 -
25463 -/* Standard copy_from_user with segment limit checking */
25464 -ENTRY(_copy_from_user)
25465 - CFI_STARTPROC
25466 - GET_THREAD_INFO(%rax)
25467 - movq %rsi,%rcx
25468 - addq %rdx,%rcx
25469 - jc bad_from_user
25470 - cmpq TI_addr_limit(%rax),%rcx
25471 - ja bad_from_user
25472 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25473 - copy_user_generic_unrolled,copy_user_generic_string, \
25474 - copy_user_enhanced_fast_string
25475 - CFI_ENDPROC
25476 -ENDPROC(_copy_from_user)
25477 -
25478 .section .fixup,"ax"
25479 /* must zero dest */
25480 ENTRY(bad_from_user)
25481 bad_from_user:
25482 CFI_STARTPROC
25483 + testl %edx,%edx
25484 + js bad_to_user
25485 movl %edx,%ecx
25486 xorl %eax,%eax
25487 rep
25488 stosb
25489 bad_to_user:
25490 movl %edx,%eax
25491 + pax_force_retaddr
25492 ret
25493 CFI_ENDPROC
25494 ENDPROC(bad_from_user)
25495 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
25496 jz 17f
25497 1: movq (%rsi),%r8
25498 2: movq 1*8(%rsi),%r9
25499 -3: movq 2*8(%rsi),%r10
25500 +3: movq 2*8(%rsi),%rax
25501 4: movq 3*8(%rsi),%r11
25502 5: movq %r8,(%rdi)
25503 6: movq %r9,1*8(%rdi)
25504 -7: movq %r10,2*8(%rdi)
25505 +7: movq %rax,2*8(%rdi)
25506 8: movq %r11,3*8(%rdi)
25507 9: movq 4*8(%rsi),%r8
25508 10: movq 5*8(%rsi),%r9
25509 -11: movq 6*8(%rsi),%r10
25510 +11: movq 6*8(%rsi),%rax
25511 12: movq 7*8(%rsi),%r11
25512 13: movq %r8,4*8(%rdi)
25513 14: movq %r9,5*8(%rdi)
25514 -15: movq %r10,6*8(%rdi)
25515 +15: movq %rax,6*8(%rdi)
25516 16: movq %r11,7*8(%rdi)
25517 leaq 64(%rsi),%rsi
25518 leaq 64(%rdi),%rdi
25519 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25520 jnz 21b
25521 23: xor %eax,%eax
25522 ASM_CLAC
25523 + pax_force_retaddr
25524 ret
25525
25526 .section .fixup,"ax"
25527 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25528 movsb
25529 4: xorl %eax,%eax
25530 ASM_CLAC
25531 + pax_force_retaddr
25532 ret
25533
25534 .section .fixup,"ax"
25535 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25536 movsb
25537 2: xorl %eax,%eax
25538 ASM_CLAC
25539 + pax_force_retaddr
25540 ret
25541
25542 .section .fixup,"ax"
25543 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25544 index 6a4f43c..f5f9e26 100644
25545 --- a/arch/x86/lib/copy_user_nocache_64.S
25546 +++ b/arch/x86/lib/copy_user_nocache_64.S
25547 @@ -8,6 +8,7 @@
25548
25549 #include <linux/linkage.h>
25550 #include <asm/dwarf2.h>
25551 +#include <asm/alternative-asm.h>
25552
25553 #define FIX_ALIGNMENT 1
25554
25555 @@ -16,6 +17,7 @@
25556 #include <asm/thread_info.h>
25557 #include <asm/asm.h>
25558 #include <asm/smap.h>
25559 +#include <asm/pgtable.h>
25560
25561 .macro ALIGN_DESTINATION
25562 #ifdef FIX_ALIGNMENT
25563 @@ -49,6 +51,15 @@
25564 */
25565 ENTRY(__copy_user_nocache)
25566 CFI_STARTPROC
25567 +
25568 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25569 + mov $PAX_USER_SHADOW_BASE,%rcx
25570 + cmp %rcx,%rsi
25571 + jae 1f
25572 + add %rcx,%rsi
25573 +1:
25574 +#endif
25575 +
25576 ASM_STAC
25577 cmpl $8,%edx
25578 jb 20f /* less then 8 bytes, go to byte copy loop */
25579 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25580 jz 17f
25581 1: movq (%rsi),%r8
25582 2: movq 1*8(%rsi),%r9
25583 -3: movq 2*8(%rsi),%r10
25584 +3: movq 2*8(%rsi),%rax
25585 4: movq 3*8(%rsi),%r11
25586 5: movnti %r8,(%rdi)
25587 6: movnti %r9,1*8(%rdi)
25588 -7: movnti %r10,2*8(%rdi)
25589 +7: movnti %rax,2*8(%rdi)
25590 8: movnti %r11,3*8(%rdi)
25591 9: movq 4*8(%rsi),%r8
25592 10: movq 5*8(%rsi),%r9
25593 -11: movq 6*8(%rsi),%r10
25594 +11: movq 6*8(%rsi),%rax
25595 12: movq 7*8(%rsi),%r11
25596 13: movnti %r8,4*8(%rdi)
25597 14: movnti %r9,5*8(%rdi)
25598 -15: movnti %r10,6*8(%rdi)
25599 +15: movnti %rax,6*8(%rdi)
25600 16: movnti %r11,7*8(%rdi)
25601 leaq 64(%rsi),%rsi
25602 leaq 64(%rdi),%rdi
25603 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25604 23: xorl %eax,%eax
25605 ASM_CLAC
25606 sfence
25607 + pax_force_retaddr
25608 ret
25609
25610 .section .fixup,"ax"
25611 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25612 index 2419d5f..953ee51 100644
25613 --- a/arch/x86/lib/csum-copy_64.S
25614 +++ b/arch/x86/lib/csum-copy_64.S
25615 @@ -9,6 +9,7 @@
25616 #include <asm/dwarf2.h>
25617 #include <asm/errno.h>
25618 #include <asm/asm.h>
25619 +#include <asm/alternative-asm.h>
25620
25621 /*
25622 * Checksum copy with exception handling.
25623 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25624 CFI_RESTORE rbp
25625 addq $7*8, %rsp
25626 CFI_ADJUST_CFA_OFFSET -7*8
25627 + pax_force_retaddr 0, 1
25628 ret
25629 CFI_RESTORE_STATE
25630
25631 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25632 index 25b7ae8..169fafc 100644
25633 --- a/arch/x86/lib/csum-wrappers_64.c
25634 +++ b/arch/x86/lib/csum-wrappers_64.c
25635 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25636 len -= 2;
25637 }
25638 }
25639 - isum = csum_partial_copy_generic((__force const void *)src,
25640 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25641 dst, len, isum, errp, NULL);
25642 if (unlikely(*errp))
25643 goto out_err;
25644 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25645 }
25646
25647 *errp = 0;
25648 - return csum_partial_copy_generic(src, (void __force *)dst,
25649 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25650 len, isum, NULL, errp);
25651 }
25652 EXPORT_SYMBOL(csum_partial_copy_to_user);
25653 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25654 index 156b9c8..b144132 100644
25655 --- a/arch/x86/lib/getuser.S
25656 +++ b/arch/x86/lib/getuser.S
25657 @@ -34,17 +34,40 @@
25658 #include <asm/thread_info.h>
25659 #include <asm/asm.h>
25660 #include <asm/smap.h>
25661 +#include <asm/segment.h>
25662 +#include <asm/pgtable.h>
25663 +#include <asm/alternative-asm.h>
25664 +
25665 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25666 +#define __copyuser_seg gs;
25667 +#else
25668 +#define __copyuser_seg
25669 +#endif
25670
25671 .text
25672 ENTRY(__get_user_1)
25673 CFI_STARTPROC
25674 +
25675 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25676 GET_THREAD_INFO(%_ASM_DX)
25677 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25678 jae bad_get_user
25679 ASM_STAC
25680 -1: movzb (%_ASM_AX),%edx
25681 +
25682 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25683 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25684 + cmp %_ASM_DX,%_ASM_AX
25685 + jae 1234f
25686 + add %_ASM_DX,%_ASM_AX
25687 +1234:
25688 +#endif
25689 +
25690 +#endif
25691 +
25692 +1: __copyuser_seg movzb (%_ASM_AX),%edx
25693 xor %eax,%eax
25694 ASM_CLAC
25695 + pax_force_retaddr
25696 ret
25697 CFI_ENDPROC
25698 ENDPROC(__get_user_1)
25699 @@ -52,14 +75,28 @@ ENDPROC(__get_user_1)
25700 ENTRY(__get_user_2)
25701 CFI_STARTPROC
25702 add $1,%_ASM_AX
25703 +
25704 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25705 jc bad_get_user
25706 GET_THREAD_INFO(%_ASM_DX)
25707 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25708 jae bad_get_user
25709 ASM_STAC
25710 -2: movzwl -1(%_ASM_AX),%edx
25711 +
25712 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25713 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25714 + cmp %_ASM_DX,%_ASM_AX
25715 + jae 1234f
25716 + add %_ASM_DX,%_ASM_AX
25717 +1234:
25718 +#endif
25719 +
25720 +#endif
25721 +
25722 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25723 xor %eax,%eax
25724 ASM_CLAC
25725 + pax_force_retaddr
25726 ret
25727 CFI_ENDPROC
25728 ENDPROC(__get_user_2)
25729 @@ -67,14 +104,28 @@ ENDPROC(__get_user_2)
25730 ENTRY(__get_user_4)
25731 CFI_STARTPROC
25732 add $3,%_ASM_AX
25733 +
25734 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25735 jc bad_get_user
25736 GET_THREAD_INFO(%_ASM_DX)
25737 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25738 jae bad_get_user
25739 ASM_STAC
25740 -3: mov -3(%_ASM_AX),%edx
25741 +
25742 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25743 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25744 + cmp %_ASM_DX,%_ASM_AX
25745 + jae 1234f
25746 + add %_ASM_DX,%_ASM_AX
25747 +1234:
25748 +#endif
25749 +
25750 +#endif
25751 +
25752 +3: __copyuser_seg mov -3(%_ASM_AX),%edx
25753 xor %eax,%eax
25754 ASM_CLAC
25755 + pax_force_retaddr
25756 ret
25757 CFI_ENDPROC
25758 ENDPROC(__get_user_4)
25759 @@ -87,10 +138,20 @@ ENTRY(__get_user_8)
25760 GET_THREAD_INFO(%_ASM_DX)
25761 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25762 jae bad_get_user
25763 +
25764 +#ifdef 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 ASM_STAC
25773 4: movq -7(%_ASM_AX),%_ASM_DX
25774 xor %eax,%eax
25775 ASM_CLAC
25776 + pax_force_retaddr
25777 ret
25778 CFI_ENDPROC
25779 ENDPROC(__get_user_8)
25780 @@ -101,6 +162,7 @@ bad_get_user:
25781 xor %edx,%edx
25782 mov $(-EFAULT),%_ASM_AX
25783 ASM_CLAC
25784 + pax_force_retaddr
25785 ret
25786 CFI_ENDPROC
25787 END(bad_get_user)
25788 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25789 index 54fcffe..7be149e 100644
25790 --- a/arch/x86/lib/insn.c
25791 +++ b/arch/x86/lib/insn.c
25792 @@ -20,8 +20,10 @@
25793
25794 #ifdef __KERNEL__
25795 #include <linux/string.h>
25796 +#include <asm/pgtable_types.h>
25797 #else
25798 #include <string.h>
25799 +#define ktla_ktva(addr) addr
25800 #endif
25801 #include <asm/inat.h>
25802 #include <asm/insn.h>
25803 @@ -53,8 +55,8 @@
25804 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25805 {
25806 memset(insn, 0, sizeof(*insn));
25807 - insn->kaddr = kaddr;
25808 - insn->next_byte = kaddr;
25809 + insn->kaddr = ktla_ktva(kaddr);
25810 + insn->next_byte = ktla_ktva(kaddr);
25811 insn->x86_64 = x86_64 ? 1 : 0;
25812 insn->opnd_bytes = 4;
25813 if (x86_64)
25814 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25815 index 05a95e7..326f2fa 100644
25816 --- a/arch/x86/lib/iomap_copy_64.S
25817 +++ b/arch/x86/lib/iomap_copy_64.S
25818 @@ -17,6 +17,7 @@
25819
25820 #include <linux/linkage.h>
25821 #include <asm/dwarf2.h>
25822 +#include <asm/alternative-asm.h>
25823
25824 /*
25825 * override generic version in lib/iomap_copy.c
25826 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25827 CFI_STARTPROC
25828 movl %edx,%ecx
25829 rep movsd
25830 + pax_force_retaddr
25831 ret
25832 CFI_ENDPROC
25833 ENDPROC(__iowrite32_copy)
25834 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25835 index 1c273be..da9cc0e 100644
25836 --- a/arch/x86/lib/memcpy_64.S
25837 +++ b/arch/x86/lib/memcpy_64.S
25838 @@ -33,6 +33,7 @@
25839 rep movsq
25840 movl %edx, %ecx
25841 rep movsb
25842 + pax_force_retaddr
25843 ret
25844 .Lmemcpy_e:
25845 .previous
25846 @@ -49,6 +50,7 @@
25847 movq %rdi, %rax
25848 movq %rdx, %rcx
25849 rep movsb
25850 + pax_force_retaddr
25851 ret
25852 .Lmemcpy_e_e:
25853 .previous
25854 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25855 */
25856 movq 0*8(%rsi), %r8
25857 movq 1*8(%rsi), %r9
25858 - movq 2*8(%rsi), %r10
25859 + movq 2*8(%rsi), %rcx
25860 movq 3*8(%rsi), %r11
25861 leaq 4*8(%rsi), %rsi
25862
25863 movq %r8, 0*8(%rdi)
25864 movq %r9, 1*8(%rdi)
25865 - movq %r10, 2*8(%rdi)
25866 + movq %rcx, 2*8(%rdi)
25867 movq %r11, 3*8(%rdi)
25868 leaq 4*8(%rdi), %rdi
25869 jae .Lcopy_forward_loop
25870 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25871 subq $0x20, %rdx
25872 movq -1*8(%rsi), %r8
25873 movq -2*8(%rsi), %r9
25874 - movq -3*8(%rsi), %r10
25875 + movq -3*8(%rsi), %rcx
25876 movq -4*8(%rsi), %r11
25877 leaq -4*8(%rsi), %rsi
25878 movq %r8, -1*8(%rdi)
25879 movq %r9, -2*8(%rdi)
25880 - movq %r10, -3*8(%rdi)
25881 + movq %rcx, -3*8(%rdi)
25882 movq %r11, -4*8(%rdi)
25883 leaq -4*8(%rdi), %rdi
25884 jae .Lcopy_backward_loop
25885 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25886 */
25887 movq 0*8(%rsi), %r8
25888 movq 1*8(%rsi), %r9
25889 - movq -2*8(%rsi, %rdx), %r10
25890 + movq -2*8(%rsi, %rdx), %rcx
25891 movq -1*8(%rsi, %rdx), %r11
25892 movq %r8, 0*8(%rdi)
25893 movq %r9, 1*8(%rdi)
25894 - movq %r10, -2*8(%rdi, %rdx)
25895 + movq %rcx, -2*8(%rdi, %rdx)
25896 movq %r11, -1*8(%rdi, %rdx)
25897 + pax_force_retaddr
25898 retq
25899 .p2align 4
25900 .Lless_16bytes:
25901 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25902 movq -1*8(%rsi, %rdx), %r9
25903 movq %r8, 0*8(%rdi)
25904 movq %r9, -1*8(%rdi, %rdx)
25905 + pax_force_retaddr
25906 retq
25907 .p2align 4
25908 .Lless_8bytes:
25909 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25910 movl -4(%rsi, %rdx), %r8d
25911 movl %ecx, (%rdi)
25912 movl %r8d, -4(%rdi, %rdx)
25913 + pax_force_retaddr
25914 retq
25915 .p2align 4
25916 .Lless_3bytes:
25917 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25918 movb %cl, (%rdi)
25919
25920 .Lend:
25921 + pax_force_retaddr
25922 retq
25923 CFI_ENDPROC
25924 ENDPROC(memcpy)
25925 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25926 index ee16461..c39c199 100644
25927 --- a/arch/x86/lib/memmove_64.S
25928 +++ b/arch/x86/lib/memmove_64.S
25929 @@ -61,13 +61,13 @@ ENTRY(memmove)
25930 5:
25931 sub $0x20, %rdx
25932 movq 0*8(%rsi), %r11
25933 - movq 1*8(%rsi), %r10
25934 + movq 1*8(%rsi), %rcx
25935 movq 2*8(%rsi), %r9
25936 movq 3*8(%rsi), %r8
25937 leaq 4*8(%rsi), %rsi
25938
25939 movq %r11, 0*8(%rdi)
25940 - movq %r10, 1*8(%rdi)
25941 + movq %rcx, 1*8(%rdi)
25942 movq %r9, 2*8(%rdi)
25943 movq %r8, 3*8(%rdi)
25944 leaq 4*8(%rdi), %rdi
25945 @@ -81,10 +81,10 @@ ENTRY(memmove)
25946 4:
25947 movq %rdx, %rcx
25948 movq -8(%rsi, %rdx), %r11
25949 - lea -8(%rdi, %rdx), %r10
25950 + lea -8(%rdi, %rdx), %r9
25951 shrq $3, %rcx
25952 rep movsq
25953 - movq %r11, (%r10)
25954 + movq %r11, (%r9)
25955 jmp 13f
25956 .Lmemmove_end_forward:
25957
25958 @@ -95,14 +95,14 @@ ENTRY(memmove)
25959 7:
25960 movq %rdx, %rcx
25961 movq (%rsi), %r11
25962 - movq %rdi, %r10
25963 + movq %rdi, %r9
25964 leaq -8(%rsi, %rdx), %rsi
25965 leaq -8(%rdi, %rdx), %rdi
25966 shrq $3, %rcx
25967 std
25968 rep movsq
25969 cld
25970 - movq %r11, (%r10)
25971 + movq %r11, (%r9)
25972 jmp 13f
25973
25974 /*
25975 @@ -127,13 +127,13 @@ ENTRY(memmove)
25976 8:
25977 subq $0x20, %rdx
25978 movq -1*8(%rsi), %r11
25979 - movq -2*8(%rsi), %r10
25980 + movq -2*8(%rsi), %rcx
25981 movq -3*8(%rsi), %r9
25982 movq -4*8(%rsi), %r8
25983 leaq -4*8(%rsi), %rsi
25984
25985 movq %r11, -1*8(%rdi)
25986 - movq %r10, -2*8(%rdi)
25987 + movq %rcx, -2*8(%rdi)
25988 movq %r9, -3*8(%rdi)
25989 movq %r8, -4*8(%rdi)
25990 leaq -4*8(%rdi), %rdi
25991 @@ -151,11 +151,11 @@ ENTRY(memmove)
25992 * Move data from 16 bytes to 31 bytes.
25993 */
25994 movq 0*8(%rsi), %r11
25995 - movq 1*8(%rsi), %r10
25996 + movq 1*8(%rsi), %rcx
25997 movq -2*8(%rsi, %rdx), %r9
25998 movq -1*8(%rsi, %rdx), %r8
25999 movq %r11, 0*8(%rdi)
26000 - movq %r10, 1*8(%rdi)
26001 + movq %rcx, 1*8(%rdi)
26002 movq %r9, -2*8(%rdi, %rdx)
26003 movq %r8, -1*8(%rdi, %rdx)
26004 jmp 13f
26005 @@ -167,9 +167,9 @@ ENTRY(memmove)
26006 * Move data from 8 bytes to 15 bytes.
26007 */
26008 movq 0*8(%rsi), %r11
26009 - movq -1*8(%rsi, %rdx), %r10
26010 + movq -1*8(%rsi, %rdx), %r9
26011 movq %r11, 0*8(%rdi)
26012 - movq %r10, -1*8(%rdi, %rdx)
26013 + movq %r9, -1*8(%rdi, %rdx)
26014 jmp 13f
26015 10:
26016 cmpq $4, %rdx
26017 @@ -178,9 +178,9 @@ ENTRY(memmove)
26018 * Move data from 4 bytes to 7 bytes.
26019 */
26020 movl (%rsi), %r11d
26021 - movl -4(%rsi, %rdx), %r10d
26022 + movl -4(%rsi, %rdx), %r9d
26023 movl %r11d, (%rdi)
26024 - movl %r10d, -4(%rdi, %rdx)
26025 + movl %r9d, -4(%rdi, %rdx)
26026 jmp 13f
26027 11:
26028 cmp $2, %rdx
26029 @@ -189,9 +189,9 @@ ENTRY(memmove)
26030 * Move data from 2 bytes to 3 bytes.
26031 */
26032 movw (%rsi), %r11w
26033 - movw -2(%rsi, %rdx), %r10w
26034 + movw -2(%rsi, %rdx), %r9w
26035 movw %r11w, (%rdi)
26036 - movw %r10w, -2(%rdi, %rdx)
26037 + movw %r9w, -2(%rdi, %rdx)
26038 jmp 13f
26039 12:
26040 cmp $1, %rdx
26041 @@ -202,6 +202,7 @@ ENTRY(memmove)
26042 movb (%rsi), %r11b
26043 movb %r11b, (%rdi)
26044 13:
26045 + pax_force_retaddr
26046 retq
26047 CFI_ENDPROC
26048
26049 @@ -210,6 +211,7 @@ ENTRY(memmove)
26050 /* Forward moving data. */
26051 movq %rdx, %rcx
26052 rep movsb
26053 + pax_force_retaddr
26054 retq
26055 .Lmemmove_end_forward_efs:
26056 .previous
26057 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
26058 index 2dcb380..963660a 100644
26059 --- a/arch/x86/lib/memset_64.S
26060 +++ b/arch/x86/lib/memset_64.S
26061 @@ -30,6 +30,7 @@
26062 movl %edx,%ecx
26063 rep stosb
26064 movq %r9,%rax
26065 + pax_force_retaddr
26066 ret
26067 .Lmemset_e:
26068 .previous
26069 @@ -52,6 +53,7 @@
26070 movq %rdx,%rcx
26071 rep stosb
26072 movq %r9,%rax
26073 + pax_force_retaddr
26074 ret
26075 .Lmemset_e_e:
26076 .previous
26077 @@ -59,7 +61,7 @@
26078 ENTRY(memset)
26079 ENTRY(__memset)
26080 CFI_STARTPROC
26081 - movq %rdi,%r10
26082 + movq %rdi,%r11
26083
26084 /* expand byte value */
26085 movzbl %sil,%ecx
26086 @@ -117,7 +119,8 @@ ENTRY(__memset)
26087 jnz .Lloop_1
26088
26089 .Lende:
26090 - movq %r10,%rax
26091 + movq %r11,%rax
26092 + pax_force_retaddr
26093 ret
26094
26095 CFI_RESTORE_STATE
26096 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
26097 index c9f2d9b..e7fd2c0 100644
26098 --- a/arch/x86/lib/mmx_32.c
26099 +++ b/arch/x86/lib/mmx_32.c
26100 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
26101 {
26102 void *p;
26103 int i;
26104 + unsigned long cr0;
26105
26106 if (unlikely(in_interrupt()))
26107 return __memcpy(to, from, len);
26108 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
26109 kernel_fpu_begin();
26110
26111 __asm__ __volatile__ (
26112 - "1: prefetch (%0)\n" /* This set is 28 bytes */
26113 - " prefetch 64(%0)\n"
26114 - " prefetch 128(%0)\n"
26115 - " prefetch 192(%0)\n"
26116 - " prefetch 256(%0)\n"
26117 + "1: prefetch (%1)\n" /* This set is 28 bytes */
26118 + " prefetch 64(%1)\n"
26119 + " prefetch 128(%1)\n"
26120 + " prefetch 192(%1)\n"
26121 + " prefetch 256(%1)\n"
26122 "2: \n"
26123 ".section .fixup, \"ax\"\n"
26124 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26125 + "3: \n"
26126 +
26127 +#ifdef CONFIG_PAX_KERNEXEC
26128 + " movl %%cr0, %0\n"
26129 + " movl %0, %%eax\n"
26130 + " andl $0xFFFEFFFF, %%eax\n"
26131 + " movl %%eax, %%cr0\n"
26132 +#endif
26133 +
26134 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26135 +
26136 +#ifdef CONFIG_PAX_KERNEXEC
26137 + " movl %0, %%cr0\n"
26138 +#endif
26139 +
26140 " jmp 2b\n"
26141 ".previous\n"
26142 _ASM_EXTABLE(1b, 3b)
26143 - : : "r" (from));
26144 + : "=&r" (cr0) : "r" (from) : "ax");
26145
26146 for ( ; i > 5; i--) {
26147 __asm__ __volatile__ (
26148 - "1: prefetch 320(%0)\n"
26149 - "2: movq (%0), %%mm0\n"
26150 - " movq 8(%0), %%mm1\n"
26151 - " movq 16(%0), %%mm2\n"
26152 - " movq 24(%0), %%mm3\n"
26153 - " movq %%mm0, (%1)\n"
26154 - " movq %%mm1, 8(%1)\n"
26155 - " movq %%mm2, 16(%1)\n"
26156 - " movq %%mm3, 24(%1)\n"
26157 - " movq 32(%0), %%mm0\n"
26158 - " movq 40(%0), %%mm1\n"
26159 - " movq 48(%0), %%mm2\n"
26160 - " movq 56(%0), %%mm3\n"
26161 - " movq %%mm0, 32(%1)\n"
26162 - " movq %%mm1, 40(%1)\n"
26163 - " movq %%mm2, 48(%1)\n"
26164 - " movq %%mm3, 56(%1)\n"
26165 + "1: prefetch 320(%1)\n"
26166 + "2: movq (%1), %%mm0\n"
26167 + " movq 8(%1), %%mm1\n"
26168 + " movq 16(%1), %%mm2\n"
26169 + " movq 24(%1), %%mm3\n"
26170 + " movq %%mm0, (%2)\n"
26171 + " movq %%mm1, 8(%2)\n"
26172 + " movq %%mm2, 16(%2)\n"
26173 + " movq %%mm3, 24(%2)\n"
26174 + " movq 32(%1), %%mm0\n"
26175 + " movq 40(%1), %%mm1\n"
26176 + " movq 48(%1), %%mm2\n"
26177 + " movq 56(%1), %%mm3\n"
26178 + " movq %%mm0, 32(%2)\n"
26179 + " movq %%mm1, 40(%2)\n"
26180 + " movq %%mm2, 48(%2)\n"
26181 + " movq %%mm3, 56(%2)\n"
26182 ".section .fixup, \"ax\"\n"
26183 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26184 + "3:\n"
26185 +
26186 +#ifdef CONFIG_PAX_KERNEXEC
26187 + " movl %%cr0, %0\n"
26188 + " movl %0, %%eax\n"
26189 + " andl $0xFFFEFFFF, %%eax\n"
26190 + " movl %%eax, %%cr0\n"
26191 +#endif
26192 +
26193 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26194 +
26195 +#ifdef CONFIG_PAX_KERNEXEC
26196 + " movl %0, %%cr0\n"
26197 +#endif
26198 +
26199 " jmp 2b\n"
26200 ".previous\n"
26201 _ASM_EXTABLE(1b, 3b)
26202 - : : "r" (from), "r" (to) : "memory");
26203 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26204
26205 from += 64;
26206 to += 64;
26207 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
26208 static void fast_copy_page(void *to, void *from)
26209 {
26210 int i;
26211 + unsigned long cr0;
26212
26213 kernel_fpu_begin();
26214
26215 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
26216 * but that is for later. -AV
26217 */
26218 __asm__ __volatile__(
26219 - "1: prefetch (%0)\n"
26220 - " prefetch 64(%0)\n"
26221 - " prefetch 128(%0)\n"
26222 - " prefetch 192(%0)\n"
26223 - " prefetch 256(%0)\n"
26224 + "1: prefetch (%1)\n"
26225 + " prefetch 64(%1)\n"
26226 + " prefetch 128(%1)\n"
26227 + " prefetch 192(%1)\n"
26228 + " prefetch 256(%1)\n"
26229 "2: \n"
26230 ".section .fixup, \"ax\"\n"
26231 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26232 + "3: \n"
26233 +
26234 +#ifdef CONFIG_PAX_KERNEXEC
26235 + " movl %%cr0, %0\n"
26236 + " movl %0, %%eax\n"
26237 + " andl $0xFFFEFFFF, %%eax\n"
26238 + " movl %%eax, %%cr0\n"
26239 +#endif
26240 +
26241 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26242 +
26243 +#ifdef CONFIG_PAX_KERNEXEC
26244 + " movl %0, %%cr0\n"
26245 +#endif
26246 +
26247 " jmp 2b\n"
26248 ".previous\n"
26249 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26250 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26251
26252 for (i = 0; i < (4096-320)/64; i++) {
26253 __asm__ __volatile__ (
26254 - "1: prefetch 320(%0)\n"
26255 - "2: movq (%0), %%mm0\n"
26256 - " movntq %%mm0, (%1)\n"
26257 - " movq 8(%0), %%mm1\n"
26258 - " movntq %%mm1, 8(%1)\n"
26259 - " movq 16(%0), %%mm2\n"
26260 - " movntq %%mm2, 16(%1)\n"
26261 - " movq 24(%0), %%mm3\n"
26262 - " movntq %%mm3, 24(%1)\n"
26263 - " movq 32(%0), %%mm4\n"
26264 - " movntq %%mm4, 32(%1)\n"
26265 - " movq 40(%0), %%mm5\n"
26266 - " movntq %%mm5, 40(%1)\n"
26267 - " movq 48(%0), %%mm6\n"
26268 - " movntq %%mm6, 48(%1)\n"
26269 - " movq 56(%0), %%mm7\n"
26270 - " movntq %%mm7, 56(%1)\n"
26271 + "1: prefetch 320(%1)\n"
26272 + "2: movq (%1), %%mm0\n"
26273 + " movntq %%mm0, (%2)\n"
26274 + " movq 8(%1), %%mm1\n"
26275 + " movntq %%mm1, 8(%2)\n"
26276 + " movq 16(%1), %%mm2\n"
26277 + " movntq %%mm2, 16(%2)\n"
26278 + " movq 24(%1), %%mm3\n"
26279 + " movntq %%mm3, 24(%2)\n"
26280 + " movq 32(%1), %%mm4\n"
26281 + " movntq %%mm4, 32(%2)\n"
26282 + " movq 40(%1), %%mm5\n"
26283 + " movntq %%mm5, 40(%2)\n"
26284 + " movq 48(%1), %%mm6\n"
26285 + " movntq %%mm6, 48(%2)\n"
26286 + " movq 56(%1), %%mm7\n"
26287 + " movntq %%mm7, 56(%2)\n"
26288 ".section .fixup, \"ax\"\n"
26289 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26290 + "3:\n"
26291 +
26292 +#ifdef CONFIG_PAX_KERNEXEC
26293 + " movl %%cr0, %0\n"
26294 + " movl %0, %%eax\n"
26295 + " andl $0xFFFEFFFF, %%eax\n"
26296 + " movl %%eax, %%cr0\n"
26297 +#endif
26298 +
26299 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26300 +
26301 +#ifdef CONFIG_PAX_KERNEXEC
26302 + " movl %0, %%cr0\n"
26303 +#endif
26304 +
26305 " jmp 2b\n"
26306 ".previous\n"
26307 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
26308 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26309
26310 from += 64;
26311 to += 64;
26312 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
26313 static void fast_copy_page(void *to, void *from)
26314 {
26315 int i;
26316 + unsigned long cr0;
26317
26318 kernel_fpu_begin();
26319
26320 __asm__ __volatile__ (
26321 - "1: prefetch (%0)\n"
26322 - " prefetch 64(%0)\n"
26323 - " prefetch 128(%0)\n"
26324 - " prefetch 192(%0)\n"
26325 - " prefetch 256(%0)\n"
26326 + "1: prefetch (%1)\n"
26327 + " prefetch 64(%1)\n"
26328 + " prefetch 128(%1)\n"
26329 + " prefetch 192(%1)\n"
26330 + " prefetch 256(%1)\n"
26331 "2: \n"
26332 ".section .fixup, \"ax\"\n"
26333 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26334 + "3: \n"
26335 +
26336 +#ifdef CONFIG_PAX_KERNEXEC
26337 + " movl %%cr0, %0\n"
26338 + " movl %0, %%eax\n"
26339 + " andl $0xFFFEFFFF, %%eax\n"
26340 + " movl %%eax, %%cr0\n"
26341 +#endif
26342 +
26343 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26344 +
26345 +#ifdef CONFIG_PAX_KERNEXEC
26346 + " movl %0, %%cr0\n"
26347 +#endif
26348 +
26349 " jmp 2b\n"
26350 ".previous\n"
26351 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26352 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26353
26354 for (i = 0; i < 4096/64; i++) {
26355 __asm__ __volatile__ (
26356 - "1: prefetch 320(%0)\n"
26357 - "2: movq (%0), %%mm0\n"
26358 - " movq 8(%0), %%mm1\n"
26359 - " movq 16(%0), %%mm2\n"
26360 - " movq 24(%0), %%mm3\n"
26361 - " movq %%mm0, (%1)\n"
26362 - " movq %%mm1, 8(%1)\n"
26363 - " movq %%mm2, 16(%1)\n"
26364 - " movq %%mm3, 24(%1)\n"
26365 - " movq 32(%0), %%mm0\n"
26366 - " movq 40(%0), %%mm1\n"
26367 - " movq 48(%0), %%mm2\n"
26368 - " movq 56(%0), %%mm3\n"
26369 - " movq %%mm0, 32(%1)\n"
26370 - " movq %%mm1, 40(%1)\n"
26371 - " movq %%mm2, 48(%1)\n"
26372 - " movq %%mm3, 56(%1)\n"
26373 + "1: prefetch 320(%1)\n"
26374 + "2: movq (%1), %%mm0\n"
26375 + " movq 8(%1), %%mm1\n"
26376 + " movq 16(%1), %%mm2\n"
26377 + " movq 24(%1), %%mm3\n"
26378 + " movq %%mm0, (%2)\n"
26379 + " movq %%mm1, 8(%2)\n"
26380 + " movq %%mm2, 16(%2)\n"
26381 + " movq %%mm3, 24(%2)\n"
26382 + " movq 32(%1), %%mm0\n"
26383 + " movq 40(%1), %%mm1\n"
26384 + " movq 48(%1), %%mm2\n"
26385 + " movq 56(%1), %%mm3\n"
26386 + " movq %%mm0, 32(%2)\n"
26387 + " movq %%mm1, 40(%2)\n"
26388 + " movq %%mm2, 48(%2)\n"
26389 + " movq %%mm3, 56(%2)\n"
26390 ".section .fixup, \"ax\"\n"
26391 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26392 + "3:\n"
26393 +
26394 +#ifdef CONFIG_PAX_KERNEXEC
26395 + " movl %%cr0, %0\n"
26396 + " movl %0, %%eax\n"
26397 + " andl $0xFFFEFFFF, %%eax\n"
26398 + " movl %%eax, %%cr0\n"
26399 +#endif
26400 +
26401 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26402 +
26403 +#ifdef CONFIG_PAX_KERNEXEC
26404 + " movl %0, %%cr0\n"
26405 +#endif
26406 +
26407 " jmp 2b\n"
26408 ".previous\n"
26409 _ASM_EXTABLE(1b, 3b)
26410 - : : "r" (from), "r" (to) : "memory");
26411 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26412
26413 from += 64;
26414 to += 64;
26415 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26416 index f6d13ee..aca5f0b 100644
26417 --- a/arch/x86/lib/msr-reg.S
26418 +++ b/arch/x86/lib/msr-reg.S
26419 @@ -3,6 +3,7 @@
26420 #include <asm/dwarf2.h>
26421 #include <asm/asm.h>
26422 #include <asm/msr.h>
26423 +#include <asm/alternative-asm.h>
26424
26425 #ifdef CONFIG_X86_64
26426 /*
26427 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26428 CFI_STARTPROC
26429 pushq_cfi %rbx
26430 pushq_cfi %rbp
26431 - movq %rdi, %r10 /* Save pointer */
26432 + movq %rdi, %r9 /* Save pointer */
26433 xorl %r11d, %r11d /* Return value */
26434 movl (%rdi), %eax
26435 movl 4(%rdi), %ecx
26436 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
26437 movl 28(%rdi), %edi
26438 CFI_REMEMBER_STATE
26439 1: \op
26440 -2: movl %eax, (%r10)
26441 +2: movl %eax, (%r9)
26442 movl %r11d, %eax /* Return value */
26443 - movl %ecx, 4(%r10)
26444 - movl %edx, 8(%r10)
26445 - movl %ebx, 12(%r10)
26446 - movl %ebp, 20(%r10)
26447 - movl %esi, 24(%r10)
26448 - movl %edi, 28(%r10)
26449 + movl %ecx, 4(%r9)
26450 + movl %edx, 8(%r9)
26451 + movl %ebx, 12(%r9)
26452 + movl %ebp, 20(%r9)
26453 + movl %esi, 24(%r9)
26454 + movl %edi, 28(%r9)
26455 popq_cfi %rbp
26456 popq_cfi %rbx
26457 + pax_force_retaddr
26458 ret
26459 3:
26460 CFI_RESTORE_STATE
26461 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
26462 index fc6ba17..04471c5 100644
26463 --- a/arch/x86/lib/putuser.S
26464 +++ b/arch/x86/lib/putuser.S
26465 @@ -16,7 +16,9 @@
26466 #include <asm/errno.h>
26467 #include <asm/asm.h>
26468 #include <asm/smap.h>
26469 -
26470 +#include <asm/segment.h>
26471 +#include <asm/pgtable.h>
26472 +#include <asm/alternative-asm.h>
26473
26474 /*
26475 * __put_user_X
26476 @@ -30,57 +32,125 @@
26477 * as they get called from within inline assembly.
26478 */
26479
26480 -#define ENTER CFI_STARTPROC ; \
26481 - GET_THREAD_INFO(%_ASM_BX)
26482 -#define EXIT ASM_CLAC ; \
26483 - ret ; \
26484 +#define ENTER CFI_STARTPROC
26485 +#define EXIT ASM_CLAC ; \
26486 + pax_force_retaddr ; \
26487 + ret ; \
26488 CFI_ENDPROC
26489
26490 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26491 +#define _DEST %_ASM_CX,%_ASM_BX
26492 +#else
26493 +#define _DEST %_ASM_CX
26494 +#endif
26495 +
26496 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26497 +#define __copyuser_seg gs;
26498 +#else
26499 +#define __copyuser_seg
26500 +#endif
26501 +
26502 .text
26503 ENTRY(__put_user_1)
26504 ENTER
26505 +
26506 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26507 + GET_THREAD_INFO(%_ASM_BX)
26508 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26509 jae bad_put_user
26510 ASM_STAC
26511 -1: movb %al,(%_ASM_CX)
26512 +
26513 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26514 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26515 + cmp %_ASM_BX,%_ASM_CX
26516 + jb 1234f
26517 + xor %ebx,%ebx
26518 +1234:
26519 +#endif
26520 +
26521 +#endif
26522 +
26523 +1: __copyuser_seg movb %al,(_DEST)
26524 xor %eax,%eax
26525 EXIT
26526 ENDPROC(__put_user_1)
26527
26528 ENTRY(__put_user_2)
26529 ENTER
26530 +
26531 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26532 + GET_THREAD_INFO(%_ASM_BX)
26533 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26534 sub $1,%_ASM_BX
26535 cmp %_ASM_BX,%_ASM_CX
26536 jae bad_put_user
26537 ASM_STAC
26538 -2: movw %ax,(%_ASM_CX)
26539 +
26540 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26541 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26542 + cmp %_ASM_BX,%_ASM_CX
26543 + jb 1234f
26544 + xor %ebx,%ebx
26545 +1234:
26546 +#endif
26547 +
26548 +#endif
26549 +
26550 +2: __copyuser_seg movw %ax,(_DEST)
26551 xor %eax,%eax
26552 EXIT
26553 ENDPROC(__put_user_2)
26554
26555 ENTRY(__put_user_4)
26556 ENTER
26557 +
26558 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26559 + GET_THREAD_INFO(%_ASM_BX)
26560 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26561 sub $3,%_ASM_BX
26562 cmp %_ASM_BX,%_ASM_CX
26563 jae bad_put_user
26564 ASM_STAC
26565 -3: movl %eax,(%_ASM_CX)
26566 +
26567 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26568 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26569 + cmp %_ASM_BX,%_ASM_CX
26570 + jb 1234f
26571 + xor %ebx,%ebx
26572 +1234:
26573 +#endif
26574 +
26575 +#endif
26576 +
26577 +3: __copyuser_seg movl %eax,(_DEST)
26578 xor %eax,%eax
26579 EXIT
26580 ENDPROC(__put_user_4)
26581
26582 ENTRY(__put_user_8)
26583 ENTER
26584 +
26585 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26586 + GET_THREAD_INFO(%_ASM_BX)
26587 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26588 sub $7,%_ASM_BX
26589 cmp %_ASM_BX,%_ASM_CX
26590 jae bad_put_user
26591 ASM_STAC
26592 -4: mov %_ASM_AX,(%_ASM_CX)
26593 +
26594 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26595 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26596 + cmp %_ASM_BX,%_ASM_CX
26597 + jb 1234f
26598 + xor %ebx,%ebx
26599 +1234:
26600 +#endif
26601 +
26602 +#endif
26603 +
26604 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26605 #ifdef CONFIG_X86_32
26606 -5: movl %edx,4(%_ASM_CX)
26607 +5: __copyuser_seg movl %edx,4(_DEST)
26608 #endif
26609 xor %eax,%eax
26610 EXIT
26611 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26612 index 1cad221..de671ee 100644
26613 --- a/arch/x86/lib/rwlock.S
26614 +++ b/arch/x86/lib/rwlock.S
26615 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26616 FRAME
26617 0: LOCK_PREFIX
26618 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26619 +
26620 +#ifdef CONFIG_PAX_REFCOUNT
26621 + jno 1234f
26622 + LOCK_PREFIX
26623 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26624 + int $4
26625 +1234:
26626 + _ASM_EXTABLE(1234b, 1234b)
26627 +#endif
26628 +
26629 1: rep; nop
26630 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26631 jne 1b
26632 LOCK_PREFIX
26633 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26634 +
26635 +#ifdef CONFIG_PAX_REFCOUNT
26636 + jno 1234f
26637 + LOCK_PREFIX
26638 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26639 + int $4
26640 +1234:
26641 + _ASM_EXTABLE(1234b, 1234b)
26642 +#endif
26643 +
26644 jnz 0b
26645 ENDFRAME
26646 + pax_force_retaddr
26647 ret
26648 CFI_ENDPROC
26649 END(__write_lock_failed)
26650 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26651 FRAME
26652 0: LOCK_PREFIX
26653 READ_LOCK_SIZE(inc) (%__lock_ptr)
26654 +
26655 +#ifdef CONFIG_PAX_REFCOUNT
26656 + jno 1234f
26657 + LOCK_PREFIX
26658 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26659 + int $4
26660 +1234:
26661 + _ASM_EXTABLE(1234b, 1234b)
26662 +#endif
26663 +
26664 1: rep; nop
26665 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26666 js 1b
26667 LOCK_PREFIX
26668 READ_LOCK_SIZE(dec) (%__lock_ptr)
26669 +
26670 +#ifdef CONFIG_PAX_REFCOUNT
26671 + jno 1234f
26672 + LOCK_PREFIX
26673 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26674 + int $4
26675 +1234:
26676 + _ASM_EXTABLE(1234b, 1234b)
26677 +#endif
26678 +
26679 js 0b
26680 ENDFRAME
26681 + pax_force_retaddr
26682 ret
26683 CFI_ENDPROC
26684 END(__read_lock_failed)
26685 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26686 index 5dff5f0..cadebf4 100644
26687 --- a/arch/x86/lib/rwsem.S
26688 +++ b/arch/x86/lib/rwsem.S
26689 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26690 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26691 CFI_RESTORE __ASM_REG(dx)
26692 restore_common_regs
26693 + pax_force_retaddr
26694 ret
26695 CFI_ENDPROC
26696 ENDPROC(call_rwsem_down_read_failed)
26697 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26698 movq %rax,%rdi
26699 call rwsem_down_write_failed
26700 restore_common_regs
26701 + pax_force_retaddr
26702 ret
26703 CFI_ENDPROC
26704 ENDPROC(call_rwsem_down_write_failed)
26705 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26706 movq %rax,%rdi
26707 call rwsem_wake
26708 restore_common_regs
26709 -1: ret
26710 +1: pax_force_retaddr
26711 + ret
26712 CFI_ENDPROC
26713 ENDPROC(call_rwsem_wake)
26714
26715 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26716 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26717 CFI_RESTORE __ASM_REG(dx)
26718 restore_common_regs
26719 + pax_force_retaddr
26720 ret
26721 CFI_ENDPROC
26722 ENDPROC(call_rwsem_downgrade_wake)
26723 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26724 index a63efd6..ccecad8 100644
26725 --- a/arch/x86/lib/thunk_64.S
26726 +++ b/arch/x86/lib/thunk_64.S
26727 @@ -8,6 +8,7 @@
26728 #include <linux/linkage.h>
26729 #include <asm/dwarf2.h>
26730 #include <asm/calling.h>
26731 +#include <asm/alternative-asm.h>
26732
26733 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26734 .macro THUNK name, func, put_ret_addr_in_rdi=0
26735 @@ -41,5 +42,6 @@
26736 SAVE_ARGS
26737 restore:
26738 RESTORE_ARGS
26739 + pax_force_retaddr
26740 ret
26741 CFI_ENDPROC
26742 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26743 index f0312d7..9c39d63 100644
26744 --- a/arch/x86/lib/usercopy_32.c
26745 +++ b/arch/x86/lib/usercopy_32.c
26746 @@ -42,11 +42,13 @@ do { \
26747 int __d0; \
26748 might_fault(); \
26749 __asm__ __volatile__( \
26750 + __COPYUSER_SET_ES \
26751 ASM_STAC "\n" \
26752 "0: rep; stosl\n" \
26753 " movl %2,%0\n" \
26754 "1: rep; stosb\n" \
26755 "2: " ASM_CLAC "\n" \
26756 + __COPYUSER_RESTORE_ES \
26757 ".section .fixup,\"ax\"\n" \
26758 "3: lea 0(%2,%0,4),%0\n" \
26759 " jmp 2b\n" \
26760 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26761
26762 #ifdef CONFIG_X86_INTEL_USERCOPY
26763 static unsigned long
26764 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26765 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26766 {
26767 int d0, d1;
26768 __asm__ __volatile__(
26769 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26770 " .align 2,0x90\n"
26771 "3: movl 0(%4), %%eax\n"
26772 "4: movl 4(%4), %%edx\n"
26773 - "5: movl %%eax, 0(%3)\n"
26774 - "6: movl %%edx, 4(%3)\n"
26775 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26776 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26777 "7: movl 8(%4), %%eax\n"
26778 "8: movl 12(%4),%%edx\n"
26779 - "9: movl %%eax, 8(%3)\n"
26780 - "10: movl %%edx, 12(%3)\n"
26781 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26782 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26783 "11: movl 16(%4), %%eax\n"
26784 "12: movl 20(%4), %%edx\n"
26785 - "13: movl %%eax, 16(%3)\n"
26786 - "14: movl %%edx, 20(%3)\n"
26787 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26788 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26789 "15: movl 24(%4), %%eax\n"
26790 "16: movl 28(%4), %%edx\n"
26791 - "17: movl %%eax, 24(%3)\n"
26792 - "18: movl %%edx, 28(%3)\n"
26793 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26794 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26795 "19: movl 32(%4), %%eax\n"
26796 "20: movl 36(%4), %%edx\n"
26797 - "21: movl %%eax, 32(%3)\n"
26798 - "22: movl %%edx, 36(%3)\n"
26799 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26800 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26801 "23: movl 40(%4), %%eax\n"
26802 "24: movl 44(%4), %%edx\n"
26803 - "25: movl %%eax, 40(%3)\n"
26804 - "26: movl %%edx, 44(%3)\n"
26805 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26806 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26807 "27: movl 48(%4), %%eax\n"
26808 "28: movl 52(%4), %%edx\n"
26809 - "29: movl %%eax, 48(%3)\n"
26810 - "30: movl %%edx, 52(%3)\n"
26811 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26812 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26813 "31: movl 56(%4), %%eax\n"
26814 "32: movl 60(%4), %%edx\n"
26815 - "33: movl %%eax, 56(%3)\n"
26816 - "34: movl %%edx, 60(%3)\n"
26817 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26818 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26819 " addl $-64, %0\n"
26820 " addl $64, %4\n"
26821 " addl $64, %3\n"
26822 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26823 " shrl $2, %0\n"
26824 " andl $3, %%eax\n"
26825 " cld\n"
26826 + __COPYUSER_SET_ES
26827 "99: rep; movsl\n"
26828 "36: movl %%eax, %0\n"
26829 "37: rep; movsb\n"
26830 "100:\n"
26831 + __COPYUSER_RESTORE_ES
26832 ".section .fixup,\"ax\"\n"
26833 "101: lea 0(%%eax,%0,4),%0\n"
26834 " jmp 100b\n"
26835 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26836 }
26837
26838 static unsigned long
26839 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26840 +{
26841 + int d0, d1;
26842 + __asm__ __volatile__(
26843 + " .align 2,0x90\n"
26844 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26845 + " cmpl $67, %0\n"
26846 + " jbe 3f\n"
26847 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26848 + " .align 2,0x90\n"
26849 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26850 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26851 + "5: movl %%eax, 0(%3)\n"
26852 + "6: movl %%edx, 4(%3)\n"
26853 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26854 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26855 + "9: movl %%eax, 8(%3)\n"
26856 + "10: movl %%edx, 12(%3)\n"
26857 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26858 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26859 + "13: movl %%eax, 16(%3)\n"
26860 + "14: movl %%edx, 20(%3)\n"
26861 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26862 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26863 + "17: movl %%eax, 24(%3)\n"
26864 + "18: movl %%edx, 28(%3)\n"
26865 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26866 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26867 + "21: movl %%eax, 32(%3)\n"
26868 + "22: movl %%edx, 36(%3)\n"
26869 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26870 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26871 + "25: movl %%eax, 40(%3)\n"
26872 + "26: movl %%edx, 44(%3)\n"
26873 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26874 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26875 + "29: movl %%eax, 48(%3)\n"
26876 + "30: movl %%edx, 52(%3)\n"
26877 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26878 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26879 + "33: movl %%eax, 56(%3)\n"
26880 + "34: movl %%edx, 60(%3)\n"
26881 + " addl $-64, %0\n"
26882 + " addl $64, %4\n"
26883 + " addl $64, %3\n"
26884 + " cmpl $63, %0\n"
26885 + " ja 1b\n"
26886 + "35: movl %0, %%eax\n"
26887 + " shrl $2, %0\n"
26888 + " andl $3, %%eax\n"
26889 + " cld\n"
26890 + "99: rep; "__copyuser_seg" movsl\n"
26891 + "36: movl %%eax, %0\n"
26892 + "37: rep; "__copyuser_seg" movsb\n"
26893 + "100:\n"
26894 + ".section .fixup,\"ax\"\n"
26895 + "101: lea 0(%%eax,%0,4),%0\n"
26896 + " jmp 100b\n"
26897 + ".previous\n"
26898 + _ASM_EXTABLE(1b,100b)
26899 + _ASM_EXTABLE(2b,100b)
26900 + _ASM_EXTABLE(3b,100b)
26901 + _ASM_EXTABLE(4b,100b)
26902 + _ASM_EXTABLE(5b,100b)
26903 + _ASM_EXTABLE(6b,100b)
26904 + _ASM_EXTABLE(7b,100b)
26905 + _ASM_EXTABLE(8b,100b)
26906 + _ASM_EXTABLE(9b,100b)
26907 + _ASM_EXTABLE(10b,100b)
26908 + _ASM_EXTABLE(11b,100b)
26909 + _ASM_EXTABLE(12b,100b)
26910 + _ASM_EXTABLE(13b,100b)
26911 + _ASM_EXTABLE(14b,100b)
26912 + _ASM_EXTABLE(15b,100b)
26913 + _ASM_EXTABLE(16b,100b)
26914 + _ASM_EXTABLE(17b,100b)
26915 + _ASM_EXTABLE(18b,100b)
26916 + _ASM_EXTABLE(19b,100b)
26917 + _ASM_EXTABLE(20b,100b)
26918 + _ASM_EXTABLE(21b,100b)
26919 + _ASM_EXTABLE(22b,100b)
26920 + _ASM_EXTABLE(23b,100b)
26921 + _ASM_EXTABLE(24b,100b)
26922 + _ASM_EXTABLE(25b,100b)
26923 + _ASM_EXTABLE(26b,100b)
26924 + _ASM_EXTABLE(27b,100b)
26925 + _ASM_EXTABLE(28b,100b)
26926 + _ASM_EXTABLE(29b,100b)
26927 + _ASM_EXTABLE(30b,100b)
26928 + _ASM_EXTABLE(31b,100b)
26929 + _ASM_EXTABLE(32b,100b)
26930 + _ASM_EXTABLE(33b,100b)
26931 + _ASM_EXTABLE(34b,100b)
26932 + _ASM_EXTABLE(35b,100b)
26933 + _ASM_EXTABLE(36b,100b)
26934 + _ASM_EXTABLE(37b,100b)
26935 + _ASM_EXTABLE(99b,101b)
26936 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26937 + : "1"(to), "2"(from), "0"(size)
26938 + : "eax", "edx", "memory");
26939 + return size;
26940 +}
26941 +
26942 +static unsigned long __size_overflow(3)
26943 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26944 {
26945 int d0, d1;
26946 __asm__ __volatile__(
26947 " .align 2,0x90\n"
26948 - "0: movl 32(%4), %%eax\n"
26949 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26950 " cmpl $67, %0\n"
26951 " jbe 2f\n"
26952 - "1: movl 64(%4), %%eax\n"
26953 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26954 " .align 2,0x90\n"
26955 - "2: movl 0(%4), %%eax\n"
26956 - "21: movl 4(%4), %%edx\n"
26957 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26958 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26959 " movl %%eax, 0(%3)\n"
26960 " movl %%edx, 4(%3)\n"
26961 - "3: movl 8(%4), %%eax\n"
26962 - "31: movl 12(%4),%%edx\n"
26963 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26964 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26965 " movl %%eax, 8(%3)\n"
26966 " movl %%edx, 12(%3)\n"
26967 - "4: movl 16(%4), %%eax\n"
26968 - "41: movl 20(%4), %%edx\n"
26969 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26970 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26971 " movl %%eax, 16(%3)\n"
26972 " movl %%edx, 20(%3)\n"
26973 - "10: movl 24(%4), %%eax\n"
26974 - "51: movl 28(%4), %%edx\n"
26975 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26976 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26977 " movl %%eax, 24(%3)\n"
26978 " movl %%edx, 28(%3)\n"
26979 - "11: movl 32(%4), %%eax\n"
26980 - "61: movl 36(%4), %%edx\n"
26981 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26982 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26983 " movl %%eax, 32(%3)\n"
26984 " movl %%edx, 36(%3)\n"
26985 - "12: movl 40(%4), %%eax\n"
26986 - "71: movl 44(%4), %%edx\n"
26987 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26988 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26989 " movl %%eax, 40(%3)\n"
26990 " movl %%edx, 44(%3)\n"
26991 - "13: movl 48(%4), %%eax\n"
26992 - "81: movl 52(%4), %%edx\n"
26993 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26994 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26995 " movl %%eax, 48(%3)\n"
26996 " movl %%edx, 52(%3)\n"
26997 - "14: movl 56(%4), %%eax\n"
26998 - "91: movl 60(%4), %%edx\n"
26999 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27000 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27001 " movl %%eax, 56(%3)\n"
27002 " movl %%edx, 60(%3)\n"
27003 " addl $-64, %0\n"
27004 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
27005 " shrl $2, %0\n"
27006 " andl $3, %%eax\n"
27007 " cld\n"
27008 - "6: rep; movsl\n"
27009 + "6: rep; "__copyuser_seg" movsl\n"
27010 " movl %%eax,%0\n"
27011 - "7: rep; movsb\n"
27012 + "7: rep; "__copyuser_seg" movsb\n"
27013 "8:\n"
27014 ".section .fixup,\"ax\"\n"
27015 "9: lea 0(%%eax,%0,4),%0\n"
27016 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
27017 * hyoshiok@miraclelinux.com
27018 */
27019
27020 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27021 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
27022 const void __user *from, unsigned long size)
27023 {
27024 int d0, d1;
27025
27026 __asm__ __volatile__(
27027 " .align 2,0x90\n"
27028 - "0: movl 32(%4), %%eax\n"
27029 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
27030 " cmpl $67, %0\n"
27031 " jbe 2f\n"
27032 - "1: movl 64(%4), %%eax\n"
27033 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
27034 " .align 2,0x90\n"
27035 - "2: movl 0(%4), %%eax\n"
27036 - "21: movl 4(%4), %%edx\n"
27037 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
27038 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
27039 " movnti %%eax, 0(%3)\n"
27040 " movnti %%edx, 4(%3)\n"
27041 - "3: movl 8(%4), %%eax\n"
27042 - "31: movl 12(%4),%%edx\n"
27043 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
27044 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
27045 " movnti %%eax, 8(%3)\n"
27046 " movnti %%edx, 12(%3)\n"
27047 - "4: movl 16(%4), %%eax\n"
27048 - "41: movl 20(%4), %%edx\n"
27049 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
27050 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
27051 " movnti %%eax, 16(%3)\n"
27052 " movnti %%edx, 20(%3)\n"
27053 - "10: movl 24(%4), %%eax\n"
27054 - "51: movl 28(%4), %%edx\n"
27055 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
27056 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
27057 " movnti %%eax, 24(%3)\n"
27058 " movnti %%edx, 28(%3)\n"
27059 - "11: movl 32(%4), %%eax\n"
27060 - "61: movl 36(%4), %%edx\n"
27061 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
27062 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
27063 " movnti %%eax, 32(%3)\n"
27064 " movnti %%edx, 36(%3)\n"
27065 - "12: movl 40(%4), %%eax\n"
27066 - "71: movl 44(%4), %%edx\n"
27067 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
27068 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
27069 " movnti %%eax, 40(%3)\n"
27070 " movnti %%edx, 44(%3)\n"
27071 - "13: movl 48(%4), %%eax\n"
27072 - "81: movl 52(%4), %%edx\n"
27073 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
27074 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
27075 " movnti %%eax, 48(%3)\n"
27076 " movnti %%edx, 52(%3)\n"
27077 - "14: movl 56(%4), %%eax\n"
27078 - "91: movl 60(%4), %%edx\n"
27079 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27080 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27081 " movnti %%eax, 56(%3)\n"
27082 " movnti %%edx, 60(%3)\n"
27083 " addl $-64, %0\n"
27084 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27085 " shrl $2, %0\n"
27086 " andl $3, %%eax\n"
27087 " cld\n"
27088 - "6: rep; movsl\n"
27089 + "6: rep; "__copyuser_seg" movsl\n"
27090 " movl %%eax,%0\n"
27091 - "7: rep; movsb\n"
27092 + "7: rep; "__copyuser_seg" movsb\n"
27093 "8:\n"
27094 ".section .fixup,\"ax\"\n"
27095 "9: lea 0(%%eax,%0,4),%0\n"
27096 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27097 return size;
27098 }
27099
27100 -static unsigned long __copy_user_intel_nocache(void *to,
27101 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
27102 const void __user *from, unsigned long size)
27103 {
27104 int d0, d1;
27105
27106 __asm__ __volatile__(
27107 " .align 2,0x90\n"
27108 - "0: movl 32(%4), %%eax\n"
27109 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
27110 " cmpl $67, %0\n"
27111 " jbe 2f\n"
27112 - "1: movl 64(%4), %%eax\n"
27113 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
27114 " .align 2,0x90\n"
27115 - "2: movl 0(%4), %%eax\n"
27116 - "21: movl 4(%4), %%edx\n"
27117 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
27118 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
27119 " movnti %%eax, 0(%3)\n"
27120 " movnti %%edx, 4(%3)\n"
27121 - "3: movl 8(%4), %%eax\n"
27122 - "31: movl 12(%4),%%edx\n"
27123 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
27124 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
27125 " movnti %%eax, 8(%3)\n"
27126 " movnti %%edx, 12(%3)\n"
27127 - "4: movl 16(%4), %%eax\n"
27128 - "41: movl 20(%4), %%edx\n"
27129 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
27130 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
27131 " movnti %%eax, 16(%3)\n"
27132 " movnti %%edx, 20(%3)\n"
27133 - "10: movl 24(%4), %%eax\n"
27134 - "51: movl 28(%4), %%edx\n"
27135 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
27136 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
27137 " movnti %%eax, 24(%3)\n"
27138 " movnti %%edx, 28(%3)\n"
27139 - "11: movl 32(%4), %%eax\n"
27140 - "61: movl 36(%4), %%edx\n"
27141 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
27142 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
27143 " movnti %%eax, 32(%3)\n"
27144 " movnti %%edx, 36(%3)\n"
27145 - "12: movl 40(%4), %%eax\n"
27146 - "71: movl 44(%4), %%edx\n"
27147 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
27148 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
27149 " movnti %%eax, 40(%3)\n"
27150 " movnti %%edx, 44(%3)\n"
27151 - "13: movl 48(%4), %%eax\n"
27152 - "81: movl 52(%4), %%edx\n"
27153 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
27154 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
27155 " movnti %%eax, 48(%3)\n"
27156 " movnti %%edx, 52(%3)\n"
27157 - "14: movl 56(%4), %%eax\n"
27158 - "91: movl 60(%4), %%edx\n"
27159 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27160 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27161 " movnti %%eax, 56(%3)\n"
27162 " movnti %%edx, 60(%3)\n"
27163 " addl $-64, %0\n"
27164 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
27165 " shrl $2, %0\n"
27166 " andl $3, %%eax\n"
27167 " cld\n"
27168 - "6: rep; movsl\n"
27169 + "6: rep; "__copyuser_seg" movsl\n"
27170 " movl %%eax,%0\n"
27171 - "7: rep; movsb\n"
27172 + "7: rep; "__copyuser_seg" movsb\n"
27173 "8:\n"
27174 ".section .fixup,\"ax\"\n"
27175 "9: lea 0(%%eax,%0,4),%0\n"
27176 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
27177 */
27178 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
27179 unsigned long size);
27180 -unsigned long __copy_user_intel(void __user *to, const void *from,
27181 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
27182 + unsigned long size);
27183 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
27184 unsigned long size);
27185 unsigned long __copy_user_zeroing_intel_nocache(void *to,
27186 const void __user *from, unsigned long size);
27187 #endif /* CONFIG_X86_INTEL_USERCOPY */
27188
27189 /* Generic arbitrary sized copy. */
27190 -#define __copy_user(to, from, size) \
27191 +#define __copy_user(to, from, size, prefix, set, restore) \
27192 do { \
27193 int __d0, __d1, __d2; \
27194 __asm__ __volatile__( \
27195 + set \
27196 " cmp $7,%0\n" \
27197 " jbe 1f\n" \
27198 " movl %1,%0\n" \
27199 " negl %0\n" \
27200 " andl $7,%0\n" \
27201 " subl %0,%3\n" \
27202 - "4: rep; movsb\n" \
27203 + "4: rep; "prefix"movsb\n" \
27204 " movl %3,%0\n" \
27205 " shrl $2,%0\n" \
27206 " andl $3,%3\n" \
27207 " .align 2,0x90\n" \
27208 - "0: rep; movsl\n" \
27209 + "0: rep; "prefix"movsl\n" \
27210 " movl %3,%0\n" \
27211 - "1: rep; movsb\n" \
27212 + "1: rep; "prefix"movsb\n" \
27213 "2:\n" \
27214 + restore \
27215 ".section .fixup,\"ax\"\n" \
27216 "5: addl %3,%0\n" \
27217 " jmp 2b\n" \
27218 @@ -538,14 +650,14 @@ do { \
27219 " negl %0\n" \
27220 " andl $7,%0\n" \
27221 " subl %0,%3\n" \
27222 - "4: rep; movsb\n" \
27223 + "4: rep; "__copyuser_seg"movsb\n" \
27224 " movl %3,%0\n" \
27225 " shrl $2,%0\n" \
27226 " andl $3,%3\n" \
27227 " .align 2,0x90\n" \
27228 - "0: rep; movsl\n" \
27229 + "0: rep; "__copyuser_seg"movsl\n" \
27230 " movl %3,%0\n" \
27231 - "1: rep; movsb\n" \
27232 + "1: rep; "__copyuser_seg"movsb\n" \
27233 "2:\n" \
27234 ".section .fixup,\"ax\"\n" \
27235 "5: addl %3,%0\n" \
27236 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
27237 {
27238 stac();
27239 if (movsl_is_ok(to, from, n))
27240 - __copy_user(to, from, n);
27241 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
27242 else
27243 - n = __copy_user_intel(to, from, n);
27244 + n = __generic_copy_to_user_intel(to, from, n);
27245 clac();
27246 return n;
27247 }
27248 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
27249 {
27250 stac();
27251 if (movsl_is_ok(to, from, n))
27252 - __copy_user(to, from, n);
27253 + __copy_user(to, from, n, __copyuser_seg, "", "");
27254 else
27255 - n = __copy_user_intel((void __user *)to,
27256 - (const void *)from, n);
27257 + n = __generic_copy_from_user_intel(to, from, n);
27258 clac();
27259 return n;
27260 }
27261 @@ -632,66 +743,51 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
27262 if (n > 64 && cpu_has_xmm2)
27263 n = __copy_user_intel_nocache(to, from, n);
27264 else
27265 - __copy_user(to, from, n);
27266 + __copy_user(to, from, n, __copyuser_seg, "", "");
27267 #else
27268 - __copy_user(to, from, n);
27269 + __copy_user(to, from, n, __copyuser_seg, "", "");
27270 #endif
27271 clac();
27272 return n;
27273 }
27274 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
27275
27276 -/**
27277 - * copy_to_user: - Copy a block of data into user space.
27278 - * @to: Destination address, in user space.
27279 - * @from: Source address, in kernel space.
27280 - * @n: Number of bytes to copy.
27281 - *
27282 - * Context: User context only. This function may sleep.
27283 - *
27284 - * Copy data from kernel space to user space.
27285 - *
27286 - * Returns number of bytes that could not be copied.
27287 - * On success, this will be zero.
27288 - */
27289 -unsigned long
27290 -copy_to_user(void __user *to, const void *from, unsigned long n)
27291 -{
27292 - if (access_ok(VERIFY_WRITE, to, n))
27293 - n = __copy_to_user(to, from, n);
27294 - return n;
27295 -}
27296 -EXPORT_SYMBOL(copy_to_user);
27297 -
27298 -/**
27299 - * copy_from_user: - Copy a block of data from user space.
27300 - * @to: Destination address, in kernel space.
27301 - * @from: Source address, in user space.
27302 - * @n: Number of bytes to copy.
27303 - *
27304 - * Context: User context only. This function may sleep.
27305 - *
27306 - * Copy data from user space to kernel space.
27307 - *
27308 - * Returns number of bytes that could not be copied.
27309 - * On success, this will be zero.
27310 - *
27311 - * If some data could not be copied, this function will pad the copied
27312 - * data to the requested size using zero bytes.
27313 - */
27314 -unsigned long
27315 -_copy_from_user(void *to, const void __user *from, unsigned long n)
27316 -{
27317 - if (access_ok(VERIFY_READ, from, n))
27318 - n = __copy_from_user(to, from, n);
27319 - else
27320 - memset(to, 0, n);
27321 - return n;
27322 -}
27323 -EXPORT_SYMBOL(_copy_from_user);
27324 -
27325 void copy_from_user_overflow(void)
27326 {
27327 WARN(1, "Buffer overflow detected!\n");
27328 }
27329 EXPORT_SYMBOL(copy_from_user_overflow);
27330 +
27331 +void copy_to_user_overflow(void)
27332 +{
27333 + WARN(1, "Buffer overflow detected!\n");
27334 +}
27335 +EXPORT_SYMBOL(copy_to_user_overflow);
27336 +
27337 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27338 +void __set_fs(mm_segment_t x)
27339 +{
27340 + switch (x.seg) {
27341 + case 0:
27342 + loadsegment(gs, 0);
27343 + break;
27344 + case TASK_SIZE_MAX:
27345 + loadsegment(gs, __USER_DS);
27346 + break;
27347 + case -1UL:
27348 + loadsegment(gs, __KERNEL_DS);
27349 + break;
27350 + default:
27351 + BUG();
27352 + }
27353 + return;
27354 +}
27355 +EXPORT_SYMBOL(__set_fs);
27356 +
27357 +void set_fs(mm_segment_t x)
27358 +{
27359 + current_thread_info()->addr_limit = x;
27360 + __set_fs(x);
27361 +}
27362 +EXPORT_SYMBOL(set_fs);
27363 +#endif
27364 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
27365 index 906fea3..ee8a097 100644
27366 --- a/arch/x86/lib/usercopy_64.c
27367 +++ b/arch/x86/lib/usercopy_64.c
27368 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
27369 _ASM_EXTABLE(0b,3b)
27370 _ASM_EXTABLE(1b,2b)
27371 : [size8] "=&c"(size), [dst] "=&D" (__d0)
27372 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
27373 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
27374 [zero] "r" (0UL), [eight] "r" (8UL));
27375 clac();
27376 return size;
27377 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
27378 }
27379 EXPORT_SYMBOL(clear_user);
27380
27381 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
27382 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
27383 {
27384 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
27385 - return copy_user_generic((__force void *)to, (__force void *)from, len);
27386 - }
27387 - return len;
27388 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
27389 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
27390 + return len;
27391 }
27392 EXPORT_SYMBOL(copy_in_user);
27393
27394 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
27395 * it is not necessary to optimize tail handling.
27396 */
27397 unsigned long
27398 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27399 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
27400 {
27401 char c;
27402 unsigned zero_len;
27403 @@ -87,3 +86,15 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27404 clac();
27405 return len;
27406 }
27407 +
27408 +void copy_from_user_overflow(void)
27409 +{
27410 + WARN(1, "Buffer overflow detected!\n");
27411 +}
27412 +EXPORT_SYMBOL(copy_from_user_overflow);
27413 +
27414 +void copy_to_user_overflow(void)
27415 +{
27416 + WARN(1, "Buffer overflow detected!\n");
27417 +}
27418 +EXPORT_SYMBOL(copy_to_user_overflow);
27419 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27420 index 903ec1e..c4166b2 100644
27421 --- a/arch/x86/mm/extable.c
27422 +++ b/arch/x86/mm/extable.c
27423 @@ -6,12 +6,24 @@
27424 static inline unsigned long
27425 ex_insn_addr(const struct exception_table_entry *x)
27426 {
27427 - return (unsigned long)&x->insn + x->insn;
27428 + unsigned long reloc = 0;
27429 +
27430 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27431 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27432 +#endif
27433 +
27434 + return (unsigned long)&x->insn + x->insn + reloc;
27435 }
27436 static inline unsigned long
27437 ex_fixup_addr(const struct exception_table_entry *x)
27438 {
27439 - return (unsigned long)&x->fixup + x->fixup;
27440 + unsigned long reloc = 0;
27441 +
27442 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27443 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27444 +#endif
27445 +
27446 + return (unsigned long)&x->fixup + x->fixup + reloc;
27447 }
27448
27449 int fixup_exception(struct pt_regs *regs)
27450 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
27451 unsigned long new_ip;
27452
27453 #ifdef CONFIG_PNPBIOS
27454 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
27455 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
27456 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
27457 extern u32 pnp_bios_is_utter_crap;
27458 pnp_bios_is_utter_crap = 1;
27459 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
27460 i += 4;
27461 p->fixup -= i;
27462 i += 4;
27463 +
27464 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27465 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
27466 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27467 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27468 +#endif
27469 +
27470 }
27471 }
27472
27473 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
27474 index fb674fd..223a693 100644
27475 --- a/arch/x86/mm/fault.c
27476 +++ b/arch/x86/mm/fault.c
27477 @@ -13,12 +13,19 @@
27478 #include <linux/perf_event.h> /* perf_sw_event */
27479 #include <linux/hugetlb.h> /* hstate_index_to_shift */
27480 #include <linux/prefetch.h> /* prefetchw */
27481 +#include <linux/unistd.h>
27482 +#include <linux/compiler.h>
27483
27484 #include <asm/traps.h> /* dotraplinkage, ... */
27485 #include <asm/pgalloc.h> /* pgd_*(), ... */
27486 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
27487 #include <asm/fixmap.h> /* VSYSCALL_START */
27488 #include <asm/context_tracking.h> /* exception_enter(), ... */
27489 +#include <asm/tlbflush.h>
27490 +
27491 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27492 +#include <asm/stacktrace.h>
27493 +#endif
27494
27495 /*
27496 * Page fault error code bits:
27497 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
27498 int ret = 0;
27499
27500 /* kprobe_running() needs smp_processor_id() */
27501 - if (kprobes_built_in() && !user_mode_vm(regs)) {
27502 + if (kprobes_built_in() && !user_mode(regs)) {
27503 preempt_disable();
27504 if (kprobe_running() && kprobe_fault_handler(regs, 14))
27505 ret = 1;
27506 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27507 return !instr_lo || (instr_lo>>1) == 1;
27508 case 0x00:
27509 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27510 - if (probe_kernel_address(instr, opcode))
27511 + if (user_mode(regs)) {
27512 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27513 + return 0;
27514 + } else if (probe_kernel_address(instr, opcode))
27515 return 0;
27516
27517 *prefetch = (instr_lo == 0xF) &&
27518 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27519 while (instr < max_instr) {
27520 unsigned char opcode;
27521
27522 - if (probe_kernel_address(instr, opcode))
27523 + if (user_mode(regs)) {
27524 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27525 + break;
27526 + } else if (probe_kernel_address(instr, opcode))
27527 break;
27528
27529 instr++;
27530 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27531 force_sig_info(si_signo, &info, tsk);
27532 }
27533
27534 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27535 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27536 +#endif
27537 +
27538 +#ifdef CONFIG_PAX_EMUTRAMP
27539 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27540 +#endif
27541 +
27542 +#ifdef CONFIG_PAX_PAGEEXEC
27543 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27544 +{
27545 + pgd_t *pgd;
27546 + pud_t *pud;
27547 + pmd_t *pmd;
27548 +
27549 + pgd = pgd_offset(mm, address);
27550 + if (!pgd_present(*pgd))
27551 + return NULL;
27552 + pud = pud_offset(pgd, address);
27553 + if (!pud_present(*pud))
27554 + return NULL;
27555 + pmd = pmd_offset(pud, address);
27556 + if (!pmd_present(*pmd))
27557 + return NULL;
27558 + return pmd;
27559 +}
27560 +#endif
27561 +
27562 DEFINE_SPINLOCK(pgd_lock);
27563 LIST_HEAD(pgd_list);
27564
27565 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27566 for (address = VMALLOC_START & PMD_MASK;
27567 address >= TASK_SIZE && address < FIXADDR_TOP;
27568 address += PMD_SIZE) {
27569 +
27570 +#ifdef CONFIG_PAX_PER_CPU_PGD
27571 + unsigned long cpu;
27572 +#else
27573 struct page *page;
27574 +#endif
27575
27576 spin_lock(&pgd_lock);
27577 +
27578 +#ifdef CONFIG_PAX_PER_CPU_PGD
27579 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27580 + pgd_t *pgd = get_cpu_pgd(cpu);
27581 + pmd_t *ret;
27582 +#else
27583 list_for_each_entry(page, &pgd_list, lru) {
27584 + pgd_t *pgd;
27585 spinlock_t *pgt_lock;
27586 pmd_t *ret;
27587
27588 @@ -243,8 +296,14 @@ void vmalloc_sync_all(void)
27589 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27590
27591 spin_lock(pgt_lock);
27592 - ret = vmalloc_sync_one(page_address(page), address);
27593 + pgd = page_address(page);
27594 +#endif
27595 +
27596 + ret = vmalloc_sync_one(pgd, address);
27597 +
27598 +#ifndef CONFIG_PAX_PER_CPU_PGD
27599 spin_unlock(pgt_lock);
27600 +#endif
27601
27602 if (!ret)
27603 break;
27604 @@ -278,6 +337,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27605 * an interrupt in the middle of a task switch..
27606 */
27607 pgd_paddr = read_cr3();
27608 +
27609 +#ifdef CONFIG_PAX_PER_CPU_PGD
27610 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27611 +#endif
27612 +
27613 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27614 if (!pmd_k)
27615 return -1;
27616 @@ -373,7 +437,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27617 * happen within a race in page table update. In the later
27618 * case just flush:
27619 */
27620 +
27621 +#ifdef CONFIG_PAX_PER_CPU_PGD
27622 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27623 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27624 +#else
27625 pgd = pgd_offset(current->active_mm, address);
27626 +#endif
27627 +
27628 pgd_ref = pgd_offset_k(address);
27629 if (pgd_none(*pgd_ref))
27630 return -1;
27631 @@ -541,7 +612,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27632 static int is_errata100(struct pt_regs *regs, unsigned long address)
27633 {
27634 #ifdef CONFIG_X86_64
27635 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27636 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27637 return 1;
27638 #endif
27639 return 0;
27640 @@ -568,7 +639,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27641 }
27642
27643 static const char nx_warning[] = KERN_CRIT
27644 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27645 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27646
27647 static void
27648 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27649 @@ -577,15 +648,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27650 if (!oops_may_print())
27651 return;
27652
27653 - if (error_code & PF_INSTR) {
27654 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27655 unsigned int level;
27656
27657 pte_t *pte = lookup_address(address, &level);
27658
27659 if (pte && pte_present(*pte) && !pte_exec(*pte))
27660 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27661 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27662 }
27663
27664 +#ifdef CONFIG_PAX_KERNEXEC
27665 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27666 + if (current->signal->curr_ip)
27667 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27668 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27669 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27670 + else
27671 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27672 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27673 + }
27674 +#endif
27675 +
27676 printk(KERN_ALERT "BUG: unable to handle kernel ");
27677 if (address < PAGE_SIZE)
27678 printk(KERN_CONT "NULL pointer dereference");
27679 @@ -748,6 +831,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27680 return;
27681 }
27682 #endif
27683 +
27684 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27685 + if (pax_is_fetch_fault(regs, error_code, address)) {
27686 +
27687 +#ifdef CONFIG_PAX_EMUTRAMP
27688 + switch (pax_handle_fetch_fault(regs)) {
27689 + case 2:
27690 + return;
27691 + }
27692 +#endif
27693 +
27694 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27695 + do_group_exit(SIGKILL);
27696 + }
27697 +#endif
27698 +
27699 /* Kernel addresses are always protection faults: */
27700 if (address >= TASK_SIZE)
27701 error_code |= PF_PROT;
27702 @@ -833,7 +932,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27703 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27704 printk(KERN_ERR
27705 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27706 - tsk->comm, tsk->pid, address);
27707 + tsk->comm, task_pid_nr(tsk), address);
27708 code = BUS_MCEERR_AR;
27709 }
27710 #endif
27711 @@ -896,6 +995,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27712 return 1;
27713 }
27714
27715 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27716 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27717 +{
27718 + pte_t *pte;
27719 + pmd_t *pmd;
27720 + spinlock_t *ptl;
27721 + unsigned char pte_mask;
27722 +
27723 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27724 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27725 + return 0;
27726 +
27727 + /* PaX: it's our fault, let's handle it if we can */
27728 +
27729 + /* PaX: take a look at read faults before acquiring any locks */
27730 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27731 + /* instruction fetch attempt from a protected page in user mode */
27732 + up_read(&mm->mmap_sem);
27733 +
27734 +#ifdef CONFIG_PAX_EMUTRAMP
27735 + switch (pax_handle_fetch_fault(regs)) {
27736 + case 2:
27737 + return 1;
27738 + }
27739 +#endif
27740 +
27741 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27742 + do_group_exit(SIGKILL);
27743 + }
27744 +
27745 + pmd = pax_get_pmd(mm, address);
27746 + if (unlikely(!pmd))
27747 + return 0;
27748 +
27749 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27750 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27751 + pte_unmap_unlock(pte, ptl);
27752 + return 0;
27753 + }
27754 +
27755 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27756 + /* write attempt to a protected page in user mode */
27757 + pte_unmap_unlock(pte, ptl);
27758 + return 0;
27759 + }
27760 +
27761 +#ifdef CONFIG_SMP
27762 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27763 +#else
27764 + if (likely(address > get_limit(regs->cs)))
27765 +#endif
27766 + {
27767 + set_pte(pte, pte_mkread(*pte));
27768 + __flush_tlb_one(address);
27769 + pte_unmap_unlock(pte, ptl);
27770 + up_read(&mm->mmap_sem);
27771 + return 1;
27772 + }
27773 +
27774 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27775 +
27776 + /*
27777 + * PaX: fill DTLB with user rights and retry
27778 + */
27779 + __asm__ __volatile__ (
27780 + "orb %2,(%1)\n"
27781 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27782 +/*
27783 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27784 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27785 + * page fault when examined during a TLB load attempt. this is true not only
27786 + * for PTEs holding a non-present entry but also present entries that will
27787 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27788 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27789 + * for our target pages since their PTEs are simply not in the TLBs at all.
27790 +
27791 + * the best thing in omitting it is that we gain around 15-20% speed in the
27792 + * fast path of the page fault handler and can get rid of tracing since we
27793 + * can no longer flush unintended entries.
27794 + */
27795 + "invlpg (%0)\n"
27796 +#endif
27797 + __copyuser_seg"testb $0,(%0)\n"
27798 + "xorb %3,(%1)\n"
27799 + :
27800 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27801 + : "memory", "cc");
27802 + pte_unmap_unlock(pte, ptl);
27803 + up_read(&mm->mmap_sem);
27804 + return 1;
27805 +}
27806 +#endif
27807 +
27808 /*
27809 * Handle a spurious fault caused by a stale TLB entry.
27810 *
27811 @@ -968,6 +1160,9 @@ int show_unhandled_signals = 1;
27812 static inline int
27813 access_error(unsigned long error_code, struct vm_area_struct *vma)
27814 {
27815 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27816 + return 1;
27817 +
27818 if (error_code & PF_WRITE) {
27819 /* write, present and write, not present: */
27820 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27821 @@ -996,7 +1191,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27822 if (error_code & PF_USER)
27823 return false;
27824
27825 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27826 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27827 return false;
27828
27829 return true;
27830 @@ -1012,18 +1207,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27831 {
27832 struct vm_area_struct *vma;
27833 struct task_struct *tsk;
27834 - unsigned long address;
27835 struct mm_struct *mm;
27836 int fault;
27837 int write = error_code & PF_WRITE;
27838 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27839 (write ? FAULT_FLAG_WRITE : 0);
27840
27841 - tsk = current;
27842 - mm = tsk->mm;
27843 -
27844 /* Get the faulting address: */
27845 - address = read_cr2();
27846 + unsigned long address = read_cr2();
27847 +
27848 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27849 + if (!user_mode(regs) && address < 2 * PAX_USER_SHADOW_BASE) {
27850 + if (!search_exception_tables(regs->ip)) {
27851 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27852 + bad_area_nosemaphore(regs, error_code, address);
27853 + return;
27854 + }
27855 + if (address < PAX_USER_SHADOW_BASE) {
27856 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27857 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27858 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27859 + } else
27860 + address -= PAX_USER_SHADOW_BASE;
27861 + }
27862 +#endif
27863 +
27864 + tsk = current;
27865 + mm = tsk->mm;
27866
27867 /*
27868 * Detect and handle instructions that would cause a page fault for
27869 @@ -1084,7 +1294,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27870 * User-mode registers count as a user access even for any
27871 * potential system fault or CPU buglet:
27872 */
27873 - if (user_mode_vm(regs)) {
27874 + if (user_mode(regs)) {
27875 local_irq_enable();
27876 error_code |= PF_USER;
27877 } else {
27878 @@ -1146,6 +1356,11 @@ retry:
27879 might_sleep();
27880 }
27881
27882 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27883 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27884 + return;
27885 +#endif
27886 +
27887 vma = find_vma(mm, address);
27888 if (unlikely(!vma)) {
27889 bad_area(regs, error_code, address);
27890 @@ -1157,18 +1372,24 @@ retry:
27891 bad_area(regs, error_code, address);
27892 return;
27893 }
27894 - if (error_code & PF_USER) {
27895 - /*
27896 - * Accessing the stack below %sp is always a bug.
27897 - * The large cushion allows instructions like enter
27898 - * and pusha to work. ("enter $65535, $31" pushes
27899 - * 32 pointers and then decrements %sp by 65535.)
27900 - */
27901 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27902 - bad_area(regs, error_code, address);
27903 - return;
27904 - }
27905 + /*
27906 + * Accessing the stack below %sp is always a bug.
27907 + * The large cushion allows instructions like enter
27908 + * and pusha to work. ("enter $65535, $31" pushes
27909 + * 32 pointers and then decrements %sp by 65535.)
27910 + */
27911 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27912 + bad_area(regs, error_code, address);
27913 + return;
27914 }
27915 +
27916 +#ifdef CONFIG_PAX_SEGMEXEC
27917 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27918 + bad_area(regs, error_code, address);
27919 + return;
27920 + }
27921 +#endif
27922 +
27923 if (unlikely(expand_stack(vma, address))) {
27924 bad_area(regs, error_code, address);
27925 return;
27926 @@ -1232,3 +1453,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27927 __do_page_fault(regs, error_code);
27928 exception_exit(regs);
27929 }
27930 +
27931 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27932 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27933 +{
27934 + struct mm_struct *mm = current->mm;
27935 + unsigned long ip = regs->ip;
27936 +
27937 + if (v8086_mode(regs))
27938 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27939 +
27940 +#ifdef CONFIG_PAX_PAGEEXEC
27941 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27942 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27943 + return true;
27944 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27945 + return true;
27946 + return false;
27947 + }
27948 +#endif
27949 +
27950 +#ifdef CONFIG_PAX_SEGMEXEC
27951 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
27952 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
27953 + return true;
27954 + return false;
27955 + }
27956 +#endif
27957 +
27958 + return false;
27959 +}
27960 +#endif
27961 +
27962 +#ifdef CONFIG_PAX_EMUTRAMP
27963 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
27964 +{
27965 + int err;
27966 +
27967 + do { /* PaX: libffi trampoline emulation */
27968 + unsigned char mov, jmp;
27969 + unsigned int addr1, addr2;
27970 +
27971 +#ifdef CONFIG_X86_64
27972 + if ((regs->ip + 9) >> 32)
27973 + break;
27974 +#endif
27975 +
27976 + err = get_user(mov, (unsigned char __user *)regs->ip);
27977 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27978 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27979 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27980 +
27981 + if (err)
27982 + break;
27983 +
27984 + if (mov == 0xB8 && jmp == 0xE9) {
27985 + regs->ax = addr1;
27986 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27987 + return 2;
27988 + }
27989 + } while (0);
27990 +
27991 + do { /* PaX: gcc trampoline emulation #1 */
27992 + unsigned char mov1, mov2;
27993 + unsigned short jmp;
27994 + unsigned int addr1, addr2;
27995 +
27996 +#ifdef CONFIG_X86_64
27997 + if ((regs->ip + 11) >> 32)
27998 + break;
27999 +#endif
28000 +
28001 + err = get_user(mov1, (unsigned char __user *)regs->ip);
28002 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
28003 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
28004 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
28005 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
28006 +
28007 + if (err)
28008 + break;
28009 +
28010 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
28011 + regs->cx = addr1;
28012 + regs->ax = addr2;
28013 + regs->ip = addr2;
28014 + return 2;
28015 + }
28016 + } while (0);
28017 +
28018 + do { /* PaX: gcc trampoline emulation #2 */
28019 + unsigned char mov, jmp;
28020 + unsigned int addr1, addr2;
28021 +
28022 +#ifdef CONFIG_X86_64
28023 + if ((regs->ip + 9) >> 32)
28024 + break;
28025 +#endif
28026 +
28027 + err = get_user(mov, (unsigned char __user *)regs->ip);
28028 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
28029 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
28030 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
28031 +
28032 + if (err)
28033 + break;
28034 +
28035 + if (mov == 0xB9 && jmp == 0xE9) {
28036 + regs->cx = addr1;
28037 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
28038 + return 2;
28039 + }
28040 + } while (0);
28041 +
28042 + return 1; /* PaX in action */
28043 +}
28044 +
28045 +#ifdef CONFIG_X86_64
28046 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
28047 +{
28048 + int err;
28049 +
28050 + do { /* PaX: libffi trampoline emulation */
28051 + unsigned short mov1, mov2, jmp1;
28052 + unsigned char stcclc, jmp2;
28053 + unsigned long addr1, addr2;
28054 +
28055 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28056 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
28057 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
28058 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
28059 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
28060 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
28061 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
28062 +
28063 + if (err)
28064 + break;
28065 +
28066 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28067 + regs->r11 = addr1;
28068 + regs->r10 = addr2;
28069 + if (stcclc == 0xF8)
28070 + regs->flags &= ~X86_EFLAGS_CF;
28071 + else
28072 + regs->flags |= X86_EFLAGS_CF;
28073 + regs->ip = addr1;
28074 + return 2;
28075 + }
28076 + } while (0);
28077 +
28078 + do { /* PaX: gcc trampoline emulation #1 */
28079 + unsigned short mov1, mov2, jmp1;
28080 + unsigned char jmp2;
28081 + unsigned int addr1;
28082 + unsigned long addr2;
28083 +
28084 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28085 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
28086 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
28087 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
28088 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
28089 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
28090 +
28091 + if (err)
28092 + break;
28093 +
28094 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28095 + regs->r11 = addr1;
28096 + regs->r10 = addr2;
28097 + regs->ip = addr1;
28098 + return 2;
28099 + }
28100 + } while (0);
28101 +
28102 + do { /* PaX: gcc trampoline emulation #2 */
28103 + unsigned short mov1, mov2, jmp1;
28104 + unsigned char 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(jmp1, (unsigned short __user *)(regs->ip + 20));
28112 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
28113 +
28114 + if (err)
28115 + break;
28116 +
28117 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28118 + regs->r11 = addr1;
28119 + regs->r10 = addr2;
28120 + regs->ip = addr1;
28121 + return 2;
28122 + }
28123 + } while (0);
28124 +
28125 + return 1; /* PaX in action */
28126 +}
28127 +#endif
28128 +
28129 +/*
28130 + * PaX: decide what to do with offenders (regs->ip = fault address)
28131 + *
28132 + * returns 1 when task should be killed
28133 + * 2 when gcc trampoline was detected
28134 + */
28135 +static int pax_handle_fetch_fault(struct pt_regs *regs)
28136 +{
28137 + if (v8086_mode(regs))
28138 + return 1;
28139 +
28140 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
28141 + return 1;
28142 +
28143 +#ifdef CONFIG_X86_32
28144 + return pax_handle_fetch_fault_32(regs);
28145 +#else
28146 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
28147 + return pax_handle_fetch_fault_32(regs);
28148 + else
28149 + return pax_handle_fetch_fault_64(regs);
28150 +#endif
28151 +}
28152 +#endif
28153 +
28154 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28155 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
28156 +{
28157 + long i;
28158 +
28159 + printk(KERN_ERR "PAX: bytes at PC: ");
28160 + for (i = 0; i < 20; i++) {
28161 + unsigned char c;
28162 + if (get_user(c, (unsigned char __force_user *)pc+i))
28163 + printk(KERN_CONT "?? ");
28164 + else
28165 + printk(KERN_CONT "%02x ", c);
28166 + }
28167 + printk("\n");
28168 +
28169 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
28170 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
28171 + unsigned long c;
28172 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
28173 +#ifdef CONFIG_X86_32
28174 + printk(KERN_CONT "???????? ");
28175 +#else
28176 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
28177 + printk(KERN_CONT "???????? ???????? ");
28178 + else
28179 + printk(KERN_CONT "???????????????? ");
28180 +#endif
28181 + } else {
28182 +#ifdef CONFIG_X86_64
28183 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
28184 + printk(KERN_CONT "%08x ", (unsigned int)c);
28185 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
28186 + } else
28187 +#endif
28188 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
28189 + }
28190 + }
28191 + printk("\n");
28192 +}
28193 +#endif
28194 +
28195 +/**
28196 + * probe_kernel_write(): safely attempt to write to a location
28197 + * @dst: address to write to
28198 + * @src: pointer to the data that shall be written
28199 + * @size: size of the data chunk
28200 + *
28201 + * Safely write to address @dst from the buffer at @src. If a kernel fault
28202 + * happens, handle that and return -EFAULT.
28203 + */
28204 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
28205 +{
28206 + long ret;
28207 + mm_segment_t old_fs = get_fs();
28208 +
28209 + set_fs(KERNEL_DS);
28210 + pagefault_disable();
28211 + pax_open_kernel();
28212 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
28213 + pax_close_kernel();
28214 + pagefault_enable();
28215 + set_fs(old_fs);
28216 +
28217 + return ret ? -EFAULT : 0;
28218 +}
28219 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
28220 index dd74e46..7d26398 100644
28221 --- a/arch/x86/mm/gup.c
28222 +++ b/arch/x86/mm/gup.c
28223 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
28224 addr = start;
28225 len = (unsigned long) nr_pages << PAGE_SHIFT;
28226 end = start + len;
28227 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
28228 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
28229 (void __user *)start, len)))
28230 return 0;
28231
28232 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
28233 index 6f31ee5..8ee4164 100644
28234 --- a/arch/x86/mm/highmem_32.c
28235 +++ b/arch/x86/mm/highmem_32.c
28236 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
28237 idx = type + KM_TYPE_NR*smp_processor_id();
28238 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28239 BUG_ON(!pte_none(*(kmap_pte-idx)));
28240 +
28241 + pax_open_kernel();
28242 set_pte(kmap_pte-idx, mk_pte(page, prot));
28243 + pax_close_kernel();
28244 +
28245 arch_flush_lazy_mmu_mode();
28246
28247 return (void *)vaddr;
28248 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
28249 index ae1aa71..56316db 100644
28250 --- a/arch/x86/mm/hugetlbpage.c
28251 +++ b/arch/x86/mm/hugetlbpage.c
28252 @@ -279,6 +279,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
28253 info.flags = 0;
28254 info.length = len;
28255 info.low_limit = TASK_UNMAPPED_BASE;
28256 +
28257 +#ifdef CONFIG_PAX_RANDMMAP
28258 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28259 + info.low_limit += current->mm->delta_mmap;
28260 +#endif
28261 +
28262 info.high_limit = TASK_SIZE;
28263 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28264 info.align_offset = 0;
28265 @@ -311,6 +317,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28266 VM_BUG_ON(addr != -ENOMEM);
28267 info.flags = 0;
28268 info.low_limit = TASK_UNMAPPED_BASE;
28269 +
28270 +#ifdef CONFIG_PAX_RANDMMAP
28271 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28272 + info.low_limit += current->mm->delta_mmap;
28273 +#endif
28274 +
28275 info.high_limit = TASK_SIZE;
28276 addr = vm_unmapped_area(&info);
28277 }
28278 @@ -325,10 +337,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28279 struct hstate *h = hstate_file(file);
28280 struct mm_struct *mm = current->mm;
28281 struct vm_area_struct *vma;
28282 + unsigned long pax_task_size = TASK_SIZE;
28283 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
28284
28285 if (len & ~huge_page_mask(h))
28286 return -EINVAL;
28287 - if (len > TASK_SIZE)
28288 +
28289 +#ifdef CONFIG_PAX_SEGMEXEC
28290 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28291 + pax_task_size = SEGMEXEC_TASK_SIZE;
28292 +#endif
28293 +
28294 + pax_task_size -= PAGE_SIZE;
28295 +
28296 + if (len > pax_task_size)
28297 return -ENOMEM;
28298
28299 if (flags & MAP_FIXED) {
28300 @@ -337,11 +359,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28301 return addr;
28302 }
28303
28304 +#ifdef CONFIG_PAX_RANDMMAP
28305 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28306 +#endif
28307 +
28308 if (addr) {
28309 addr = ALIGN(addr, huge_page_size(h));
28310 vma = find_vma(mm, addr);
28311 - if (TASK_SIZE - len >= addr &&
28312 - (!vma || addr + len <= vma->vm_start))
28313 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28314 return addr;
28315 }
28316 if (mm->get_unmapped_area == arch_get_unmapped_area)
28317 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
28318 index d7aea41..0fc945b 100644
28319 --- a/arch/x86/mm/init.c
28320 +++ b/arch/x86/mm/init.c
28321 @@ -4,6 +4,7 @@
28322 #include <linux/swap.h>
28323 #include <linux/memblock.h>
28324 #include <linux/bootmem.h> /* for max_low_pfn */
28325 +#include <linux/tboot.h>
28326
28327 #include <asm/cacheflush.h>
28328 #include <asm/e820.h>
28329 @@ -16,6 +17,8 @@
28330 #include <asm/tlb.h>
28331 #include <asm/proto.h>
28332 #include <asm/dma.h> /* for MAX_DMA_PFN */
28333 +#include <asm/desc.h>
28334 +#include <asm/bios_ebda.h>
28335
28336 unsigned long __initdata pgt_buf_start;
28337 unsigned long __meminitdata pgt_buf_end;
28338 @@ -44,7 +47,7 @@ static void __init find_early_table_space(struct map_range *mr, int nr_range)
28339 {
28340 int i;
28341 unsigned long puds = 0, pmds = 0, ptes = 0, tables;
28342 - unsigned long start = 0, good_end;
28343 + unsigned long start = 0x100000, good_end;
28344 phys_addr_t base;
28345
28346 for (i = 0; i < nr_range; i++) {
28347 @@ -321,10 +324,40 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
28348 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
28349 * mmio resources as well as potential bios/acpi data regions.
28350 */
28351 +
28352 +#ifdef CONFIG_GRKERNSEC_KMEM
28353 +static unsigned int ebda_start __read_only;
28354 +static unsigned int ebda_end __read_only;
28355 +#endif
28356 +
28357 int devmem_is_allowed(unsigned long pagenr)
28358 {
28359 - if (pagenr < 256)
28360 +#ifdef CONFIG_GRKERNSEC_KMEM
28361 + /* allow BDA */
28362 + if (!pagenr)
28363 return 1;
28364 + /* allow EBDA */
28365 + if (pagenr >= ebda_start && pagenr < ebda_end)
28366 + return 1;
28367 + /* if tboot is in use, allow access to its hardcoded serial log range */
28368 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
28369 + return 1;
28370 +#else
28371 + if (!pagenr)
28372 + return 1;
28373 +#ifdef CONFIG_VM86
28374 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
28375 + return 1;
28376 +#endif
28377 +#endif
28378 +
28379 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
28380 + return 1;
28381 +#ifdef CONFIG_GRKERNSEC_KMEM
28382 + /* throw out everything else below 1MB */
28383 + if (pagenr <= 256)
28384 + return 0;
28385 +#endif
28386 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28387 return 0;
28388 if (!page_is_ram(pagenr))
28389 @@ -381,8 +414,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28390 #endif
28391 }
28392
28393 +#ifdef CONFIG_GRKERNSEC_KMEM
28394 +static inline void gr_init_ebda(void)
28395 +{
28396 + unsigned int ebda_addr;
28397 + unsigned int ebda_size = 0;
28398 +
28399 + ebda_addr = get_bios_ebda();
28400 + if (ebda_addr) {
28401 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28402 + ebda_size <<= 10;
28403 + }
28404 + if (ebda_addr && ebda_size) {
28405 + ebda_start = ebda_addr >> PAGE_SHIFT;
28406 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28407 + } else {
28408 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28409 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28410 + }
28411 +}
28412 +#else
28413 +static inline void gr_init_ebda(void) { }
28414 +#endif
28415 +
28416 void free_initmem(void)
28417 {
28418 +#ifdef CONFIG_PAX_KERNEXEC
28419 +#ifdef CONFIG_X86_32
28420 + /* PaX: limit KERNEL_CS to actual size */
28421 + unsigned long addr, limit;
28422 + struct desc_struct d;
28423 + int cpu;
28424 +#else
28425 + pgd_t *pgd;
28426 + pud_t *pud;
28427 + pmd_t *pmd;
28428 + unsigned long addr, end;
28429 +#endif
28430 +#endif
28431 +
28432 + gr_init_ebda();
28433 +
28434 +#ifdef CONFIG_PAX_KERNEXEC
28435 +#ifdef CONFIG_X86_32
28436 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
28437 + limit = (limit - 1UL) >> PAGE_SHIFT;
28438 +
28439 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
28440 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
28441 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
28442 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
28443 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
28444 + }
28445 +
28446 + /* PaX: make KERNEL_CS read-only */
28447 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
28448 + if (!paravirt_enabled())
28449 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
28450 +/*
28451 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
28452 + pgd = pgd_offset_k(addr);
28453 + pud = pud_offset(pgd, addr);
28454 + pmd = pmd_offset(pud, addr);
28455 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28456 + }
28457 +*/
28458 +#ifdef CONFIG_X86_PAE
28459 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
28460 +/*
28461 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
28462 + pgd = pgd_offset_k(addr);
28463 + pud = pud_offset(pgd, addr);
28464 + pmd = pmd_offset(pud, addr);
28465 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28466 + }
28467 +*/
28468 +#endif
28469 +
28470 +#ifdef CONFIG_MODULES
28471 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
28472 +#endif
28473 +
28474 +#else
28475 + /* PaX: make kernel code/rodata read-only, rest non-executable */
28476 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
28477 + pgd = pgd_offset_k(addr);
28478 + pud = pud_offset(pgd, addr);
28479 + pmd = pmd_offset(pud, addr);
28480 + if (!pmd_present(*pmd))
28481 + continue;
28482 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
28483 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28484 + else
28485 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28486 + }
28487 +
28488 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
28489 + end = addr + KERNEL_IMAGE_SIZE;
28490 + for (; addr < end; addr += PMD_SIZE) {
28491 + pgd = pgd_offset_k(addr);
28492 + pud = pud_offset(pgd, addr);
28493 + pmd = pmd_offset(pud, addr);
28494 + if (!pmd_present(*pmd))
28495 + continue;
28496 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
28497 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28498 + }
28499 +#endif
28500 +
28501 + flush_tlb_all();
28502 +#endif
28503 +
28504 free_init_pages("unused kernel memory",
28505 (unsigned long)(&__init_begin),
28506 (unsigned long)(&__init_end));
28507 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28508 index 745d66b..56bf568 100644
28509 --- a/arch/x86/mm/init_32.c
28510 +++ b/arch/x86/mm/init_32.c
28511 @@ -73,36 +73,6 @@ static __init void *alloc_low_page(void)
28512 }
28513
28514 /*
28515 - * Creates a middle page table and puts a pointer to it in the
28516 - * given global directory entry. This only returns the gd entry
28517 - * in non-PAE compilation mode, since the middle layer is folded.
28518 - */
28519 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28520 -{
28521 - pud_t *pud;
28522 - pmd_t *pmd_table;
28523 -
28524 -#ifdef CONFIG_X86_PAE
28525 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28526 - if (after_bootmem)
28527 - pmd_table = (pmd_t *)alloc_bootmem_pages(PAGE_SIZE);
28528 - else
28529 - pmd_table = (pmd_t *)alloc_low_page();
28530 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28531 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28532 - pud = pud_offset(pgd, 0);
28533 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28534 -
28535 - return pmd_table;
28536 - }
28537 -#endif
28538 - pud = pud_offset(pgd, 0);
28539 - pmd_table = pmd_offset(pud, 0);
28540 -
28541 - return pmd_table;
28542 -}
28543 -
28544 -/*
28545 * Create a page table and place a pointer to it in a middle page
28546 * directory entry:
28547 */
28548 @@ -122,13 +92,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28549 page_table = (pte_t *)alloc_low_page();
28550
28551 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28552 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28553 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28554 +#else
28555 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28556 +#endif
28557 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28558 }
28559
28560 return pte_offset_kernel(pmd, 0);
28561 }
28562
28563 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28564 +{
28565 + pud_t *pud;
28566 + pmd_t *pmd_table;
28567 +
28568 + pud = pud_offset(pgd, 0);
28569 + pmd_table = pmd_offset(pud, 0);
28570 +
28571 + return pmd_table;
28572 +}
28573 +
28574 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28575 {
28576 int pgd_idx = pgd_index(vaddr);
28577 @@ -202,6 +187,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28578 int pgd_idx, pmd_idx;
28579 unsigned long vaddr;
28580 pgd_t *pgd;
28581 + pud_t *pud;
28582 pmd_t *pmd;
28583 pte_t *pte = NULL;
28584
28585 @@ -211,8 +197,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28586 pgd = pgd_base + pgd_idx;
28587
28588 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28589 - pmd = one_md_table_init(pgd);
28590 - pmd = pmd + pmd_index(vaddr);
28591 + pud = pud_offset(pgd, vaddr);
28592 + pmd = pmd_offset(pud, vaddr);
28593 +
28594 +#ifdef CONFIG_X86_PAE
28595 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28596 +#endif
28597 +
28598 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28599 pmd++, pmd_idx++) {
28600 pte = page_table_kmap_check(one_page_table_init(pmd),
28601 @@ -224,11 +215,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28602 }
28603 }
28604
28605 -static inline int is_kernel_text(unsigned long addr)
28606 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28607 {
28608 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28609 - return 1;
28610 - return 0;
28611 + if ((start > ktla_ktva((unsigned long)_etext) ||
28612 + end <= ktla_ktva((unsigned long)_stext)) &&
28613 + (start > ktla_ktva((unsigned long)_einittext) ||
28614 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28615 +
28616 +#ifdef CONFIG_ACPI_SLEEP
28617 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28618 +#endif
28619 +
28620 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28621 + return 0;
28622 + return 1;
28623 }
28624
28625 /*
28626 @@ -245,9 +245,10 @@ kernel_physical_mapping_init(unsigned long start,
28627 unsigned long last_map_addr = end;
28628 unsigned long start_pfn, end_pfn;
28629 pgd_t *pgd_base = swapper_pg_dir;
28630 - int pgd_idx, pmd_idx, pte_ofs;
28631 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28632 unsigned long pfn;
28633 pgd_t *pgd;
28634 + pud_t *pud;
28635 pmd_t *pmd;
28636 pte_t *pte;
28637 unsigned pages_2m, pages_4k;
28638 @@ -280,8 +281,13 @@ repeat:
28639 pfn = start_pfn;
28640 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28641 pgd = pgd_base + pgd_idx;
28642 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28643 - pmd = one_md_table_init(pgd);
28644 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28645 + pud = pud_offset(pgd, 0);
28646 + pmd = pmd_offset(pud, 0);
28647 +
28648 +#ifdef CONFIG_X86_PAE
28649 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28650 +#endif
28651
28652 if (pfn >= end_pfn)
28653 continue;
28654 @@ -293,14 +299,13 @@ repeat:
28655 #endif
28656 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28657 pmd++, pmd_idx++) {
28658 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28659 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28660
28661 /*
28662 * Map with big pages if possible, otherwise
28663 * create normal page tables:
28664 */
28665 if (use_pse) {
28666 - unsigned int addr2;
28667 pgprot_t prot = PAGE_KERNEL_LARGE;
28668 /*
28669 * first pass will use the same initial
28670 @@ -310,11 +315,7 @@ repeat:
28671 __pgprot(PTE_IDENT_ATTR |
28672 _PAGE_PSE);
28673
28674 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28675 - PAGE_OFFSET + PAGE_SIZE-1;
28676 -
28677 - if (is_kernel_text(addr) ||
28678 - is_kernel_text(addr2))
28679 + if (is_kernel_text(address, address + PMD_SIZE))
28680 prot = PAGE_KERNEL_LARGE_EXEC;
28681
28682 pages_2m++;
28683 @@ -331,7 +332,7 @@ repeat:
28684 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28685 pte += pte_ofs;
28686 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28687 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28688 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28689 pgprot_t prot = PAGE_KERNEL;
28690 /*
28691 * first pass will use the same initial
28692 @@ -339,7 +340,7 @@ repeat:
28693 */
28694 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28695
28696 - if (is_kernel_text(addr))
28697 + if (is_kernel_text(address, address + PAGE_SIZE))
28698 prot = PAGE_KERNEL_EXEC;
28699
28700 pages_4k++;
28701 @@ -465,7 +466,7 @@ void __init native_pagetable_init(void)
28702
28703 pud = pud_offset(pgd, va);
28704 pmd = pmd_offset(pud, va);
28705 - if (!pmd_present(*pmd))
28706 + if (!pmd_present(*pmd) || pmd_huge(*pmd))
28707 break;
28708
28709 pte = pte_offset_kernel(pmd, va);
28710 @@ -514,12 +515,10 @@ void __init early_ioremap_page_table_range_init(void)
28711
28712 static void __init pagetable_init(void)
28713 {
28714 - pgd_t *pgd_base = swapper_pg_dir;
28715 -
28716 - permanent_kmaps_init(pgd_base);
28717 + permanent_kmaps_init(swapper_pg_dir);
28718 }
28719
28720 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28721 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28722 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28723
28724 /* user-defined highmem size */
28725 @@ -728,6 +727,12 @@ void __init mem_init(void)
28726
28727 pci_iommu_alloc();
28728
28729 +#ifdef CONFIG_PAX_PER_CPU_PGD
28730 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28731 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28732 + KERNEL_PGD_PTRS);
28733 +#endif
28734 +
28735 #ifdef CONFIG_FLATMEM
28736 BUG_ON(!mem_map);
28737 #endif
28738 @@ -754,7 +759,7 @@ void __init mem_init(void)
28739 reservedpages++;
28740
28741 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28742 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28743 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28744 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28745
28746 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28747 @@ -795,10 +800,10 @@ void __init mem_init(void)
28748 ((unsigned long)&__init_end -
28749 (unsigned long)&__init_begin) >> 10,
28750
28751 - (unsigned long)&_etext, (unsigned long)&_edata,
28752 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28753 + (unsigned long)&_sdata, (unsigned long)&_edata,
28754 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28755
28756 - (unsigned long)&_text, (unsigned long)&_etext,
28757 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28758 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28759
28760 /*
28761 @@ -876,6 +881,7 @@ void set_kernel_text_rw(void)
28762 if (!kernel_set_to_readonly)
28763 return;
28764
28765 + start = ktla_ktva(start);
28766 pr_debug("Set kernel text: %lx - %lx for read write\n",
28767 start, start+size);
28768
28769 @@ -890,6 +896,7 @@ void set_kernel_text_ro(void)
28770 if (!kernel_set_to_readonly)
28771 return;
28772
28773 + start = ktla_ktva(start);
28774 pr_debug("Set kernel text: %lx - %lx for read only\n",
28775 start, start+size);
28776
28777 @@ -918,6 +925,7 @@ void mark_rodata_ro(void)
28778 unsigned long start = PFN_ALIGN(_text);
28779 unsigned long size = PFN_ALIGN(_etext) - start;
28780
28781 + start = ktla_ktva(start);
28782 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28783 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28784 size >> 10);
28785 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28786 index 75c9a6a..498d677 100644
28787 --- a/arch/x86/mm/init_64.c
28788 +++ b/arch/x86/mm/init_64.c
28789 @@ -74,7 +74,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28790 * around without checking the pgd every time.
28791 */
28792
28793 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28794 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28795 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28796
28797 int force_personality32;
28798 @@ -107,12 +107,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28799
28800 for (address = start; address <= end; address += PGDIR_SIZE) {
28801 const pgd_t *pgd_ref = pgd_offset_k(address);
28802 +
28803 +#ifdef CONFIG_PAX_PER_CPU_PGD
28804 + unsigned long cpu;
28805 +#else
28806 struct page *page;
28807 +#endif
28808
28809 if (pgd_none(*pgd_ref))
28810 continue;
28811
28812 spin_lock(&pgd_lock);
28813 +
28814 +#ifdef CONFIG_PAX_PER_CPU_PGD
28815 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28816 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28817 +#else
28818 list_for_each_entry(page, &pgd_list, lru) {
28819 pgd_t *pgd;
28820 spinlock_t *pgt_lock;
28821 @@ -121,6 +131,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28822 /* the pgt_lock only for Xen */
28823 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28824 spin_lock(pgt_lock);
28825 +#endif
28826
28827 if (pgd_none(*pgd))
28828 set_pgd(pgd, *pgd_ref);
28829 @@ -128,7 +139,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28830 BUG_ON(pgd_page_vaddr(*pgd)
28831 != pgd_page_vaddr(*pgd_ref));
28832
28833 +#ifndef CONFIG_PAX_PER_CPU_PGD
28834 spin_unlock(pgt_lock);
28835 +#endif
28836 +
28837 }
28838 spin_unlock(&pgd_lock);
28839 }
28840 @@ -161,7 +175,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28841 {
28842 if (pgd_none(*pgd)) {
28843 pud_t *pud = (pud_t *)spp_getpage();
28844 - pgd_populate(&init_mm, pgd, pud);
28845 + pgd_populate_kernel(&init_mm, pgd, pud);
28846 if (pud != pud_offset(pgd, 0))
28847 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28848 pud, pud_offset(pgd, 0));
28849 @@ -173,7 +187,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28850 {
28851 if (pud_none(*pud)) {
28852 pmd_t *pmd = (pmd_t *) spp_getpage();
28853 - pud_populate(&init_mm, pud, pmd);
28854 + pud_populate_kernel(&init_mm, pud, pmd);
28855 if (pmd != pmd_offset(pud, 0))
28856 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28857 pmd, pmd_offset(pud, 0));
28858 @@ -202,7 +216,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28859 pmd = fill_pmd(pud, vaddr);
28860 pte = fill_pte(pmd, vaddr);
28861
28862 + pax_open_kernel();
28863 set_pte(pte, new_pte);
28864 + pax_close_kernel();
28865
28866 /*
28867 * It's enough to flush this one mapping.
28868 @@ -261,14 +277,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28869 pgd = pgd_offset_k((unsigned long)__va(phys));
28870 if (pgd_none(*pgd)) {
28871 pud = (pud_t *) spp_getpage();
28872 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28873 - _PAGE_USER));
28874 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28875 }
28876 pud = pud_offset(pgd, (unsigned long)__va(phys));
28877 if (pud_none(*pud)) {
28878 pmd = (pmd_t *) spp_getpage();
28879 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28880 - _PAGE_USER));
28881 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28882 }
28883 pmd = pmd_offset(pud, phys);
28884 BUG_ON(!pmd_none(*pmd));
28885 @@ -329,7 +343,7 @@ static __ref void *alloc_low_page(unsigned long *phys)
28886 if (pfn >= pgt_buf_top)
28887 panic("alloc_low_page: ran out of memory");
28888
28889 - adr = early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
28890 + adr = (void __force_kernel *)early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
28891 clear_page(adr);
28892 *phys = pfn * PAGE_SIZE;
28893 return adr;
28894 @@ -345,7 +359,7 @@ static __ref void *map_low_page(void *virt)
28895
28896 phys = __pa(virt);
28897 left = phys & (PAGE_SIZE - 1);
28898 - adr = early_memremap(phys & PAGE_MASK, PAGE_SIZE);
28899 + adr = (void __force_kernel *)early_memremap(phys & PAGE_MASK, PAGE_SIZE);
28900 adr = (void *)(((unsigned long)adr) | left);
28901
28902 return adr;
28903 @@ -553,7 +567,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28904 unmap_low_page(pmd);
28905
28906 spin_lock(&init_mm.page_table_lock);
28907 - pud_populate(&init_mm, pud, __va(pmd_phys));
28908 + pud_populate_kernel(&init_mm, pud, __va(pmd_phys));
28909 spin_unlock(&init_mm.page_table_lock);
28910 }
28911 __flush_tlb_all();
28912 @@ -599,7 +613,7 @@ kernel_physical_mapping_init(unsigned long start,
28913 unmap_low_page(pud);
28914
28915 spin_lock(&init_mm.page_table_lock);
28916 - pgd_populate(&init_mm, pgd, __va(pud_phys));
28917 + pgd_populate_kernel(&init_mm, pgd, __va(pud_phys));
28918 spin_unlock(&init_mm.page_table_lock);
28919 pgd_changed = true;
28920 }
28921 @@ -693,6 +707,12 @@ void __init mem_init(void)
28922
28923 pci_iommu_alloc();
28924
28925 +#ifdef CONFIG_PAX_PER_CPU_PGD
28926 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28927 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28928 + KERNEL_PGD_PTRS);
28929 +#endif
28930 +
28931 /* clear_bss() already clear the empty_zero_page */
28932
28933 reservedpages = 0;
28934 @@ -856,8 +876,8 @@ int kern_addr_valid(unsigned long addr)
28935 static struct vm_area_struct gate_vma = {
28936 .vm_start = VSYSCALL_START,
28937 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28938 - .vm_page_prot = PAGE_READONLY_EXEC,
28939 - .vm_flags = VM_READ | VM_EXEC
28940 + .vm_page_prot = PAGE_READONLY,
28941 + .vm_flags = VM_READ
28942 };
28943
28944 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28945 @@ -891,7 +911,7 @@ int in_gate_area_no_mm(unsigned long addr)
28946
28947 const char *arch_vma_name(struct vm_area_struct *vma)
28948 {
28949 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
28950 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
28951 return "[vdso]";
28952 if (vma == &gate_vma)
28953 return "[vsyscall]";
28954 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
28955 index 7b179b4..6bd17777 100644
28956 --- a/arch/x86/mm/iomap_32.c
28957 +++ b/arch/x86/mm/iomap_32.c
28958 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
28959 type = kmap_atomic_idx_push();
28960 idx = type + KM_TYPE_NR * smp_processor_id();
28961 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28962 +
28963 + pax_open_kernel();
28964 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
28965 + pax_close_kernel();
28966 +
28967 arch_flush_lazy_mmu_mode();
28968
28969 return (void *)vaddr;
28970 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
28971 index 78fe3f1..73b95e2 100644
28972 --- a/arch/x86/mm/ioremap.c
28973 +++ b/arch/x86/mm/ioremap.c
28974 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
28975 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
28976 int is_ram = page_is_ram(pfn);
28977
28978 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
28979 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
28980 return NULL;
28981 WARN_ON_ONCE(is_ram);
28982 }
28983 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
28984 *
28985 * Caller must ensure there is only one unmapping for the same pointer.
28986 */
28987 -void iounmap(volatile void __iomem *addr)
28988 +void iounmap(const volatile void __iomem *addr)
28989 {
28990 struct vm_struct *p, *o;
28991
28992 @@ -315,6 +315,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28993
28994 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
28995 if (page_is_ram(start >> PAGE_SHIFT))
28996 +#ifdef CONFIG_HIGHMEM
28997 + if ((start >> PAGE_SHIFT) < max_low_pfn)
28998 +#endif
28999 return __va(phys);
29000
29001 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
29002 @@ -327,6 +330,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
29003 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
29004 {
29005 if (page_is_ram(phys >> PAGE_SHIFT))
29006 +#ifdef CONFIG_HIGHMEM
29007 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
29008 +#endif
29009 return;
29010
29011 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
29012 @@ -344,7 +350,7 @@ static int __init early_ioremap_debug_setup(char *str)
29013 early_param("early_ioremap_debug", early_ioremap_debug_setup);
29014
29015 static __initdata int after_paging_init;
29016 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
29017 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
29018
29019 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
29020 {
29021 @@ -381,8 +387,7 @@ void __init early_ioremap_init(void)
29022 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
29023
29024 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
29025 - memset(bm_pte, 0, sizeof(bm_pte));
29026 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
29027 + pmd_populate_user(&init_mm, pmd, bm_pte);
29028
29029 /*
29030 * The boot-ioremap range spans multiple pmds, for which
29031 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
29032 index d87dd6d..bf3fa66 100644
29033 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
29034 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
29035 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
29036 * memory (e.g. tracked pages)? For now, we need this to avoid
29037 * invoking kmemcheck for PnP BIOS calls.
29038 */
29039 - if (regs->flags & X86_VM_MASK)
29040 + if (v8086_mode(regs))
29041 return false;
29042 - if (regs->cs != __KERNEL_CS)
29043 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
29044 return false;
29045
29046 pte = kmemcheck_pte_lookup(address);
29047 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
29048 index 845df68..1d8d29f 100644
29049 --- a/arch/x86/mm/mmap.c
29050 +++ b/arch/x86/mm/mmap.c
29051 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
29052 * Leave an at least ~128 MB hole with possible stack randomization.
29053 */
29054 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
29055 -#define MAX_GAP (TASK_SIZE/6*5)
29056 +#define MAX_GAP (pax_task_size/6*5)
29057
29058 static int mmap_is_legacy(void)
29059 {
29060 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
29061 return rnd << PAGE_SHIFT;
29062 }
29063
29064 -static unsigned long mmap_base(void)
29065 +static unsigned long mmap_base(struct mm_struct *mm)
29066 {
29067 unsigned long gap = rlimit(RLIMIT_STACK);
29068 + unsigned long pax_task_size = TASK_SIZE;
29069 +
29070 +#ifdef CONFIG_PAX_SEGMEXEC
29071 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
29072 + pax_task_size = SEGMEXEC_TASK_SIZE;
29073 +#endif
29074
29075 if (gap < MIN_GAP)
29076 gap = MIN_GAP;
29077 else if (gap > MAX_GAP)
29078 gap = MAX_GAP;
29079
29080 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
29081 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
29082 }
29083
29084 /*
29085 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
29086 * does, but not when emulating X86_32
29087 */
29088 -static unsigned long mmap_legacy_base(void)
29089 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
29090 {
29091 - if (mmap_is_ia32())
29092 + if (mmap_is_ia32()) {
29093 +
29094 +#ifdef CONFIG_PAX_SEGMEXEC
29095 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
29096 + return SEGMEXEC_TASK_UNMAPPED_BASE;
29097 + else
29098 +#endif
29099 +
29100 return TASK_UNMAPPED_BASE;
29101 - else
29102 + } else
29103 return TASK_UNMAPPED_BASE + mmap_rnd();
29104 }
29105
29106 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
29107 void arch_pick_mmap_layout(struct mm_struct *mm)
29108 {
29109 if (mmap_is_legacy()) {
29110 - mm->mmap_base = mmap_legacy_base();
29111 + mm->mmap_base = mmap_legacy_base(mm);
29112 +
29113 +#ifdef CONFIG_PAX_RANDMMAP
29114 + if (mm->pax_flags & MF_PAX_RANDMMAP)
29115 + mm->mmap_base += mm->delta_mmap;
29116 +#endif
29117 +
29118 mm->get_unmapped_area = arch_get_unmapped_area;
29119 mm->unmap_area = arch_unmap_area;
29120 } else {
29121 - mm->mmap_base = mmap_base();
29122 + mm->mmap_base = mmap_base(mm);
29123 +
29124 +#ifdef CONFIG_PAX_RANDMMAP
29125 + if (mm->pax_flags & MF_PAX_RANDMMAP)
29126 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
29127 +#endif
29128 +
29129 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
29130 mm->unmap_area = arch_unmap_area_topdown;
29131 }
29132 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
29133 index dc0b727..f612039 100644
29134 --- a/arch/x86/mm/mmio-mod.c
29135 +++ b/arch/x86/mm/mmio-mod.c
29136 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
29137 break;
29138 default:
29139 {
29140 - unsigned char *ip = (unsigned char *)instptr;
29141 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
29142 my_trace->opcode = MMIO_UNKNOWN_OP;
29143 my_trace->width = 0;
29144 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
29145 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
29146 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
29147 void __iomem *addr)
29148 {
29149 - static atomic_t next_id;
29150 + static atomic_unchecked_t next_id;
29151 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
29152 /* These are page-unaligned. */
29153 struct mmiotrace_map map = {
29154 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
29155 .private = trace
29156 },
29157 .phys = offset,
29158 - .id = atomic_inc_return(&next_id)
29159 + .id = atomic_inc_return_unchecked(&next_id)
29160 };
29161 map.map_id = trace->id;
29162
29163 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
29164 ioremap_trace_core(offset, size, addr);
29165 }
29166
29167 -static void iounmap_trace_core(volatile void __iomem *addr)
29168 +static void iounmap_trace_core(const volatile void __iomem *addr)
29169 {
29170 struct mmiotrace_map map = {
29171 .phys = 0,
29172 @@ -328,7 +328,7 @@ not_enabled:
29173 }
29174 }
29175
29176 -void mmiotrace_iounmap(volatile void __iomem *addr)
29177 +void mmiotrace_iounmap(const volatile void __iomem *addr)
29178 {
29179 might_sleep();
29180 if (is_enabled()) /* recheck and proper locking in *_core() */
29181 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
29182 index 8504f36..5fc68f2 100644
29183 --- a/arch/x86/mm/numa.c
29184 +++ b/arch/x86/mm/numa.c
29185 @@ -478,7 +478,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
29186 return true;
29187 }
29188
29189 -static int __init numa_register_memblks(struct numa_meminfo *mi)
29190 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
29191 {
29192 unsigned long uninitialized_var(pfn_align);
29193 int i, nid;
29194 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
29195 index b008656..773eac2 100644
29196 --- a/arch/x86/mm/pageattr-test.c
29197 +++ b/arch/x86/mm/pageattr-test.c
29198 @@ -36,7 +36,7 @@ enum {
29199
29200 static int pte_testbit(pte_t pte)
29201 {
29202 - return pte_flags(pte) & _PAGE_UNUSED1;
29203 + return pte_flags(pte) & _PAGE_CPA_TEST;
29204 }
29205
29206 struct split_state {
29207 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
29208 index a718e0d..77419bc 100644
29209 --- a/arch/x86/mm/pageattr.c
29210 +++ b/arch/x86/mm/pageattr.c
29211 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29212 */
29213 #ifdef CONFIG_PCI_BIOS
29214 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
29215 - pgprot_val(forbidden) |= _PAGE_NX;
29216 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29217 #endif
29218
29219 /*
29220 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29221 * Does not cover __inittext since that is gone later on. On
29222 * 64bit we do not enforce !NX on the low mapping
29223 */
29224 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
29225 - pgprot_val(forbidden) |= _PAGE_NX;
29226 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
29227 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29228
29229 +#ifdef CONFIG_DEBUG_RODATA
29230 /*
29231 * The .rodata section needs to be read-only. Using the pfn
29232 * catches all aliases.
29233 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29234 if (within(pfn, __pa((unsigned long)__start_rodata) >> PAGE_SHIFT,
29235 __pa((unsigned long)__end_rodata) >> PAGE_SHIFT))
29236 pgprot_val(forbidden) |= _PAGE_RW;
29237 +#endif
29238
29239 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
29240 /*
29241 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29242 }
29243 #endif
29244
29245 +#ifdef CONFIG_PAX_KERNEXEC
29246 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
29247 + pgprot_val(forbidden) |= _PAGE_RW;
29248 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29249 + }
29250 +#endif
29251 +
29252 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
29253
29254 return prot;
29255 @@ -369,23 +378,37 @@ EXPORT_SYMBOL_GPL(lookup_address);
29256 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
29257 {
29258 /* change init_mm */
29259 + pax_open_kernel();
29260 set_pte_atomic(kpte, pte);
29261 +
29262 #ifdef CONFIG_X86_32
29263 if (!SHARED_KERNEL_PMD) {
29264 +
29265 +#ifdef CONFIG_PAX_PER_CPU_PGD
29266 + unsigned long cpu;
29267 +#else
29268 struct page *page;
29269 +#endif
29270
29271 +#ifdef CONFIG_PAX_PER_CPU_PGD
29272 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29273 + pgd_t *pgd = get_cpu_pgd(cpu);
29274 +#else
29275 list_for_each_entry(page, &pgd_list, lru) {
29276 - pgd_t *pgd;
29277 + pgd_t *pgd = (pgd_t *)page_address(page);
29278 +#endif
29279 +
29280 pud_t *pud;
29281 pmd_t *pmd;
29282
29283 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
29284 + pgd += pgd_index(address);
29285 pud = pud_offset(pgd, address);
29286 pmd = pmd_offset(pud, address);
29287 set_pte_atomic((pte_t *)pmd, pte);
29288 }
29289 }
29290 #endif
29291 + pax_close_kernel();
29292 }
29293
29294 static int
29295 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
29296 index 0eb572e..92f5c1e 100644
29297 --- a/arch/x86/mm/pat.c
29298 +++ b/arch/x86/mm/pat.c
29299 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
29300
29301 if (!entry) {
29302 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
29303 - current->comm, current->pid, start, end - 1);
29304 + current->comm, task_pid_nr(current), start, end - 1);
29305 return -EINVAL;
29306 }
29307
29308 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29309
29310 while (cursor < to) {
29311 if (!devmem_is_allowed(pfn)) {
29312 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
29313 - current->comm, from, to - 1);
29314 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
29315 + current->comm, from, to - 1, cursor);
29316 return 0;
29317 }
29318 cursor += PAGE_SIZE;
29319 @@ -570,7 +570,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
29320 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
29321 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
29322 "for [mem %#010Lx-%#010Lx]\n",
29323 - current->comm, current->pid,
29324 + current->comm, task_pid_nr(current),
29325 cattr_name(flags),
29326 base, (unsigned long long)(base + size-1));
29327 return -EINVAL;
29328 @@ -605,7 +605,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29329 flags = lookup_memtype(paddr);
29330 if (want_flags != flags) {
29331 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
29332 - current->comm, current->pid,
29333 + current->comm, task_pid_nr(current),
29334 cattr_name(want_flags),
29335 (unsigned long long)paddr,
29336 (unsigned long long)(paddr + size - 1),
29337 @@ -627,7 +627,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29338 free_memtype(paddr, paddr + size);
29339 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
29340 " for [mem %#010Lx-%#010Lx], got %s\n",
29341 - current->comm, current->pid,
29342 + current->comm, task_pid_nr(current),
29343 cattr_name(want_flags),
29344 (unsigned long long)paddr,
29345 (unsigned long long)(paddr + size - 1),
29346 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
29347 index 9f0614d..92ae64a 100644
29348 --- a/arch/x86/mm/pf_in.c
29349 +++ b/arch/x86/mm/pf_in.c
29350 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
29351 int i;
29352 enum reason_type rv = OTHERS;
29353
29354 - p = (unsigned char *)ins_addr;
29355 + p = (unsigned char *)ktla_ktva(ins_addr);
29356 p += skip_prefix(p, &prf);
29357 p += get_opcode(p, &opcode);
29358
29359 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
29360 struct prefix_bits prf;
29361 int i;
29362
29363 - p = (unsigned char *)ins_addr;
29364 + p = (unsigned char *)ktla_ktva(ins_addr);
29365 p += skip_prefix(p, &prf);
29366 p += get_opcode(p, &opcode);
29367
29368 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
29369 struct prefix_bits prf;
29370 int i;
29371
29372 - p = (unsigned char *)ins_addr;
29373 + p = (unsigned char *)ktla_ktva(ins_addr);
29374 p += skip_prefix(p, &prf);
29375 p += get_opcode(p, &opcode);
29376
29377 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
29378 struct prefix_bits prf;
29379 int i;
29380
29381 - p = (unsigned char *)ins_addr;
29382 + p = (unsigned char *)ktla_ktva(ins_addr);
29383 p += skip_prefix(p, &prf);
29384 p += get_opcode(p, &opcode);
29385 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
29386 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
29387 struct prefix_bits prf;
29388 int i;
29389
29390 - p = (unsigned char *)ins_addr;
29391 + p = (unsigned char *)ktla_ktva(ins_addr);
29392 p += skip_prefix(p, &prf);
29393 p += get_opcode(p, &opcode);
29394 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
29395 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
29396 index e27fbf8..8b56dc9 100644
29397 --- a/arch/x86/mm/pgtable.c
29398 +++ b/arch/x86/mm/pgtable.c
29399 @@ -84,10 +84,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29400 list_del(&page->lru);
29401 }
29402
29403 -#define UNSHARED_PTRS_PER_PGD \
29404 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29405 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29406 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29407
29408 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29409 +{
29410 + unsigned int count = USER_PGD_PTRS;
29411
29412 + while (count--)
29413 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29414 +}
29415 +#endif
29416 +
29417 +#ifdef CONFIG_PAX_PER_CPU_PGD
29418 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29419 +{
29420 + unsigned int count = USER_PGD_PTRS;
29421 +
29422 + while (count--) {
29423 + pgd_t pgd;
29424 +
29425 +#ifdef CONFIG_X86_64
29426 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29427 +#else
29428 + pgd = *src++;
29429 +#endif
29430 +
29431 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29432 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29433 +#endif
29434 +
29435 + *dst++ = pgd;
29436 + }
29437 +
29438 +}
29439 +#endif
29440 +
29441 +#ifdef CONFIG_X86_64
29442 +#define pxd_t pud_t
29443 +#define pyd_t pgd_t
29444 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
29445 +#define pxd_free(mm, pud) pud_free((mm), (pud))
29446 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
29447 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
29448 +#define PYD_SIZE PGDIR_SIZE
29449 +#else
29450 +#define pxd_t pmd_t
29451 +#define pyd_t pud_t
29452 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
29453 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
29454 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
29455 +#define pyd_offset(mm, address) pud_offset((mm), (address))
29456 +#define PYD_SIZE PUD_SIZE
29457 +#endif
29458 +
29459 +#ifdef CONFIG_PAX_PER_CPU_PGD
29460 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
29461 +static inline void pgd_dtor(pgd_t *pgd) {}
29462 +#else
29463 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
29464 {
29465 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
29466 @@ -128,6 +182,7 @@ static void pgd_dtor(pgd_t *pgd)
29467 pgd_list_del(pgd);
29468 spin_unlock(&pgd_lock);
29469 }
29470 +#endif
29471
29472 /*
29473 * List of all pgd's needed for non-PAE so it can invalidate entries
29474 @@ -140,7 +195,7 @@ static void pgd_dtor(pgd_t *pgd)
29475 * -- nyc
29476 */
29477
29478 -#ifdef CONFIG_X86_PAE
29479 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
29480 /*
29481 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
29482 * updating the top-level pagetable entries to guarantee the
29483 @@ -152,7 +207,7 @@ static void pgd_dtor(pgd_t *pgd)
29484 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
29485 * and initialize the kernel pmds here.
29486 */
29487 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
29488 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29489
29490 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29491 {
29492 @@ -170,36 +225,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29493 */
29494 flush_tlb_mm(mm);
29495 }
29496 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
29497 +#define PREALLOCATED_PXDS USER_PGD_PTRS
29498 #else /* !CONFIG_X86_PAE */
29499
29500 /* No need to prepopulate any pagetable entries in non-PAE modes. */
29501 -#define PREALLOCATED_PMDS 0
29502 +#define PREALLOCATED_PXDS 0
29503
29504 #endif /* CONFIG_X86_PAE */
29505
29506 -static void free_pmds(pmd_t *pmds[])
29507 +static void free_pxds(pxd_t *pxds[])
29508 {
29509 int i;
29510
29511 - for(i = 0; i < PREALLOCATED_PMDS; i++)
29512 - if (pmds[i])
29513 - free_page((unsigned long)pmds[i]);
29514 + for(i = 0; i < PREALLOCATED_PXDS; i++)
29515 + if (pxds[i])
29516 + free_page((unsigned long)pxds[i]);
29517 }
29518
29519 -static int preallocate_pmds(pmd_t *pmds[])
29520 +static int preallocate_pxds(pxd_t *pxds[])
29521 {
29522 int i;
29523 bool failed = false;
29524
29525 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29526 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29527 - if (pmd == NULL)
29528 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29529 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29530 + if (pxd == NULL)
29531 failed = true;
29532 - pmds[i] = pmd;
29533 + pxds[i] = pxd;
29534 }
29535
29536 if (failed) {
29537 - free_pmds(pmds);
29538 + free_pxds(pxds);
29539 return -ENOMEM;
29540 }
29541
29542 @@ -212,51 +269,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29543 * preallocate which never got a corresponding vma will need to be
29544 * freed manually.
29545 */
29546 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29547 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29548 {
29549 int i;
29550
29551 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29552 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29553 pgd_t pgd = pgdp[i];
29554
29555 if (pgd_val(pgd) != 0) {
29556 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29557 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29558
29559 - pgdp[i] = native_make_pgd(0);
29560 + set_pgd(pgdp + i, native_make_pgd(0));
29561
29562 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29563 - pmd_free(mm, pmd);
29564 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29565 + pxd_free(mm, pxd);
29566 }
29567 }
29568 }
29569
29570 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29571 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29572 {
29573 - pud_t *pud;
29574 + pyd_t *pyd;
29575 unsigned long addr;
29576 int i;
29577
29578 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29579 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29580 return;
29581
29582 - pud = pud_offset(pgd, 0);
29583 +#ifdef CONFIG_X86_64
29584 + pyd = pyd_offset(mm, 0L);
29585 +#else
29586 + pyd = pyd_offset(pgd, 0L);
29587 +#endif
29588
29589 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29590 - i++, pud++, addr += PUD_SIZE) {
29591 - pmd_t *pmd = pmds[i];
29592 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29593 + i++, pyd++, addr += PYD_SIZE) {
29594 + pxd_t *pxd = pxds[i];
29595
29596 if (i >= KERNEL_PGD_BOUNDARY)
29597 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29598 - sizeof(pmd_t) * PTRS_PER_PMD);
29599 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29600 + sizeof(pxd_t) * PTRS_PER_PMD);
29601
29602 - pud_populate(mm, pud, pmd);
29603 + pyd_populate(mm, pyd, pxd);
29604 }
29605 }
29606
29607 pgd_t *pgd_alloc(struct mm_struct *mm)
29608 {
29609 pgd_t *pgd;
29610 - pmd_t *pmds[PREALLOCATED_PMDS];
29611 + pxd_t *pxds[PREALLOCATED_PXDS];
29612
29613 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29614
29615 @@ -265,11 +326,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29616
29617 mm->pgd = pgd;
29618
29619 - if (preallocate_pmds(pmds) != 0)
29620 + if (preallocate_pxds(pxds) != 0)
29621 goto out_free_pgd;
29622
29623 if (paravirt_pgd_alloc(mm) != 0)
29624 - goto out_free_pmds;
29625 + goto out_free_pxds;
29626
29627 /*
29628 * Make sure that pre-populating the pmds is atomic with
29629 @@ -279,14 +340,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29630 spin_lock(&pgd_lock);
29631
29632 pgd_ctor(mm, pgd);
29633 - pgd_prepopulate_pmd(mm, pgd, pmds);
29634 + pgd_prepopulate_pxd(mm, pgd, pxds);
29635
29636 spin_unlock(&pgd_lock);
29637
29638 return pgd;
29639
29640 -out_free_pmds:
29641 - free_pmds(pmds);
29642 +out_free_pxds:
29643 + free_pxds(pxds);
29644 out_free_pgd:
29645 free_page((unsigned long)pgd);
29646 out:
29647 @@ -295,7 +356,7 @@ out:
29648
29649 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29650 {
29651 - pgd_mop_up_pmds(mm, pgd);
29652 + pgd_mop_up_pxds(mm, pgd);
29653 pgd_dtor(pgd);
29654 paravirt_pgd_free(mm, pgd);
29655 free_page((unsigned long)pgd);
29656 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29657 index a69bcb8..19068ab 100644
29658 --- a/arch/x86/mm/pgtable_32.c
29659 +++ b/arch/x86/mm/pgtable_32.c
29660 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29661 return;
29662 }
29663 pte = pte_offset_kernel(pmd, vaddr);
29664 +
29665 + pax_open_kernel();
29666 if (pte_val(pteval))
29667 set_pte_at(&init_mm, vaddr, pte, pteval);
29668 else
29669 pte_clear(&init_mm, vaddr, pte);
29670 + pax_close_kernel();
29671
29672 /*
29673 * It's enough to flush this one mapping.
29674 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29675 index d2e2735..5c6586f 100644
29676 --- a/arch/x86/mm/physaddr.c
29677 +++ b/arch/x86/mm/physaddr.c
29678 @@ -8,7 +8,7 @@
29679
29680 #ifdef CONFIG_X86_64
29681
29682 -unsigned long __phys_addr(unsigned long x)
29683 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29684 {
29685 if (x >= __START_KERNEL_map) {
29686 x -= __START_KERNEL_map;
29687 @@ -45,7 +45,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29688 #else
29689
29690 #ifdef CONFIG_DEBUG_VIRTUAL
29691 -unsigned long __phys_addr(unsigned long x)
29692 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29693 {
29694 /* VMALLOC_* aren't constants */
29695 VIRTUAL_BUG_ON(x < PAGE_OFFSET);
29696 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29697 index 410531d..0f16030 100644
29698 --- a/arch/x86/mm/setup_nx.c
29699 +++ b/arch/x86/mm/setup_nx.c
29700 @@ -5,8 +5,10 @@
29701 #include <asm/pgtable.h>
29702 #include <asm/proto.h>
29703
29704 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29705 static int disable_nx __cpuinitdata;
29706
29707 +#ifndef CONFIG_PAX_PAGEEXEC
29708 /*
29709 * noexec = on|off
29710 *
29711 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29712 return 0;
29713 }
29714 early_param("noexec", noexec_setup);
29715 +#endif
29716 +
29717 +#endif
29718
29719 void __cpuinit x86_configure_nx(void)
29720 {
29721 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29722 if (cpu_has_nx && !disable_nx)
29723 __supported_pte_mask |= _PAGE_NX;
29724 else
29725 +#endif
29726 __supported_pte_mask &= ~_PAGE_NX;
29727 }
29728
29729 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29730 index 13a6b29..c2fff23 100644
29731 --- a/arch/x86/mm/tlb.c
29732 +++ b/arch/x86/mm/tlb.c
29733 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29734 BUG();
29735 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29736 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29737 +
29738 +#ifndef CONFIG_PAX_PER_CPU_PGD
29739 load_cr3(swapper_pg_dir);
29740 +#endif
29741 +
29742 }
29743 }
29744 EXPORT_SYMBOL_GPL(leave_mm);
29745 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29746 index 877b9a1..a8ecf42 100644
29747 --- a/arch/x86/net/bpf_jit.S
29748 +++ b/arch/x86/net/bpf_jit.S
29749 @@ -9,6 +9,7 @@
29750 */
29751 #include <linux/linkage.h>
29752 #include <asm/dwarf2.h>
29753 +#include <asm/alternative-asm.h>
29754
29755 /*
29756 * Calling convention :
29757 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29758 jle bpf_slow_path_word
29759 mov (SKBDATA,%rsi),%eax
29760 bswap %eax /* ntohl() */
29761 + pax_force_retaddr
29762 ret
29763
29764 sk_load_half:
29765 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29766 jle bpf_slow_path_half
29767 movzwl (SKBDATA,%rsi),%eax
29768 rol $8,%ax # ntohs()
29769 + pax_force_retaddr
29770 ret
29771
29772 sk_load_byte:
29773 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29774 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29775 jle bpf_slow_path_byte
29776 movzbl (SKBDATA,%rsi),%eax
29777 + pax_force_retaddr
29778 ret
29779
29780 /**
29781 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29782 movzbl (SKBDATA,%rsi),%ebx
29783 and $15,%bl
29784 shl $2,%bl
29785 + pax_force_retaddr
29786 ret
29787
29788 /* rsi contains offset and can be scratched */
29789 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29790 js bpf_error
29791 mov -12(%rbp),%eax
29792 bswap %eax
29793 + pax_force_retaddr
29794 ret
29795
29796 bpf_slow_path_half:
29797 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29798 mov -12(%rbp),%ax
29799 rol $8,%ax
29800 movzwl %ax,%eax
29801 + pax_force_retaddr
29802 ret
29803
29804 bpf_slow_path_byte:
29805 bpf_slow_path_common(1)
29806 js bpf_error
29807 movzbl -12(%rbp),%eax
29808 + pax_force_retaddr
29809 ret
29810
29811 bpf_slow_path_byte_msh:
29812 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29813 and $15,%al
29814 shl $2,%al
29815 xchg %eax,%ebx
29816 + pax_force_retaddr
29817 ret
29818
29819 #define sk_negative_common(SIZE) \
29820 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29821 sk_negative_common(4)
29822 mov (%rax), %eax
29823 bswap %eax
29824 + pax_force_retaddr
29825 ret
29826
29827 bpf_slow_path_half_neg:
29828 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29829 mov (%rax),%ax
29830 rol $8,%ax
29831 movzwl %ax,%eax
29832 + pax_force_retaddr
29833 ret
29834
29835 bpf_slow_path_byte_neg:
29836 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29837 .globl sk_load_byte_negative_offset
29838 sk_negative_common(1)
29839 movzbl (%rax), %eax
29840 + pax_force_retaddr
29841 ret
29842
29843 bpf_slow_path_byte_msh_neg:
29844 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29845 and $15,%al
29846 shl $2,%al
29847 xchg %eax,%ebx
29848 + pax_force_retaddr
29849 ret
29850
29851 bpf_error:
29852 @@ -197,4 +210,5 @@ bpf_error:
29853 xor %eax,%eax
29854 mov -8(%rbp),%rbx
29855 leaveq
29856 + pax_force_retaddr
29857 ret
29858 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29859 index d11a470..3f9adff3 100644
29860 --- a/arch/x86/net/bpf_jit_comp.c
29861 +++ b/arch/x86/net/bpf_jit_comp.c
29862 @@ -12,6 +12,7 @@
29863 #include <linux/netdevice.h>
29864 #include <linux/filter.h>
29865 #include <linux/if_vlan.h>
29866 +#include <linux/random.h>
29867
29868 /*
29869 * Conventions :
29870 @@ -49,13 +50,87 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29871 return ptr + len;
29872 }
29873
29874 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29875 +#define MAX_INSTR_CODE_SIZE 96
29876 +#else
29877 +#define MAX_INSTR_CODE_SIZE 64
29878 +#endif
29879 +
29880 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29881
29882 #define EMIT1(b1) EMIT(b1, 1)
29883 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29884 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29885 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29886 +
29887 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29888 +/* original constant will appear in ecx */
29889 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29890 +do { \
29891 + /* mov ecx, randkey */ \
29892 + EMIT1(0xb9); \
29893 + EMIT(_key, 4); \
29894 + /* xor ecx, randkey ^ off */ \
29895 + EMIT2(0x81, 0xf1); \
29896 + EMIT((_key) ^ (_off), 4); \
29897 +} while (0)
29898 +
29899 +#define EMIT1_off32(b1, _off) \
29900 +do { \
29901 + switch (b1) { \
29902 + case 0x05: /* add eax, imm32 */ \
29903 + case 0x2d: /* sub eax, imm32 */ \
29904 + case 0x25: /* and eax, imm32 */ \
29905 + case 0x0d: /* or eax, imm32 */ \
29906 + case 0xb8: /* mov eax, imm32 */ \
29907 + case 0x3d: /* cmp eax, imm32 */ \
29908 + case 0xa9: /* test eax, imm32 */ \
29909 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29910 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29911 + break; \
29912 + case 0xbb: /* mov ebx, imm32 */ \
29913 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29914 + /* mov ebx, ecx */ \
29915 + EMIT2(0x89, 0xcb); \
29916 + break; \
29917 + case 0xbe: /* mov esi, imm32 */ \
29918 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29919 + /* mov esi, ecx */ \
29920 + EMIT2(0x89, 0xce); \
29921 + break; \
29922 + case 0xe9: /* jmp rel imm32 */ \
29923 + EMIT1(b1); \
29924 + EMIT(_off, 4); \
29925 + /* prevent fall-through, we're not called if off = 0 */ \
29926 + EMIT(0xcccccccc, 4); \
29927 + EMIT(0xcccccccc, 4); \
29928 + break; \
29929 + default: \
29930 + EMIT1(b1); \
29931 + EMIT(_off, 4); \
29932 + } \
29933 +} while (0)
29934 +
29935 +#define EMIT2_off32(b1, b2, _off) \
29936 +do { \
29937 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29938 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29939 + EMIT(randkey, 4); \
29940 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29941 + EMIT((_off) - randkey, 4); \
29942 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
29943 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29944 + /* imul eax, ecx */ \
29945 + EMIT3(0x0f, 0xaf, 0xc1); \
29946 + } else { \
29947 + EMIT2(b1, b2); \
29948 + EMIT(_off, 4); \
29949 + } \
29950 +} while (0)
29951 +#else
29952 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
29953 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
29954 +#endif
29955
29956 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
29957 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
29958 @@ -90,6 +165,24 @@ do { \
29959 #define X86_JBE 0x76
29960 #define X86_JA 0x77
29961
29962 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29963 +#define APPEND_FLOW_VERIFY() \
29964 +do { \
29965 + /* mov ecx, randkey */ \
29966 + EMIT1(0xb9); \
29967 + EMIT(randkey, 4); \
29968 + /* cmp ecx, randkey */ \
29969 + EMIT2(0x81, 0xf9); \
29970 + EMIT(randkey, 4); \
29971 + /* jz after 8 int 3s */ \
29972 + EMIT2(0x74, 0x08); \
29973 + EMIT(0xcccccccc, 4); \
29974 + EMIT(0xcccccccc, 4); \
29975 +} while (0)
29976 +#else
29977 +#define APPEND_FLOW_VERIFY() do { } while (0)
29978 +#endif
29979 +
29980 #define EMIT_COND_JMP(op, offset) \
29981 do { \
29982 if (is_near(offset)) \
29983 @@ -97,6 +190,7 @@ do { \
29984 else { \
29985 EMIT2(0x0f, op + 0x10); \
29986 EMIT(offset, 4); /* jxx .+off32 */ \
29987 + APPEND_FLOW_VERIFY(); \
29988 } \
29989 } while (0)
29990
29991 @@ -121,12 +215,17 @@ static inline void bpf_flush_icache(void *start, void *end)
29992 set_fs(old_fs);
29993 }
29994
29995 +struct bpf_jit_work {
29996 + struct work_struct work;
29997 + void *image;
29998 +};
29999 +
30000 #define CHOOSE_LOAD_FUNC(K, func) \
30001 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
30002
30003 void bpf_jit_compile(struct sk_filter *fp)
30004 {
30005 - u8 temp[64];
30006 + u8 temp[MAX_INSTR_CODE_SIZE];
30007 u8 *prog;
30008 unsigned int proglen, oldproglen = 0;
30009 int ilen, i;
30010 @@ -139,6 +238,9 @@ void bpf_jit_compile(struct sk_filter *fp)
30011 unsigned int *addrs;
30012 const struct sock_filter *filter = fp->insns;
30013 int flen = fp->len;
30014 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30015 + unsigned int randkey;
30016 +#endif
30017
30018 if (!bpf_jit_enable)
30019 return;
30020 @@ -147,11 +249,19 @@ void bpf_jit_compile(struct sk_filter *fp)
30021 if (addrs == NULL)
30022 return;
30023
30024 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
30025 + if (!fp->work)
30026 + goto out;
30027 +
30028 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30029 + randkey = get_random_int();
30030 +#endif
30031 +
30032 /* Before first pass, make a rough estimation of addrs[]
30033 - * each bpf instruction is translated to less than 64 bytes
30034 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
30035 */
30036 for (proglen = 0, i = 0; i < flen; i++) {
30037 - proglen += 64;
30038 + proglen += MAX_INSTR_CODE_SIZE;
30039 addrs[i] = proglen;
30040 }
30041 cleanup_addr = proglen; /* epilogue address */
30042 @@ -261,10 +371,8 @@ void bpf_jit_compile(struct sk_filter *fp)
30043 case BPF_S_ALU_MUL_K: /* A *= K */
30044 if (is_imm8(K))
30045 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
30046 - else {
30047 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
30048 - EMIT(K, 4);
30049 - }
30050 + else
30051 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
30052 break;
30053 case BPF_S_ALU_DIV_X: /* A /= X; */
30054 seen |= SEEN_XREG;
30055 @@ -304,13 +412,23 @@ void bpf_jit_compile(struct sk_filter *fp)
30056 break;
30057 case BPF_S_ALU_MOD_K: /* A %= K; */
30058 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
30059 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30060 + DILUTE_CONST_SEQUENCE(K, randkey);
30061 +#else
30062 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
30063 +#endif
30064 EMIT2(0xf7, 0xf1); /* div %ecx */
30065 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
30066 break;
30067 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
30068 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30069 + DILUTE_CONST_SEQUENCE(K, randkey);
30070 + // imul rax, rcx
30071 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
30072 +#else
30073 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
30074 EMIT(K, 4);
30075 +#endif
30076 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
30077 break;
30078 case BPF_S_ALU_AND_X:
30079 @@ -564,8 +682,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
30080 if (is_imm8(K)) {
30081 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
30082 } else {
30083 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
30084 - EMIT(K, 4);
30085 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
30086 }
30087 } else {
30088 EMIT2(0x89,0xde); /* mov %ebx,%esi */
30089 @@ -648,17 +765,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30090 break;
30091 default:
30092 /* hmm, too complex filter, give up with jit compiler */
30093 - goto out;
30094 + goto error;
30095 }
30096 ilen = prog - temp;
30097 if (image) {
30098 if (unlikely(proglen + ilen > oldproglen)) {
30099 pr_err("bpb_jit_compile fatal error\n");
30100 - kfree(addrs);
30101 - module_free(NULL, image);
30102 - return;
30103 + module_free_exec(NULL, image);
30104 + goto error;
30105 }
30106 + pax_open_kernel();
30107 memcpy(image + proglen, temp, ilen);
30108 + pax_close_kernel();
30109 }
30110 proglen += ilen;
30111 addrs[i] = proglen;
30112 @@ -679,11 +797,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30113 break;
30114 }
30115 if (proglen == oldproglen) {
30116 - image = module_alloc(max_t(unsigned int,
30117 - proglen,
30118 - sizeof(struct work_struct)));
30119 + image = module_alloc_exec(proglen);
30120 if (!image)
30121 - goto out;
30122 + goto error;
30123 }
30124 oldproglen = proglen;
30125 }
30126 @@ -699,7 +815,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30127 bpf_flush_icache(image, image + proglen);
30128
30129 fp->bpf_func = (void *)image;
30130 - }
30131 + } else
30132 +error:
30133 + kfree(fp->work);
30134 +
30135 out:
30136 kfree(addrs);
30137 return;
30138 @@ -707,18 +826,20 @@ out:
30139
30140 static void jit_free_defer(struct work_struct *arg)
30141 {
30142 - module_free(NULL, arg);
30143 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
30144 + kfree(arg);
30145 }
30146
30147 /* run from softirq, we must use a work_struct to call
30148 - * module_free() from process context
30149 + * module_free_exec() from process context
30150 */
30151 void bpf_jit_free(struct sk_filter *fp)
30152 {
30153 if (fp->bpf_func != sk_run_filter) {
30154 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
30155 + struct work_struct *work = &fp->work->work;
30156
30157 INIT_WORK(work, jit_free_defer);
30158 + fp->work->image = fp->bpf_func;
30159 schedule_work(work);
30160 }
30161 }
30162 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
30163 index d6aa6e8..266395a 100644
30164 --- a/arch/x86/oprofile/backtrace.c
30165 +++ b/arch/x86/oprofile/backtrace.c
30166 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
30167 struct stack_frame_ia32 *fp;
30168 unsigned long bytes;
30169
30170 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
30171 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
30172 if (bytes != sizeof(bufhead))
30173 return NULL;
30174
30175 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
30176 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
30177
30178 oprofile_add_trace(bufhead[0].return_address);
30179
30180 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
30181 struct stack_frame bufhead[2];
30182 unsigned long bytes;
30183
30184 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
30185 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
30186 if (bytes != sizeof(bufhead))
30187 return NULL;
30188
30189 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
30190 {
30191 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
30192
30193 - if (!user_mode_vm(regs)) {
30194 + if (!user_mode(regs)) {
30195 unsigned long stack = kernel_stack_pointer(regs);
30196 if (depth)
30197 dump_trace(NULL, regs, (unsigned long *)stack, 0,
30198 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
30199 index 48768df..ba9143c 100644
30200 --- a/arch/x86/oprofile/nmi_int.c
30201 +++ b/arch/x86/oprofile/nmi_int.c
30202 @@ -23,6 +23,7 @@
30203 #include <asm/nmi.h>
30204 #include <asm/msr.h>
30205 #include <asm/apic.h>
30206 +#include <asm/pgtable.h>
30207
30208 #include "op_counter.h"
30209 #include "op_x86_model.h"
30210 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
30211 if (ret)
30212 return ret;
30213
30214 - if (!model->num_virt_counters)
30215 - model->num_virt_counters = model->num_counters;
30216 + if (!model->num_virt_counters) {
30217 + pax_open_kernel();
30218 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
30219 + pax_close_kernel();
30220 + }
30221
30222 mux_init(ops);
30223
30224 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
30225 index b2b9443..be58856 100644
30226 --- a/arch/x86/oprofile/op_model_amd.c
30227 +++ b/arch/x86/oprofile/op_model_amd.c
30228 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
30229 num_counters = AMD64_NUM_COUNTERS;
30230 }
30231
30232 - op_amd_spec.num_counters = num_counters;
30233 - op_amd_spec.num_controls = num_counters;
30234 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30235 + pax_open_kernel();
30236 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
30237 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
30238 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30239 + pax_close_kernel();
30240
30241 return 0;
30242 }
30243 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
30244 index d90528e..0127e2b 100644
30245 --- a/arch/x86/oprofile/op_model_ppro.c
30246 +++ b/arch/x86/oprofile/op_model_ppro.c
30247 @@ -19,6 +19,7 @@
30248 #include <asm/msr.h>
30249 #include <asm/apic.h>
30250 #include <asm/nmi.h>
30251 +#include <asm/pgtable.h>
30252
30253 #include "op_x86_model.h"
30254 #include "op_counter.h"
30255 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
30256
30257 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
30258
30259 - op_arch_perfmon_spec.num_counters = num_counters;
30260 - op_arch_perfmon_spec.num_controls = num_counters;
30261 + pax_open_kernel();
30262 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
30263 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
30264 + pax_close_kernel();
30265 }
30266
30267 static int arch_perfmon_init(struct oprofile_operations *ignore)
30268 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
30269 index 71e8a67..6a313bb 100644
30270 --- a/arch/x86/oprofile/op_x86_model.h
30271 +++ b/arch/x86/oprofile/op_x86_model.h
30272 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
30273 void (*switch_ctrl)(struct op_x86_model_spec const *model,
30274 struct op_msrs const * const msrs);
30275 #endif
30276 -};
30277 +} __do_const;
30278
30279 struct op_counter_config;
30280
30281 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
30282 index e9e6ed5..e47ae67 100644
30283 --- a/arch/x86/pci/amd_bus.c
30284 +++ b/arch/x86/pci/amd_bus.c
30285 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
30286 return NOTIFY_OK;
30287 }
30288
30289 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
30290 +static struct notifier_block amd_cpu_notifier = {
30291 .notifier_call = amd_cpu_notify,
30292 };
30293
30294 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
30295 index 372e9b8..e775a6c 100644
30296 --- a/arch/x86/pci/irq.c
30297 +++ b/arch/x86/pci/irq.c
30298 @@ -50,7 +50,7 @@ struct irq_router {
30299 struct irq_router_handler {
30300 u16 vendor;
30301 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
30302 -};
30303 +} __do_const;
30304
30305 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
30306 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
30307 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
30308 return 0;
30309 }
30310
30311 -static __initdata struct irq_router_handler pirq_routers[] = {
30312 +static __initconst const struct irq_router_handler pirq_routers[] = {
30313 { PCI_VENDOR_ID_INTEL, intel_router_probe },
30314 { PCI_VENDOR_ID_AL, ali_router_probe },
30315 { PCI_VENDOR_ID_ITE, ite_router_probe },
30316 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
30317 static void __init pirq_find_router(struct irq_router *r)
30318 {
30319 struct irq_routing_table *rt = pirq_table;
30320 - struct irq_router_handler *h;
30321 + const struct irq_router_handler *h;
30322
30323 #ifdef CONFIG_PCI_BIOS
30324 if (!rt->signature) {
30325 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
30326 return 0;
30327 }
30328
30329 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
30330 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
30331 {
30332 .callback = fix_broken_hp_bios_irq9,
30333 .ident = "HP Pavilion N5400 Series Laptop",
30334 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
30335 index 6eb18c4..20d83de 100644
30336 --- a/arch/x86/pci/mrst.c
30337 +++ b/arch/x86/pci/mrst.c
30338 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
30339 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
30340 pci_mmcfg_late_init();
30341 pcibios_enable_irq = mrst_pci_irq_enable;
30342 - pci_root_ops = pci_mrst_ops;
30343 + pax_open_kernel();
30344 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
30345 + pax_close_kernel();
30346 pci_soc_mode = 1;
30347 /* Continue with standard init */
30348 return 1;
30349 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
30350 index c77b24a..c979855 100644
30351 --- a/arch/x86/pci/pcbios.c
30352 +++ b/arch/x86/pci/pcbios.c
30353 @@ -79,7 +79,7 @@ union bios32 {
30354 static struct {
30355 unsigned long address;
30356 unsigned short segment;
30357 -} bios32_indirect = { 0, __KERNEL_CS };
30358 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
30359
30360 /*
30361 * Returns the entry point for the given service, NULL on error
30362 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
30363 unsigned long length; /* %ecx */
30364 unsigned long entry; /* %edx */
30365 unsigned long flags;
30366 + struct desc_struct d, *gdt;
30367
30368 local_irq_save(flags);
30369 - __asm__("lcall *(%%edi); cld"
30370 +
30371 + gdt = get_cpu_gdt_table(smp_processor_id());
30372 +
30373 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
30374 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30375 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
30376 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30377 +
30378 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
30379 : "=a" (return_code),
30380 "=b" (address),
30381 "=c" (length),
30382 "=d" (entry)
30383 : "0" (service),
30384 "1" (0),
30385 - "D" (&bios32_indirect));
30386 + "D" (&bios32_indirect),
30387 + "r"(__PCIBIOS_DS)
30388 + : "memory");
30389 +
30390 + pax_open_kernel();
30391 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
30392 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
30393 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
30394 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
30395 + pax_close_kernel();
30396 +
30397 local_irq_restore(flags);
30398
30399 switch (return_code) {
30400 - case 0:
30401 - return address + entry;
30402 - case 0x80: /* Not present */
30403 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30404 - return 0;
30405 - default: /* Shouldn't happen */
30406 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30407 - service, return_code);
30408 + case 0: {
30409 + int cpu;
30410 + unsigned char flags;
30411 +
30412 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30413 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30414 + printk(KERN_WARNING "bios32_service: not valid\n");
30415 return 0;
30416 + }
30417 + address = address + PAGE_OFFSET;
30418 + length += 16UL; /* some BIOSs underreport this... */
30419 + flags = 4;
30420 + if (length >= 64*1024*1024) {
30421 + length >>= PAGE_SHIFT;
30422 + flags |= 8;
30423 + }
30424 +
30425 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30426 + gdt = get_cpu_gdt_table(cpu);
30427 + pack_descriptor(&d, address, length, 0x9b, flags);
30428 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30429 + pack_descriptor(&d, address, length, 0x93, flags);
30430 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30431 + }
30432 + return entry;
30433 + }
30434 + case 0x80: /* Not present */
30435 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30436 + return 0;
30437 + default: /* Shouldn't happen */
30438 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30439 + service, return_code);
30440 + return 0;
30441 }
30442 }
30443
30444 static struct {
30445 unsigned long address;
30446 unsigned short segment;
30447 -} pci_indirect = { 0, __KERNEL_CS };
30448 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
30449
30450 -static int pci_bios_present;
30451 +static int pci_bios_present __read_only;
30452
30453 static int check_pcibios(void)
30454 {
30455 @@ -131,11 +174,13 @@ static int check_pcibios(void)
30456 unsigned long flags, pcibios_entry;
30457
30458 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
30459 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
30460 + pci_indirect.address = pcibios_entry;
30461
30462 local_irq_save(flags);
30463 - __asm__(
30464 - "lcall *(%%edi); cld\n\t"
30465 + __asm__("movw %w6, %%ds\n\t"
30466 + "lcall *%%ss:(%%edi); cld\n\t"
30467 + "push %%ss\n\t"
30468 + "pop %%ds\n\t"
30469 "jc 1f\n\t"
30470 "xor %%ah, %%ah\n"
30471 "1:"
30472 @@ -144,7 +189,8 @@ static int check_pcibios(void)
30473 "=b" (ebx),
30474 "=c" (ecx)
30475 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
30476 - "D" (&pci_indirect)
30477 + "D" (&pci_indirect),
30478 + "r" (__PCIBIOS_DS)
30479 : "memory");
30480 local_irq_restore(flags);
30481
30482 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30483
30484 switch (len) {
30485 case 1:
30486 - __asm__("lcall *(%%esi); cld\n\t"
30487 + __asm__("movw %w6, %%ds\n\t"
30488 + "lcall *%%ss:(%%esi); cld\n\t"
30489 + "push %%ss\n\t"
30490 + "pop %%ds\n\t"
30491 "jc 1f\n\t"
30492 "xor %%ah, %%ah\n"
30493 "1:"
30494 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30495 : "1" (PCIBIOS_READ_CONFIG_BYTE),
30496 "b" (bx),
30497 "D" ((long)reg),
30498 - "S" (&pci_indirect));
30499 + "S" (&pci_indirect),
30500 + "r" (__PCIBIOS_DS));
30501 /*
30502 * Zero-extend the result beyond 8 bits, do not trust the
30503 * BIOS having done it:
30504 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30505 *value &= 0xff;
30506 break;
30507 case 2:
30508 - __asm__("lcall *(%%esi); cld\n\t"
30509 + __asm__("movw %w6, %%ds\n\t"
30510 + "lcall *%%ss:(%%esi); cld\n\t"
30511 + "push %%ss\n\t"
30512 + "pop %%ds\n\t"
30513 "jc 1f\n\t"
30514 "xor %%ah, %%ah\n"
30515 "1:"
30516 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30517 : "1" (PCIBIOS_READ_CONFIG_WORD),
30518 "b" (bx),
30519 "D" ((long)reg),
30520 - "S" (&pci_indirect));
30521 + "S" (&pci_indirect),
30522 + "r" (__PCIBIOS_DS));
30523 /*
30524 * Zero-extend the result beyond 16 bits, do not trust the
30525 * BIOS having done it:
30526 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30527 *value &= 0xffff;
30528 break;
30529 case 4:
30530 - __asm__("lcall *(%%esi); cld\n\t"
30531 + __asm__("movw %w6, %%ds\n\t"
30532 + "lcall *%%ss:(%%esi); cld\n\t"
30533 + "push %%ss\n\t"
30534 + "pop %%ds\n\t"
30535 "jc 1f\n\t"
30536 "xor %%ah, %%ah\n"
30537 "1:"
30538 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30539 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30540 "b" (bx),
30541 "D" ((long)reg),
30542 - "S" (&pci_indirect));
30543 + "S" (&pci_indirect),
30544 + "r" (__PCIBIOS_DS));
30545 break;
30546 }
30547
30548 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30549
30550 switch (len) {
30551 case 1:
30552 - __asm__("lcall *(%%esi); cld\n\t"
30553 + __asm__("movw %w6, %%ds\n\t"
30554 + "lcall *%%ss:(%%esi); cld\n\t"
30555 + "push %%ss\n\t"
30556 + "pop %%ds\n\t"
30557 "jc 1f\n\t"
30558 "xor %%ah, %%ah\n"
30559 "1:"
30560 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30561 "c" (value),
30562 "b" (bx),
30563 "D" ((long)reg),
30564 - "S" (&pci_indirect));
30565 + "S" (&pci_indirect),
30566 + "r" (__PCIBIOS_DS));
30567 break;
30568 case 2:
30569 - __asm__("lcall *(%%esi); cld\n\t"
30570 + __asm__("movw %w6, %%ds\n\t"
30571 + "lcall *%%ss:(%%esi); cld\n\t"
30572 + "push %%ss\n\t"
30573 + "pop %%ds\n\t"
30574 "jc 1f\n\t"
30575 "xor %%ah, %%ah\n"
30576 "1:"
30577 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30578 "c" (value),
30579 "b" (bx),
30580 "D" ((long)reg),
30581 - "S" (&pci_indirect));
30582 + "S" (&pci_indirect),
30583 + "r" (__PCIBIOS_DS));
30584 break;
30585 case 4:
30586 - __asm__("lcall *(%%esi); cld\n\t"
30587 + __asm__("movw %w6, %%ds\n\t"
30588 + "lcall *%%ss:(%%esi); cld\n\t"
30589 + "push %%ss\n\t"
30590 + "pop %%ds\n\t"
30591 "jc 1f\n\t"
30592 "xor %%ah, %%ah\n"
30593 "1:"
30594 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30595 "c" (value),
30596 "b" (bx),
30597 "D" ((long)reg),
30598 - "S" (&pci_indirect));
30599 + "S" (&pci_indirect),
30600 + "r" (__PCIBIOS_DS));
30601 break;
30602 }
30603
30604 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30605
30606 DBG("PCI: Fetching IRQ routing table... ");
30607 __asm__("push %%es\n\t"
30608 + "movw %w8, %%ds\n\t"
30609 "push %%ds\n\t"
30610 "pop %%es\n\t"
30611 - "lcall *(%%esi); cld\n\t"
30612 + "lcall *%%ss:(%%esi); cld\n\t"
30613 "pop %%es\n\t"
30614 + "push %%ss\n\t"
30615 + "pop %%ds\n"
30616 "jc 1f\n\t"
30617 "xor %%ah, %%ah\n"
30618 "1:"
30619 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30620 "1" (0),
30621 "D" ((long) &opt),
30622 "S" (&pci_indirect),
30623 - "m" (opt)
30624 + "m" (opt),
30625 + "r" (__PCIBIOS_DS)
30626 : "memory");
30627 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30628 if (ret & 0xff00)
30629 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30630 {
30631 int ret;
30632
30633 - __asm__("lcall *(%%esi); cld\n\t"
30634 + __asm__("movw %w5, %%ds\n\t"
30635 + "lcall *%%ss:(%%esi); cld\n\t"
30636 + "push %%ss\n\t"
30637 + "pop %%ds\n"
30638 "jc 1f\n\t"
30639 "xor %%ah, %%ah\n"
30640 "1:"
30641 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30642 : "0" (PCIBIOS_SET_PCI_HW_INT),
30643 "b" ((dev->bus->number << 8) | dev->devfn),
30644 "c" ((irq << 8) | (pin + 10)),
30645 - "S" (&pci_indirect));
30646 + "S" (&pci_indirect),
30647 + "r" (__PCIBIOS_DS));
30648 return !(ret & 0xff00);
30649 }
30650 EXPORT_SYMBOL(pcibios_set_irq_routing);
30651 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30652 index 40e4469..1ab536e 100644
30653 --- a/arch/x86/platform/efi/efi_32.c
30654 +++ b/arch/x86/platform/efi/efi_32.c
30655 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30656 {
30657 struct desc_ptr gdt_descr;
30658
30659 +#ifdef CONFIG_PAX_KERNEXEC
30660 + struct desc_struct d;
30661 +#endif
30662 +
30663 local_irq_save(efi_rt_eflags);
30664
30665 load_cr3(initial_page_table);
30666 __flush_tlb_all();
30667
30668 +#ifdef CONFIG_PAX_KERNEXEC
30669 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30670 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30671 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30672 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30673 +#endif
30674 +
30675 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30676 gdt_descr.size = GDT_SIZE - 1;
30677 load_gdt(&gdt_descr);
30678 @@ -58,6 +69,14 @@ void efi_call_phys_epilog(void)
30679 {
30680 struct desc_ptr gdt_descr;
30681
30682 +#ifdef CONFIG_PAX_KERNEXEC
30683 + struct desc_struct d;
30684 +
30685 + memset(&d, 0, sizeof d);
30686 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30687 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30688 +#endif
30689 +
30690 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30691 gdt_descr.size = GDT_SIZE - 1;
30692 load_gdt(&gdt_descr);
30693 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30694 index fbe66e6..eae5e38 100644
30695 --- a/arch/x86/platform/efi/efi_stub_32.S
30696 +++ b/arch/x86/platform/efi/efi_stub_32.S
30697 @@ -6,7 +6,9 @@
30698 */
30699
30700 #include <linux/linkage.h>
30701 +#include <linux/init.h>
30702 #include <asm/page_types.h>
30703 +#include <asm/segment.h>
30704
30705 /*
30706 * efi_call_phys(void *, ...) is a function with variable parameters.
30707 @@ -20,7 +22,7 @@
30708 * service functions will comply with gcc calling convention, too.
30709 */
30710
30711 -.text
30712 +__INIT
30713 ENTRY(efi_call_phys)
30714 /*
30715 * 0. The function can only be called in Linux kernel. So CS has been
30716 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30717 * The mapping of lower virtual memory has been created in prelog and
30718 * epilog.
30719 */
30720 - movl $1f, %edx
30721 - subl $__PAGE_OFFSET, %edx
30722 - jmp *%edx
30723 +#ifdef CONFIG_PAX_KERNEXEC
30724 + movl $(__KERNEXEC_EFI_DS), %edx
30725 + mov %edx, %ds
30726 + mov %edx, %es
30727 + mov %edx, %ss
30728 + addl $2f,(1f)
30729 + ljmp *(1f)
30730 +
30731 +__INITDATA
30732 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30733 +.previous
30734 +
30735 +2:
30736 + subl $2b,(1b)
30737 +#else
30738 + jmp 1f-__PAGE_OFFSET
30739 1:
30740 +#endif
30741
30742 /*
30743 * 2. Now on the top of stack is the return
30744 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30745 * parameter 2, ..., param n. To make things easy, we save the return
30746 * address of efi_call_phys in a global variable.
30747 */
30748 - popl %edx
30749 - movl %edx, saved_return_addr
30750 - /* get the function pointer into ECX*/
30751 - popl %ecx
30752 - movl %ecx, efi_rt_function_ptr
30753 - movl $2f, %edx
30754 - subl $__PAGE_OFFSET, %edx
30755 - pushl %edx
30756 + popl (saved_return_addr)
30757 + popl (efi_rt_function_ptr)
30758
30759 /*
30760 * 3. Clear PG bit in %CR0.
30761 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30762 /*
30763 * 5. Call the physical function.
30764 */
30765 - jmp *%ecx
30766 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30767
30768 -2:
30769 /*
30770 * 6. After EFI runtime service returns, control will return to
30771 * following instruction. We'd better readjust stack pointer first.
30772 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30773 movl %cr0, %edx
30774 orl $0x80000000, %edx
30775 movl %edx, %cr0
30776 - jmp 1f
30777 -1:
30778 +
30779 /*
30780 * 8. Now restore the virtual mode from flat mode by
30781 * adding EIP with PAGE_OFFSET.
30782 */
30783 - movl $1f, %edx
30784 - jmp *%edx
30785 +#ifdef CONFIG_PAX_KERNEXEC
30786 + movl $(__KERNEL_DS), %edx
30787 + mov %edx, %ds
30788 + mov %edx, %es
30789 + mov %edx, %ss
30790 + ljmp $(__KERNEL_CS),$1f
30791 +#else
30792 + jmp 1f+__PAGE_OFFSET
30793 +#endif
30794 1:
30795
30796 /*
30797 * 9. Balance the stack. And because EAX contain the return value,
30798 * we'd better not clobber it.
30799 */
30800 - leal efi_rt_function_ptr, %edx
30801 - movl (%edx), %ecx
30802 - pushl %ecx
30803 + pushl (efi_rt_function_ptr)
30804
30805 /*
30806 - * 10. Push the saved return address onto the stack and return.
30807 + * 10. Return to the saved return address.
30808 */
30809 - leal saved_return_addr, %edx
30810 - movl (%edx), %ecx
30811 - pushl %ecx
30812 - ret
30813 + jmpl *(saved_return_addr)
30814 ENDPROC(efi_call_phys)
30815 .previous
30816
30817 -.data
30818 +__INITDATA
30819 saved_return_addr:
30820 .long 0
30821 efi_rt_function_ptr:
30822 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30823 index 4c07cca..2c8427d 100644
30824 --- a/arch/x86/platform/efi/efi_stub_64.S
30825 +++ b/arch/x86/platform/efi/efi_stub_64.S
30826 @@ -7,6 +7,7 @@
30827 */
30828
30829 #include <linux/linkage.h>
30830 +#include <asm/alternative-asm.h>
30831
30832 #define SAVE_XMM \
30833 mov %rsp, %rax; \
30834 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30835 call *%rdi
30836 addq $32, %rsp
30837 RESTORE_XMM
30838 + pax_force_retaddr 0, 1
30839 ret
30840 ENDPROC(efi_call0)
30841
30842 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30843 call *%rdi
30844 addq $32, %rsp
30845 RESTORE_XMM
30846 + pax_force_retaddr 0, 1
30847 ret
30848 ENDPROC(efi_call1)
30849
30850 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30851 call *%rdi
30852 addq $32, %rsp
30853 RESTORE_XMM
30854 + pax_force_retaddr 0, 1
30855 ret
30856 ENDPROC(efi_call2)
30857
30858 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30859 call *%rdi
30860 addq $32, %rsp
30861 RESTORE_XMM
30862 + pax_force_retaddr 0, 1
30863 ret
30864 ENDPROC(efi_call3)
30865
30866 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30867 call *%rdi
30868 addq $32, %rsp
30869 RESTORE_XMM
30870 + pax_force_retaddr 0, 1
30871 ret
30872 ENDPROC(efi_call4)
30873
30874 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30875 call *%rdi
30876 addq $48, %rsp
30877 RESTORE_XMM
30878 + pax_force_retaddr 0, 1
30879 ret
30880 ENDPROC(efi_call5)
30881
30882 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30883 call *%rdi
30884 addq $48, %rsp
30885 RESTORE_XMM
30886 + pax_force_retaddr 0, 1
30887 ret
30888 ENDPROC(efi_call6)
30889 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30890 index e31bcd8..f12dc46 100644
30891 --- a/arch/x86/platform/mrst/mrst.c
30892 +++ b/arch/x86/platform/mrst/mrst.c
30893 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30894 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30895 int sfi_mrtc_num;
30896
30897 -static void mrst_power_off(void)
30898 +static __noreturn void mrst_power_off(void)
30899 {
30900 + BUG();
30901 }
30902
30903 -static void mrst_reboot(void)
30904 +static __noreturn void mrst_reboot(void)
30905 {
30906 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30907 + BUG();
30908 }
30909
30910 /* parse all the mtimer info to a static mtimer array */
30911 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30912 index d6ee929..3637cb5 100644
30913 --- a/arch/x86/platform/olpc/olpc_dt.c
30914 +++ b/arch/x86/platform/olpc/olpc_dt.c
30915 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30916 return res;
30917 }
30918
30919 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30920 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30921 .nextprop = olpc_dt_nextprop,
30922 .getproplen = olpc_dt_getproplen,
30923 .getproperty = olpc_dt_getproperty,
30924 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30925 index 3c68768..07e82b8 100644
30926 --- a/arch/x86/power/cpu.c
30927 +++ b/arch/x86/power/cpu.c
30928 @@ -134,7 +134,7 @@ static void do_fpu_end(void)
30929 static void fix_processor_context(void)
30930 {
30931 int cpu = smp_processor_id();
30932 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30933 + struct tss_struct *t = init_tss + cpu;
30934
30935 set_tss_desc(cpu, t); /*
30936 * This just modifies memory; should not be
30937 @@ -144,8 +144,6 @@ static void fix_processor_context(void)
30938 */
30939
30940 #ifdef CONFIG_X86_64
30941 - get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
30942 -
30943 syscall_init(); /* This sets MSR_*STAR and related */
30944 #endif
30945 load_TR_desc(); /* This does ltr */
30946 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
30947 index cbca565..bae7133 100644
30948 --- a/arch/x86/realmode/init.c
30949 +++ b/arch/x86/realmode/init.c
30950 @@ -62,7 +62,13 @@ void __init setup_real_mode(void)
30951 __va(real_mode_header->trampoline_header);
30952
30953 #ifdef CONFIG_X86_32
30954 - trampoline_header->start = __pa(startup_32_smp);
30955 + trampoline_header->start = __pa(ktla_ktva(startup_32_smp));
30956 +
30957 +#ifdef CONFIG_PAX_KERNEXEC
30958 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
30959 +#endif
30960 +
30961 + trampoline_header->boot_cs = __BOOT_CS;
30962 trampoline_header->gdt_limit = __BOOT_DS + 7;
30963 trampoline_header->gdt_base = __pa(boot_gdt);
30964 #else
30965 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
30966 index 8869287..d577672 100644
30967 --- a/arch/x86/realmode/rm/Makefile
30968 +++ b/arch/x86/realmode/rm/Makefile
30969 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
30970 $(call cc-option, -fno-unit-at-a-time)) \
30971 $(call cc-option, -fno-stack-protector) \
30972 $(call cc-option, -mpreferred-stack-boundary=2)
30973 +ifdef CONSTIFY_PLUGIN
30974 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
30975 +endif
30976 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
30977 GCOV_PROFILE := n
30978 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
30979 index a28221d..93c40f1 100644
30980 --- a/arch/x86/realmode/rm/header.S
30981 +++ b/arch/x86/realmode/rm/header.S
30982 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
30983 #endif
30984 /* APM/BIOS reboot */
30985 .long pa_machine_real_restart_asm
30986 -#ifdef CONFIG_X86_64
30987 +#ifdef CONFIG_X86_32
30988 + .long __KERNEL_CS
30989 +#else
30990 .long __KERNEL32_CS
30991 #endif
30992 END(real_mode_header)
30993 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
30994 index c1b2791..f9e31c7 100644
30995 --- a/arch/x86/realmode/rm/trampoline_32.S
30996 +++ b/arch/x86/realmode/rm/trampoline_32.S
30997 @@ -25,6 +25,12 @@
30998 #include <asm/page_types.h>
30999 #include "realmode.h"
31000
31001 +#ifdef CONFIG_PAX_KERNEXEC
31002 +#define ta(X) (X)
31003 +#else
31004 +#define ta(X) (pa_ ## X)
31005 +#endif
31006 +
31007 .text
31008 .code16
31009
31010 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
31011
31012 cli # We should be safe anyway
31013
31014 - movl tr_start, %eax # where we need to go
31015 -
31016 movl $0xA5A5A5A5, trampoline_status
31017 # write marker for master knows we're running
31018
31019 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
31020 movw $1, %dx # protected mode (PE) bit
31021 lmsw %dx # into protected mode
31022
31023 - ljmpl $__BOOT_CS, $pa_startup_32
31024 + ljmpl *(trampoline_header)
31025
31026 .section ".text32","ax"
31027 .code32
31028 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
31029 .balign 8
31030 GLOBAL(trampoline_header)
31031 tr_start: .space 4
31032 - tr_gdt_pad: .space 2
31033 + tr_boot_cs: .space 2
31034 tr_gdt: .space 6
31035 END(trampoline_header)
31036
31037 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
31038 index bb360dc..3e5945f 100644
31039 --- a/arch/x86/realmode/rm/trampoline_64.S
31040 +++ b/arch/x86/realmode/rm/trampoline_64.S
31041 @@ -107,7 +107,7 @@ ENTRY(startup_32)
31042 wrmsr
31043
31044 # Enable paging and in turn activate Long Mode
31045 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
31046 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
31047 movl %eax, %cr0
31048
31049 /*
31050 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
31051 index 79d67bd..c7e1b90 100644
31052 --- a/arch/x86/tools/relocs.c
31053 +++ b/arch/x86/tools/relocs.c
31054 @@ -12,10 +12,13 @@
31055 #include <regex.h>
31056 #include <tools/le_byteshift.h>
31057
31058 +#include "../../../include/generated/autoconf.h"
31059 +
31060 static void die(char *fmt, ...);
31061
31062 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
31063 static Elf32_Ehdr ehdr;
31064 +static Elf32_Phdr *phdr;
31065 static unsigned long reloc_count, reloc_idx;
31066 static unsigned long *relocs;
31067 static unsigned long reloc16_count, reloc16_idx;
31068 @@ -330,9 +333,39 @@ static void read_ehdr(FILE *fp)
31069 }
31070 }
31071
31072 +static void read_phdrs(FILE *fp)
31073 +{
31074 + unsigned int i;
31075 +
31076 + phdr = calloc(ehdr.e_phnum, sizeof(Elf32_Phdr));
31077 + if (!phdr) {
31078 + die("Unable to allocate %d program headers\n",
31079 + ehdr.e_phnum);
31080 + }
31081 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
31082 + die("Seek to %d failed: %s\n",
31083 + ehdr.e_phoff, strerror(errno));
31084 + }
31085 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
31086 + die("Cannot read ELF program headers: %s\n",
31087 + strerror(errno));
31088 + }
31089 + for(i = 0; i < ehdr.e_phnum; i++) {
31090 + phdr[i].p_type = elf32_to_cpu(phdr[i].p_type);
31091 + phdr[i].p_offset = elf32_to_cpu(phdr[i].p_offset);
31092 + phdr[i].p_vaddr = elf32_to_cpu(phdr[i].p_vaddr);
31093 + phdr[i].p_paddr = elf32_to_cpu(phdr[i].p_paddr);
31094 + phdr[i].p_filesz = elf32_to_cpu(phdr[i].p_filesz);
31095 + phdr[i].p_memsz = elf32_to_cpu(phdr[i].p_memsz);
31096 + phdr[i].p_flags = elf32_to_cpu(phdr[i].p_flags);
31097 + phdr[i].p_align = elf32_to_cpu(phdr[i].p_align);
31098 + }
31099 +
31100 +}
31101 +
31102 static void read_shdrs(FILE *fp)
31103 {
31104 - int i;
31105 + unsigned int i;
31106 Elf32_Shdr shdr;
31107
31108 secs = calloc(ehdr.e_shnum, sizeof(struct section));
31109 @@ -367,7 +400,7 @@ static void read_shdrs(FILE *fp)
31110
31111 static void read_strtabs(FILE *fp)
31112 {
31113 - int i;
31114 + unsigned int i;
31115 for (i = 0; i < ehdr.e_shnum; i++) {
31116 struct section *sec = &secs[i];
31117 if (sec->shdr.sh_type != SHT_STRTAB) {
31118 @@ -392,7 +425,7 @@ static void read_strtabs(FILE *fp)
31119
31120 static void read_symtabs(FILE *fp)
31121 {
31122 - int i,j;
31123 + unsigned int i,j;
31124 for (i = 0; i < ehdr.e_shnum; i++) {
31125 struct section *sec = &secs[i];
31126 if (sec->shdr.sh_type != SHT_SYMTAB) {
31127 @@ -423,9 +456,11 @@ static void read_symtabs(FILE *fp)
31128 }
31129
31130
31131 -static void read_relocs(FILE *fp)
31132 +static void read_relocs(FILE *fp, int use_real_mode)
31133 {
31134 - int i,j;
31135 + unsigned int i,j;
31136 + uint32_t base;
31137 +
31138 for (i = 0; i < ehdr.e_shnum; i++) {
31139 struct section *sec = &secs[i];
31140 if (sec->shdr.sh_type != SHT_REL) {
31141 @@ -445,9 +480,22 @@ static void read_relocs(FILE *fp)
31142 die("Cannot read symbol table: %s\n",
31143 strerror(errno));
31144 }
31145 + base = 0;
31146 +
31147 +#ifdef CONFIG_X86_32
31148 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
31149 + if (phdr[j].p_type != PT_LOAD )
31150 + continue;
31151 + 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)
31152 + continue;
31153 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
31154 + break;
31155 + }
31156 +#endif
31157 +
31158 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
31159 Elf32_Rel *rel = &sec->reltab[j];
31160 - rel->r_offset = elf32_to_cpu(rel->r_offset);
31161 + rel->r_offset = elf32_to_cpu(rel->r_offset) + base;
31162 rel->r_info = elf32_to_cpu(rel->r_info);
31163 }
31164 }
31165 @@ -456,13 +504,13 @@ static void read_relocs(FILE *fp)
31166
31167 static void print_absolute_symbols(void)
31168 {
31169 - int i;
31170 + unsigned int i;
31171 printf("Absolute symbols\n");
31172 printf(" Num: Value Size Type Bind Visibility Name\n");
31173 for (i = 0; i < ehdr.e_shnum; i++) {
31174 struct section *sec = &secs[i];
31175 char *sym_strtab;
31176 - int j;
31177 + unsigned int j;
31178
31179 if (sec->shdr.sh_type != SHT_SYMTAB) {
31180 continue;
31181 @@ -489,14 +537,14 @@ static void print_absolute_symbols(void)
31182
31183 static void print_absolute_relocs(void)
31184 {
31185 - int i, printed = 0;
31186 + unsigned int i, printed = 0;
31187
31188 for (i = 0; i < ehdr.e_shnum; i++) {
31189 struct section *sec = &secs[i];
31190 struct section *sec_applies, *sec_symtab;
31191 char *sym_strtab;
31192 Elf32_Sym *sh_symtab;
31193 - int j;
31194 + unsigned int j;
31195 if (sec->shdr.sh_type != SHT_REL) {
31196 continue;
31197 }
31198 @@ -558,13 +606,13 @@ static void print_absolute_relocs(void)
31199 static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
31200 int use_real_mode)
31201 {
31202 - int i;
31203 + unsigned int i;
31204 /* Walk through the relocations */
31205 for (i = 0; i < ehdr.e_shnum; i++) {
31206 char *sym_strtab;
31207 Elf32_Sym *sh_symtab;
31208 struct section *sec_applies, *sec_symtab;
31209 - int j;
31210 + unsigned int j;
31211 struct section *sec = &secs[i];
31212
31213 if (sec->shdr.sh_type != SHT_REL) {
31214 @@ -588,6 +636,24 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
31215 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
31216 r_type = ELF32_R_TYPE(rel->r_info);
31217
31218 + if (!use_real_mode) {
31219 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
31220 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
31221 + continue;
31222 +
31223 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_X86_32)
31224 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
31225 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
31226 + continue;
31227 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
31228 + continue;
31229 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
31230 + continue;
31231 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
31232 + continue;
31233 +#endif
31234 + }
31235 +
31236 shn_abs = sym->st_shndx == SHN_ABS;
31237
31238 switch (r_type) {
31239 @@ -681,7 +747,7 @@ static int write32(unsigned int v, FILE *f)
31240
31241 static void emit_relocs(int as_text, int use_real_mode)
31242 {
31243 - int i;
31244 + unsigned int i;
31245 /* Count how many relocations I have and allocate space for them. */
31246 reloc_count = 0;
31247 walk_relocs(count_reloc, use_real_mode);
31248 @@ -808,10 +874,11 @@ int main(int argc, char **argv)
31249 fname, strerror(errno));
31250 }
31251 read_ehdr(fp);
31252 + read_phdrs(fp);
31253 read_shdrs(fp);
31254 read_strtabs(fp);
31255 read_symtabs(fp);
31256 - read_relocs(fp);
31257 + read_relocs(fp, use_real_mode);
31258 if (show_absolute_syms) {
31259 print_absolute_symbols();
31260 goto out;
31261 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
31262 index fd14be1..e3c79c0 100644
31263 --- a/arch/x86/vdso/Makefile
31264 +++ b/arch/x86/vdso/Makefile
31265 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
31266 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
31267 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
31268
31269 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31270 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31271 GCOV_PROFILE := n
31272
31273 #
31274 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
31275 index 0faad64..39ef157 100644
31276 --- a/arch/x86/vdso/vdso32-setup.c
31277 +++ b/arch/x86/vdso/vdso32-setup.c
31278 @@ -25,6 +25,7 @@
31279 #include <asm/tlbflush.h>
31280 #include <asm/vdso.h>
31281 #include <asm/proto.h>
31282 +#include <asm/mman.h>
31283
31284 enum {
31285 VDSO_DISABLED = 0,
31286 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
31287 void enable_sep_cpu(void)
31288 {
31289 int cpu = get_cpu();
31290 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
31291 + struct tss_struct *tss = init_tss + cpu;
31292
31293 if (!boot_cpu_has(X86_FEATURE_SEP)) {
31294 put_cpu();
31295 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
31296 gate_vma.vm_start = FIXADDR_USER_START;
31297 gate_vma.vm_end = FIXADDR_USER_END;
31298 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
31299 - gate_vma.vm_page_prot = __P101;
31300 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
31301
31302 return 0;
31303 }
31304 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31305 if (compat)
31306 addr = VDSO_HIGH_BASE;
31307 else {
31308 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
31309 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
31310 if (IS_ERR_VALUE(addr)) {
31311 ret = addr;
31312 goto up_fail;
31313 }
31314 }
31315
31316 - current->mm->context.vdso = (void *)addr;
31317 + current->mm->context.vdso = addr;
31318
31319 if (compat_uses_vma || !compat) {
31320 /*
31321 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31322 }
31323
31324 current_thread_info()->sysenter_return =
31325 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31326 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31327
31328 up_fail:
31329 if (ret)
31330 - current->mm->context.vdso = NULL;
31331 + current->mm->context.vdso = 0;
31332
31333 up_write(&mm->mmap_sem);
31334
31335 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
31336
31337 const char *arch_vma_name(struct vm_area_struct *vma)
31338 {
31339 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31340 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31341 return "[vdso]";
31342 +
31343 +#ifdef CONFIG_PAX_SEGMEXEC
31344 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
31345 + return "[vdso]";
31346 +#endif
31347 +
31348 return NULL;
31349 }
31350
31351 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31352 * Check to see if the corresponding task was created in compat vdso
31353 * mode.
31354 */
31355 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
31356 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
31357 return &gate_vma;
31358 return NULL;
31359 }
31360 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
31361 index 431e875..cbb23f3 100644
31362 --- a/arch/x86/vdso/vma.c
31363 +++ b/arch/x86/vdso/vma.c
31364 @@ -16,8 +16,6 @@
31365 #include <asm/vdso.h>
31366 #include <asm/page.h>
31367
31368 -unsigned int __read_mostly vdso_enabled = 1;
31369 -
31370 extern char vdso_start[], vdso_end[];
31371 extern unsigned short vdso_sync_cpuid;
31372
31373 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
31374 * unaligned here as a result of stack start randomization.
31375 */
31376 addr = PAGE_ALIGN(addr);
31377 - addr = align_vdso_addr(addr);
31378
31379 return addr;
31380 }
31381 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
31382 unsigned size)
31383 {
31384 struct mm_struct *mm = current->mm;
31385 - unsigned long addr;
31386 + unsigned long addr = 0;
31387 int ret;
31388
31389 - if (!vdso_enabled)
31390 - return 0;
31391 -
31392 down_write(&mm->mmap_sem);
31393 +
31394 +#ifdef CONFIG_PAX_RANDMMAP
31395 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31396 +#endif
31397 +
31398 addr = vdso_addr(mm->start_stack, size);
31399 + addr = align_vdso_addr(addr);
31400 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31401 if (IS_ERR_VALUE(addr)) {
31402 ret = addr;
31403 goto up_fail;
31404 }
31405
31406 - current->mm->context.vdso = (void *)addr;
31407 + mm->context.vdso = addr;
31408
31409 ret = install_special_mapping(mm, addr, size,
31410 VM_READ|VM_EXEC|
31411 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31412 pages);
31413 - if (ret) {
31414 - current->mm->context.vdso = NULL;
31415 - goto up_fail;
31416 - }
31417 + if (ret)
31418 + mm->context.vdso = 0;
31419
31420 up_fail:
31421 up_write(&mm->mmap_sem);
31422 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31423 vdsox32_size);
31424 }
31425 #endif
31426 -
31427 -static __init int vdso_setup(char *s)
31428 -{
31429 - vdso_enabled = simple_strtoul(s, NULL, 0);
31430 - return 0;
31431 -}
31432 -__setup("vdso=", vdso_setup);
31433 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
31434 index 2262003..f229ced 100644
31435 --- a/arch/x86/xen/enlighten.c
31436 +++ b/arch/x86/xen/enlighten.c
31437 @@ -100,8 +100,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
31438
31439 struct shared_info xen_dummy_shared_info;
31440
31441 -void *xen_initial_gdt;
31442 -
31443 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
31444 __read_mostly int xen_have_vector_callback;
31445 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
31446 @@ -496,8 +494,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
31447 {
31448 unsigned long va = dtr->address;
31449 unsigned int size = dtr->size + 1;
31450 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31451 - unsigned long frames[pages];
31452 + unsigned long frames[65536 / PAGE_SIZE];
31453 int f;
31454
31455 /*
31456 @@ -545,8 +542,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31457 {
31458 unsigned long va = dtr->address;
31459 unsigned int size = dtr->size + 1;
31460 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31461 - unsigned long frames[pages];
31462 + unsigned long frames[65536 / PAGE_SIZE];
31463 int f;
31464
31465 /*
31466 @@ -939,7 +935,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
31467 return 0;
31468 }
31469
31470 -static void set_xen_basic_apic_ops(void)
31471 +static void __init set_xen_basic_apic_ops(void)
31472 {
31473 apic->read = xen_apic_read;
31474 apic->write = xen_apic_write;
31475 @@ -1245,30 +1241,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
31476 #endif
31477 };
31478
31479 -static void xen_reboot(int reason)
31480 +static __noreturn void xen_reboot(int reason)
31481 {
31482 struct sched_shutdown r = { .reason = reason };
31483
31484 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
31485 - BUG();
31486 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
31487 + BUG();
31488 }
31489
31490 -static void xen_restart(char *msg)
31491 +static __noreturn void xen_restart(char *msg)
31492 {
31493 xen_reboot(SHUTDOWN_reboot);
31494 }
31495
31496 -static void xen_emergency_restart(void)
31497 +static __noreturn void xen_emergency_restart(void)
31498 {
31499 xen_reboot(SHUTDOWN_reboot);
31500 }
31501
31502 -static void xen_machine_halt(void)
31503 +static __noreturn void xen_machine_halt(void)
31504 {
31505 xen_reboot(SHUTDOWN_poweroff);
31506 }
31507
31508 -static void xen_machine_power_off(void)
31509 +static __noreturn void xen_machine_power_off(void)
31510 {
31511 if (pm_power_off)
31512 pm_power_off();
31513 @@ -1370,7 +1366,17 @@ asmlinkage void __init xen_start_kernel(void)
31514 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
31515
31516 /* Work out if we support NX */
31517 - x86_configure_nx();
31518 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31519 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31520 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31521 + unsigned l, h;
31522 +
31523 + __supported_pte_mask |= _PAGE_NX;
31524 + rdmsr(MSR_EFER, l, h);
31525 + l |= EFER_NX;
31526 + wrmsr(MSR_EFER, l, h);
31527 + }
31528 +#endif
31529
31530 xen_setup_features();
31531
31532 @@ -1399,14 +1405,7 @@ asmlinkage void __init xen_start_kernel(void)
31533 pv_mmu_ops.ptep_modify_prot_commit = xen_ptep_modify_prot_commit;
31534 }
31535
31536 - machine_ops = xen_machine_ops;
31537 -
31538 - /*
31539 - * The only reliable way to retain the initial address of the
31540 - * percpu gdt_page is to remember it here, so we can go and
31541 - * mark it RW later, when the initial percpu area is freed.
31542 - */
31543 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31544 + memcpy((void *)&machine_ops, &xen_machine_ops, sizeof machine_ops);
31545
31546 xen_smp_init();
31547
31548 @@ -1598,7 +1597,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31549 return NOTIFY_OK;
31550 }
31551
31552 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31553 +static struct notifier_block xen_hvm_cpu_notifier = {
31554 .notifier_call = xen_hvm_cpu_notify,
31555 };
31556
31557 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31558 index 01de35c..692023f 100644
31559 --- a/arch/x86/xen/mmu.c
31560 +++ b/arch/x86/xen/mmu.c
31561 @@ -1739,14 +1739,18 @@ static void *m2v(phys_addr_t maddr)
31562 }
31563
31564 /* Set the page permissions on an identity-mapped pages */
31565 -static void set_page_prot(void *addr, pgprot_t prot)
31566 +static void set_page_prot_flags(void *addr, pgprot_t prot, unsigned long flags)
31567 {
31568 unsigned long pfn = __pa(addr) >> PAGE_SHIFT;
31569 pte_t pte = pfn_pte(pfn, prot);
31570
31571 - if (HYPERVISOR_update_va_mapping((unsigned long)addr, pte, 0))
31572 + if (HYPERVISOR_update_va_mapping((unsigned long)addr, pte, flags))
31573 BUG();
31574 }
31575 +static void set_page_prot(void *addr, pgprot_t prot)
31576 +{
31577 + return set_page_prot_flags(addr, prot, UVMF_NONE);
31578 +}
31579 #ifdef CONFIG_X86_32
31580 static void __init xen_map_identity_early(pmd_t *pmd, unsigned long max_pfn)
31581 {
31582 @@ -1830,12 +1834,12 @@ static void __init check_pt_base(unsigned long *pt_base, unsigned long *pt_end,
31583 unsigned long addr)
31584 {
31585 if (*pt_base == PFN_DOWN(__pa(addr))) {
31586 - set_page_prot((void *)addr, PAGE_KERNEL);
31587 + set_page_prot_flags((void *)addr, PAGE_KERNEL, UVMF_INVLPG);
31588 clear_page((void *)addr);
31589 (*pt_base)++;
31590 }
31591 if (*pt_end == PFN_DOWN(__pa(addr))) {
31592 - set_page_prot((void *)addr, PAGE_KERNEL);
31593 + set_page_prot_flags((void *)addr, PAGE_KERNEL, UVMF_INVLPG);
31594 clear_page((void *)addr);
31595 (*pt_end)--;
31596 }
31597 @@ -1881,6 +1885,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31598 /* L3_k[510] -> level2_kernel_pgt
31599 * L3_i[511] -> level2_fixmap_pgt */
31600 convert_pfn_mfn(level3_kernel_pgt);
31601 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31602 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31603 + convert_pfn_mfn(level3_vmemmap_pgt);
31604
31605 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31606 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31607 @@ -1910,8 +1917,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31608 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31609 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31610 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31611 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31612 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31613 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31614 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31615 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31616 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31617 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31618 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31619
31620 @@ -2097,6 +2108,7 @@ static void __init xen_post_allocator_init(void)
31621 pv_mmu_ops.set_pud = xen_set_pud;
31622 #if PAGETABLE_LEVELS == 4
31623 pv_mmu_ops.set_pgd = xen_set_pgd;
31624 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31625 #endif
31626
31627 /* This will work as long as patching hasn't happened yet
31628 @@ -2178,6 +2190,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31629 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31630 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31631 .set_pgd = xen_set_pgd_hyper,
31632 + .set_pgd_batched = xen_set_pgd_hyper,
31633
31634 .alloc_pud = xen_alloc_pmd_init,
31635 .release_pud = xen_release_pmd_init,
31636 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31637 index 34bc4ce..c34aa24 100644
31638 --- a/arch/x86/xen/smp.c
31639 +++ b/arch/x86/xen/smp.c
31640 @@ -229,11 +229,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31641 {
31642 BUG_ON(smp_processor_id() != 0);
31643 native_smp_prepare_boot_cpu();
31644 -
31645 - /* We've switched to the "real" per-cpu gdt, so make sure the
31646 - old memory can be recycled */
31647 - make_lowmem_page_readwrite(xen_initial_gdt);
31648 -
31649 xen_filter_cpu_maps();
31650 xen_setup_vcpu_info_placement();
31651 }
31652 @@ -300,12 +295,12 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31653 gdt = get_cpu_gdt_table(cpu);
31654
31655 ctxt->flags = VGCF_IN_KERNEL;
31656 - ctxt->user_regs.ds = __USER_DS;
31657 - ctxt->user_regs.es = __USER_DS;
31658 + ctxt->user_regs.ds = __KERNEL_DS;
31659 + ctxt->user_regs.es = __KERNEL_DS;
31660 ctxt->user_regs.ss = __KERNEL_DS;
31661 #ifdef CONFIG_X86_32
31662 ctxt->user_regs.fs = __KERNEL_PERCPU;
31663 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31664 + savesegment(gs, ctxt->user_regs.gs);
31665 #else
31666 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31667 #endif
31668 @@ -355,13 +350,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31669 int rc;
31670
31671 per_cpu(current_task, cpu) = idle;
31672 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31673 #ifdef CONFIG_X86_32
31674 irq_ctx_init(cpu);
31675 #else
31676 clear_tsk_thread_flag(idle, TIF_FORK);
31677 - per_cpu(kernel_stack, cpu) =
31678 - (unsigned long)task_stack_page(idle) -
31679 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31680 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31681 #endif
31682 xen_setup_runstate_info(cpu);
31683 xen_setup_timer(cpu);
31684 @@ -630,7 +624,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31685
31686 void __init xen_smp_init(void)
31687 {
31688 - smp_ops = xen_smp_ops;
31689 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31690 xen_fill_possible_map();
31691 xen_init_spinlocks();
31692 }
31693 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31694 index 33ca6e4..0ded929 100644
31695 --- a/arch/x86/xen/xen-asm_32.S
31696 +++ b/arch/x86/xen/xen-asm_32.S
31697 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31698 ESP_OFFSET=4 # bytes pushed onto stack
31699
31700 /*
31701 - * Store vcpu_info pointer for easy access. Do it this way to
31702 - * avoid having to reload %fs
31703 + * Store vcpu_info pointer for easy access.
31704 */
31705 #ifdef CONFIG_SMP
31706 - GET_THREAD_INFO(%eax)
31707 - movl %ss:TI_cpu(%eax), %eax
31708 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31709 - mov %ss:xen_vcpu(%eax), %eax
31710 + push %fs
31711 + mov $(__KERNEL_PERCPU), %eax
31712 + mov %eax, %fs
31713 + mov PER_CPU_VAR(xen_vcpu), %eax
31714 + pop %fs
31715 #else
31716 movl %ss:xen_vcpu, %eax
31717 #endif
31718 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31719 index 7faed58..ba4427c 100644
31720 --- a/arch/x86/xen/xen-head.S
31721 +++ b/arch/x86/xen/xen-head.S
31722 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31723 #ifdef CONFIG_X86_32
31724 mov %esi,xen_start_info
31725 mov $init_thread_union+THREAD_SIZE,%esp
31726 +#ifdef CONFIG_SMP
31727 + movl $cpu_gdt_table,%edi
31728 + movl $__per_cpu_load,%eax
31729 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31730 + rorl $16,%eax
31731 + movb %al,__KERNEL_PERCPU + 4(%edi)
31732 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31733 + movl $__per_cpu_end - 1,%eax
31734 + subl $__per_cpu_start,%eax
31735 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31736 +#endif
31737 #else
31738 mov %rsi,xen_start_info
31739 mov $init_thread_union+THREAD_SIZE,%rsp
31740 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31741 index a95b417..b6dbd0b 100644
31742 --- a/arch/x86/xen/xen-ops.h
31743 +++ b/arch/x86/xen/xen-ops.h
31744 @@ -10,8 +10,6 @@
31745 extern const char xen_hypervisor_callback[];
31746 extern const char xen_failsafe_callback[];
31747
31748 -extern void *xen_initial_gdt;
31749 -
31750 struct trap_info;
31751 void xen_copy_trap_info(struct trap_info *traps);
31752
31753 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31754 index 525bd3d..ef888b1 100644
31755 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31756 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31757 @@ -119,9 +119,9 @@
31758 ----------------------------------------------------------------------*/
31759
31760 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31761 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31762 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31763 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31764 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31765
31766 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31767 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31768 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31769 index 2f33760..835e50a 100644
31770 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31771 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31772 @@ -11,6 +11,7 @@
31773 #ifndef _XTENSA_CORE_H
31774 #define _XTENSA_CORE_H
31775
31776 +#include <linux/const.h>
31777
31778 /****************************************************************************
31779 Parameters Useful for Any Code, USER or PRIVILEGED
31780 @@ -112,9 +113,9 @@
31781 ----------------------------------------------------------------------*/
31782
31783 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31784 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31785 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31786 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31787 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31788
31789 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31790 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31791 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31792 index af00795..2bb8105 100644
31793 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31794 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31795 @@ -11,6 +11,7 @@
31796 #ifndef _XTENSA_CORE_CONFIGURATION_H
31797 #define _XTENSA_CORE_CONFIGURATION_H
31798
31799 +#include <linux/const.h>
31800
31801 /****************************************************************************
31802 Parameters Useful for Any Code, USER or PRIVILEGED
31803 @@ -118,9 +119,9 @@
31804 ----------------------------------------------------------------------*/
31805
31806 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31807 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31808 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31809 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31810 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31811
31812 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31813 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31814 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31815 index 58916af..eb9dbcf6 100644
31816 --- a/block/blk-iopoll.c
31817 +++ b/block/blk-iopoll.c
31818 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31819 }
31820 EXPORT_SYMBOL(blk_iopoll_complete);
31821
31822 -static void blk_iopoll_softirq(struct softirq_action *h)
31823 +static void blk_iopoll_softirq(void)
31824 {
31825 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31826 int rearm = 0, budget = blk_iopoll_budget;
31827 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31828 return NOTIFY_OK;
31829 }
31830
31831 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31832 +static struct notifier_block blk_iopoll_cpu_notifier = {
31833 .notifier_call = blk_iopoll_cpu_notify,
31834 };
31835
31836 diff --git a/block/blk-map.c b/block/blk-map.c
31837 index 623e1cd..ca1e109 100644
31838 --- a/block/blk-map.c
31839 +++ b/block/blk-map.c
31840 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31841 if (!len || !kbuf)
31842 return -EINVAL;
31843
31844 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31845 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31846 if (do_copy)
31847 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31848 else
31849 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31850 index 467c8de..f3628c5 100644
31851 --- a/block/blk-softirq.c
31852 +++ b/block/blk-softirq.c
31853 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31854 * Softirq action handler - move entries to local list and loop over them
31855 * while passing them to the queue registered handler.
31856 */
31857 -static void blk_done_softirq(struct softirq_action *h)
31858 +static void blk_done_softirq(void)
31859 {
31860 struct list_head *cpu_list, local_list;
31861
31862 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31863 return NOTIFY_OK;
31864 }
31865
31866 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31867 +static struct notifier_block blk_cpu_notifier = {
31868 .notifier_call = blk_cpu_notify,
31869 };
31870
31871 diff --git a/block/bsg.c b/block/bsg.c
31872 index ff64ae3..593560c 100644
31873 --- a/block/bsg.c
31874 +++ b/block/bsg.c
31875 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31876 struct sg_io_v4 *hdr, struct bsg_device *bd,
31877 fmode_t has_write_perm)
31878 {
31879 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31880 + unsigned char *cmdptr;
31881 +
31882 if (hdr->request_len > BLK_MAX_CDB) {
31883 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31884 if (!rq->cmd)
31885 return -ENOMEM;
31886 - }
31887 + cmdptr = rq->cmd;
31888 + } else
31889 + cmdptr = tmpcmd;
31890
31891 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31892 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31893 hdr->request_len))
31894 return -EFAULT;
31895
31896 + if (cmdptr != rq->cmd)
31897 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31898 +
31899 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31900 if (blk_verify_command(rq->cmd, has_write_perm))
31901 return -EPERM;
31902 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31903 index 7c668c8..db3521c 100644
31904 --- a/block/compat_ioctl.c
31905 +++ b/block/compat_ioctl.c
31906 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31907 err |= __get_user(f->spec1, &uf->spec1);
31908 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31909 err |= __get_user(name, &uf->name);
31910 - f->name = compat_ptr(name);
31911 + f->name = (void __force_kernel *)compat_ptr(name);
31912 if (err) {
31913 err = -EFAULT;
31914 goto out;
31915 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31916 index b62fb88..bdab4c4 100644
31917 --- a/block/partitions/efi.c
31918 +++ b/block/partitions/efi.c
31919 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31920 if (!gpt)
31921 return NULL;
31922
31923 + if (!le32_to_cpu(gpt->num_partition_entries))
31924 + return NULL;
31925 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31926 + if (!pte)
31927 + return NULL;
31928 +
31929 count = le32_to_cpu(gpt->num_partition_entries) *
31930 le32_to_cpu(gpt->sizeof_partition_entry);
31931 - if (!count)
31932 - return NULL;
31933 - pte = kzalloc(count, GFP_KERNEL);
31934 - if (!pte)
31935 - return NULL;
31936 -
31937 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
31938 (u8 *) pte,
31939 count) < count) {
31940 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
31941 index 9a87daa..fb17486 100644
31942 --- a/block/scsi_ioctl.c
31943 +++ b/block/scsi_ioctl.c
31944 @@ -223,8 +223,20 @@ EXPORT_SYMBOL(blk_verify_command);
31945 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
31946 struct sg_io_hdr *hdr, fmode_t mode)
31947 {
31948 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
31949 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31950 + unsigned char *cmdptr;
31951 +
31952 + if (rq->cmd != rq->__cmd)
31953 + cmdptr = rq->cmd;
31954 + else
31955 + cmdptr = tmpcmd;
31956 +
31957 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
31958 return -EFAULT;
31959 +
31960 + if (cmdptr != rq->cmd)
31961 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
31962 +
31963 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
31964 return -EPERM;
31965
31966 @@ -433,6 +445,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31967 int err;
31968 unsigned int in_len, out_len, bytes, opcode, cmdlen;
31969 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
31970 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31971 + unsigned char *cmdptr;
31972
31973 if (!sic)
31974 return -EINVAL;
31975 @@ -466,9 +480,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31976 */
31977 err = -EFAULT;
31978 rq->cmd_len = cmdlen;
31979 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
31980 +
31981 + if (rq->cmd != rq->__cmd)
31982 + cmdptr = rq->cmd;
31983 + else
31984 + cmdptr = tmpcmd;
31985 +
31986 + if (copy_from_user(cmdptr, sic->data, cmdlen))
31987 goto error;
31988
31989 + if (rq->cmd != cmdptr)
31990 + memcpy(rq->cmd, cmdptr, cmdlen);
31991 +
31992 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
31993 goto error;
31994
31995 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
31996 index 7bdd61b..afec999 100644
31997 --- a/crypto/cryptd.c
31998 +++ b/crypto/cryptd.c
31999 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
32000
32001 struct cryptd_blkcipher_request_ctx {
32002 crypto_completion_t complete;
32003 -};
32004 +} __no_const;
32005
32006 struct cryptd_hash_ctx {
32007 struct crypto_shash *child;
32008 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
32009
32010 struct cryptd_aead_request_ctx {
32011 crypto_completion_t complete;
32012 -};
32013 +} __no_const;
32014
32015 static void cryptd_queue_worker(struct work_struct *work);
32016
32017 diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
32018 index f6d9baf..dfd511f 100644
32019 --- a/crypto/crypto_user.c
32020 +++ b/crypto/crypto_user.c
32021 @@ -30,6 +30,8 @@
32022
32023 #include "internal.h"
32024
32025 +#define null_terminated(x) (strnlen(x, sizeof(x)) < sizeof(x))
32026 +
32027 static DEFINE_MUTEX(crypto_cfg_mutex);
32028
32029 /* The crypto netlink socket */
32030 @@ -196,7 +198,10 @@ static int crypto_report(struct sk_buff *in_skb, struct nlmsghdr *in_nlh,
32031 struct crypto_dump_info info;
32032 int err;
32033
32034 - if (!p->cru_driver_name)
32035 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32036 + return -EINVAL;
32037 +
32038 + if (!p->cru_driver_name[0])
32039 return -EINVAL;
32040
32041 alg = crypto_alg_match(p, 1);
32042 @@ -260,6 +265,9 @@ static int crypto_update_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32043 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
32044 LIST_HEAD(list);
32045
32046 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32047 + return -EINVAL;
32048 +
32049 if (priority && !strlen(p->cru_driver_name))
32050 return -EINVAL;
32051
32052 @@ -287,6 +295,9 @@ static int crypto_del_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32053 struct crypto_alg *alg;
32054 struct crypto_user_alg *p = nlmsg_data(nlh);
32055
32056 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32057 + return -EINVAL;
32058 +
32059 alg = crypto_alg_match(p, 1);
32060 if (!alg)
32061 return -ENOENT;
32062 @@ -368,6 +379,9 @@ static int crypto_add_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32063 struct crypto_user_alg *p = nlmsg_data(nlh);
32064 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
32065
32066 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32067 + return -EINVAL;
32068 +
32069 if (strlen(p->cru_driver_name))
32070 exact = 1;
32071
32072 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
32073 index f220d64..d359ad6 100644
32074 --- a/drivers/acpi/apei/apei-internal.h
32075 +++ b/drivers/acpi/apei/apei-internal.h
32076 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
32077 struct apei_exec_ins_type {
32078 u32 flags;
32079 apei_exec_ins_func_t run;
32080 -};
32081 +} __do_const;
32082
32083 struct apei_exec_context {
32084 u32 ip;
32085 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
32086 index e6defd8..c26a225 100644
32087 --- a/drivers/acpi/apei/cper.c
32088 +++ b/drivers/acpi/apei/cper.c
32089 @@ -38,12 +38,12 @@
32090 */
32091 u64 cper_next_record_id(void)
32092 {
32093 - static atomic64_t seq;
32094 + static atomic64_unchecked_t seq;
32095
32096 - if (!atomic64_read(&seq))
32097 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
32098 + if (!atomic64_read_unchecked(&seq))
32099 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
32100
32101 - return atomic64_inc_return(&seq);
32102 + return atomic64_inc_return_unchecked(&seq);
32103 }
32104 EXPORT_SYMBOL_GPL(cper_next_record_id);
32105
32106 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
32107 index be60399..778b33e8 100644
32108 --- a/drivers/acpi/bgrt.c
32109 +++ b/drivers/acpi/bgrt.c
32110 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
32111 return -ENODEV;
32112
32113 sysfs_bin_attr_init(&image_attr);
32114 - image_attr.private = bgrt_image;
32115 - image_attr.size = bgrt_image_size;
32116 + pax_open_kernel();
32117 + *(void **)&image_attr.private = bgrt_image;
32118 + *(size_t *)&image_attr.size = bgrt_image_size;
32119 + pax_close_kernel();
32120
32121 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
32122 if (!bgrt_kobj)
32123 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
32124 index cb96296..b81293b 100644
32125 --- a/drivers/acpi/blacklist.c
32126 +++ b/drivers/acpi/blacklist.c
32127 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
32128 u32 is_critical_error;
32129 };
32130
32131 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
32132 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
32133
32134 /*
32135 * POLICY: If *anything* doesn't work, put it on the blacklist.
32136 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
32137 return 0;
32138 }
32139
32140 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
32141 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
32142 {
32143 .callback = dmi_disable_osi_vista,
32144 .ident = "Fujitsu Siemens",
32145 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
32146 index 7586544..636a2f0 100644
32147 --- a/drivers/acpi/ec_sys.c
32148 +++ b/drivers/acpi/ec_sys.c
32149 @@ -12,6 +12,7 @@
32150 #include <linux/acpi.h>
32151 #include <linux/debugfs.h>
32152 #include <linux/module.h>
32153 +#include <linux/uaccess.h>
32154 #include "internal.h"
32155
32156 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
32157 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
32158 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
32159 */
32160 unsigned int size = EC_SPACE_SIZE;
32161 - u8 *data = (u8 *) buf;
32162 + u8 data;
32163 loff_t init_off = *off;
32164 int err = 0;
32165
32166 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
32167 size = count;
32168
32169 while (size) {
32170 - err = ec_read(*off, &data[*off - init_off]);
32171 + err = ec_read(*off, &data);
32172 if (err)
32173 return err;
32174 + if (put_user(data, &buf[*off - init_off]))
32175 + return -EFAULT;
32176 *off += 1;
32177 size--;
32178 }
32179 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32180
32181 unsigned int size = count;
32182 loff_t init_off = *off;
32183 - u8 *data = (u8 *) buf;
32184 int err = 0;
32185
32186 if (*off >= EC_SPACE_SIZE)
32187 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32188 }
32189
32190 while (size) {
32191 - u8 byte_write = data[*off - init_off];
32192 + u8 byte_write;
32193 + if (get_user(byte_write, &buf[*off - init_off]))
32194 + return -EFAULT;
32195 err = ec_write(*off, byte_write);
32196 if (err)
32197 return err;
32198 diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
32199 index e83311b..142b5cc 100644
32200 --- a/drivers/acpi/processor_driver.c
32201 +++ b/drivers/acpi/processor_driver.c
32202 @@ -558,7 +558,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
32203 return 0;
32204 #endif
32205
32206 - BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0));
32207 + BUG_ON(pr->id >= nr_cpu_ids);
32208
32209 /*
32210 * Buggy BIOS check
32211 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
32212 index ed9a1cc..f4a354c 100644
32213 --- a/drivers/acpi/processor_idle.c
32214 +++ b/drivers/acpi/processor_idle.c
32215 @@ -1005,7 +1005,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
32216 {
32217 int i, count = CPUIDLE_DRIVER_STATE_START;
32218 struct acpi_processor_cx *cx;
32219 - struct cpuidle_state *state;
32220 + cpuidle_state_no_const *state;
32221 struct cpuidle_driver *drv = &acpi_idle_driver;
32222
32223 if (!pr->flags.power_setup_done)
32224 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
32225 index ea61ca9..3fdd70d 100644
32226 --- a/drivers/acpi/sysfs.c
32227 +++ b/drivers/acpi/sysfs.c
32228 @@ -420,11 +420,11 @@ static u32 num_counters;
32229 static struct attribute **all_attrs;
32230 static u32 acpi_gpe_count;
32231
32232 -static struct attribute_group interrupt_stats_attr_group = {
32233 +static attribute_group_no_const interrupt_stats_attr_group = {
32234 .name = "interrupts",
32235 };
32236
32237 -static struct kobj_attribute *counter_attrs;
32238 +static kobj_attribute_no_const *counter_attrs;
32239
32240 static void delete_gpe_attr_array(void)
32241 {
32242 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
32243 index 6cd7805..07facb3 100644
32244 --- a/drivers/ata/libahci.c
32245 +++ b/drivers/ata/libahci.c
32246 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
32247 }
32248 EXPORT_SYMBOL_GPL(ahci_kick_engine);
32249
32250 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32251 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32252 struct ata_taskfile *tf, int is_cmd, u16 flags,
32253 unsigned long timeout_msec)
32254 {
32255 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
32256 index 46cd3f4..0871ad0 100644
32257 --- a/drivers/ata/libata-core.c
32258 +++ b/drivers/ata/libata-core.c
32259 @@ -4780,7 +4780,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
32260 struct ata_port *ap;
32261 unsigned int tag;
32262
32263 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32264 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32265 ap = qc->ap;
32266
32267 qc->flags = 0;
32268 @@ -4796,7 +4796,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
32269 struct ata_port *ap;
32270 struct ata_link *link;
32271
32272 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32273 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32274 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
32275 ap = qc->ap;
32276 link = qc->dev->link;
32277 @@ -5892,6 +5892,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32278 return;
32279
32280 spin_lock(&lock);
32281 + pax_open_kernel();
32282
32283 for (cur = ops->inherits; cur; cur = cur->inherits) {
32284 void **inherit = (void **)cur;
32285 @@ -5905,8 +5906,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32286 if (IS_ERR(*pp))
32287 *pp = NULL;
32288
32289 - ops->inherits = NULL;
32290 + *(struct ata_port_operations **)&ops->inherits = NULL;
32291
32292 + pax_close_kernel();
32293 spin_unlock(&lock);
32294 }
32295
32296 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
32297 index 405022d..fb70e53 100644
32298 --- a/drivers/ata/pata_arasan_cf.c
32299 +++ b/drivers/ata/pata_arasan_cf.c
32300 @@ -864,7 +864,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
32301 /* Handle platform specific quirks */
32302 if (pdata->quirk) {
32303 if (pdata->quirk & CF_BROKEN_PIO) {
32304 - ap->ops->set_piomode = NULL;
32305 + pax_open_kernel();
32306 + *(void **)&ap->ops->set_piomode = NULL;
32307 + pax_close_kernel();
32308 ap->pio_mask = 0;
32309 }
32310 if (pdata->quirk & CF_BROKEN_MWDMA)
32311 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
32312 index f9b983a..887b9d8 100644
32313 --- a/drivers/atm/adummy.c
32314 +++ b/drivers/atm/adummy.c
32315 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
32316 vcc->pop(vcc, skb);
32317 else
32318 dev_kfree_skb_any(skb);
32319 - atomic_inc(&vcc->stats->tx);
32320 + atomic_inc_unchecked(&vcc->stats->tx);
32321
32322 return 0;
32323 }
32324 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
32325 index 77a7480..05cde58 100644
32326 --- a/drivers/atm/ambassador.c
32327 +++ b/drivers/atm/ambassador.c
32328 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
32329 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
32330
32331 // VC layer stats
32332 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32333 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32334
32335 // free the descriptor
32336 kfree (tx_descr);
32337 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32338 dump_skb ("<<<", vc, skb);
32339
32340 // VC layer stats
32341 - atomic_inc(&atm_vcc->stats->rx);
32342 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32343 __net_timestamp(skb);
32344 // end of our responsibility
32345 atm_vcc->push (atm_vcc, skb);
32346 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32347 } else {
32348 PRINTK (KERN_INFO, "dropped over-size frame");
32349 // should we count this?
32350 - atomic_inc(&atm_vcc->stats->rx_drop);
32351 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32352 }
32353
32354 } else {
32355 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
32356 }
32357
32358 if (check_area (skb->data, skb->len)) {
32359 - atomic_inc(&atm_vcc->stats->tx_err);
32360 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
32361 return -ENOMEM; // ?
32362 }
32363
32364 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
32365 index b22d71c..d6e1049 100644
32366 --- a/drivers/atm/atmtcp.c
32367 +++ b/drivers/atm/atmtcp.c
32368 @@ -207,7 +207,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32369 if (vcc->pop) vcc->pop(vcc,skb);
32370 else dev_kfree_skb(skb);
32371 if (dev_data) return 0;
32372 - atomic_inc(&vcc->stats->tx_err);
32373 + atomic_inc_unchecked(&vcc->stats->tx_err);
32374 return -ENOLINK;
32375 }
32376 size = skb->len+sizeof(struct atmtcp_hdr);
32377 @@ -215,7 +215,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32378 if (!new_skb) {
32379 if (vcc->pop) vcc->pop(vcc,skb);
32380 else dev_kfree_skb(skb);
32381 - atomic_inc(&vcc->stats->tx_err);
32382 + atomic_inc_unchecked(&vcc->stats->tx_err);
32383 return -ENOBUFS;
32384 }
32385 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
32386 @@ -226,8 +226,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32387 if (vcc->pop) vcc->pop(vcc,skb);
32388 else dev_kfree_skb(skb);
32389 out_vcc->push(out_vcc,new_skb);
32390 - atomic_inc(&vcc->stats->tx);
32391 - atomic_inc(&out_vcc->stats->rx);
32392 + atomic_inc_unchecked(&vcc->stats->tx);
32393 + atomic_inc_unchecked(&out_vcc->stats->rx);
32394 return 0;
32395 }
32396
32397 @@ -301,7 +301,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32398 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
32399 read_unlock(&vcc_sklist_lock);
32400 if (!out_vcc) {
32401 - atomic_inc(&vcc->stats->tx_err);
32402 + atomic_inc_unchecked(&vcc->stats->tx_err);
32403 goto done;
32404 }
32405 skb_pull(skb,sizeof(struct atmtcp_hdr));
32406 @@ -313,8 +313,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32407 __net_timestamp(new_skb);
32408 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
32409 out_vcc->push(out_vcc,new_skb);
32410 - atomic_inc(&vcc->stats->tx);
32411 - atomic_inc(&out_vcc->stats->rx);
32412 + atomic_inc_unchecked(&vcc->stats->tx);
32413 + atomic_inc_unchecked(&out_vcc->stats->rx);
32414 done:
32415 if (vcc->pop) vcc->pop(vcc,skb);
32416 else dev_kfree_skb(skb);
32417 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
32418 index c1eb6fa..4c71be9 100644
32419 --- a/drivers/atm/eni.c
32420 +++ b/drivers/atm/eni.c
32421 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
32422 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
32423 vcc->dev->number);
32424 length = 0;
32425 - atomic_inc(&vcc->stats->rx_err);
32426 + atomic_inc_unchecked(&vcc->stats->rx_err);
32427 }
32428 else {
32429 length = ATM_CELL_SIZE-1; /* no HEC */
32430 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32431 size);
32432 }
32433 eff = length = 0;
32434 - atomic_inc(&vcc->stats->rx_err);
32435 + atomic_inc_unchecked(&vcc->stats->rx_err);
32436 }
32437 else {
32438 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
32439 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32440 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
32441 vcc->dev->number,vcc->vci,length,size << 2,descr);
32442 length = eff = 0;
32443 - atomic_inc(&vcc->stats->rx_err);
32444 + atomic_inc_unchecked(&vcc->stats->rx_err);
32445 }
32446 }
32447 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
32448 @@ -767,7 +767,7 @@ rx_dequeued++;
32449 vcc->push(vcc,skb);
32450 pushed++;
32451 }
32452 - atomic_inc(&vcc->stats->rx);
32453 + atomic_inc_unchecked(&vcc->stats->rx);
32454 }
32455 wake_up(&eni_dev->rx_wait);
32456 }
32457 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
32458 PCI_DMA_TODEVICE);
32459 if (vcc->pop) vcc->pop(vcc,skb);
32460 else dev_kfree_skb_irq(skb);
32461 - atomic_inc(&vcc->stats->tx);
32462 + atomic_inc_unchecked(&vcc->stats->tx);
32463 wake_up(&eni_dev->tx_wait);
32464 dma_complete++;
32465 }
32466 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
32467 index b41c948..a002b17 100644
32468 --- a/drivers/atm/firestream.c
32469 +++ b/drivers/atm/firestream.c
32470 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
32471 }
32472 }
32473
32474 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32475 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32476
32477 fs_dprintk (FS_DEBUG_TXMEM, "i");
32478 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
32479 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32480 #endif
32481 skb_put (skb, qe->p1 & 0xffff);
32482 ATM_SKB(skb)->vcc = atm_vcc;
32483 - atomic_inc(&atm_vcc->stats->rx);
32484 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32485 __net_timestamp(skb);
32486 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
32487 atm_vcc->push (atm_vcc, skb);
32488 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32489 kfree (pe);
32490 }
32491 if (atm_vcc)
32492 - atomic_inc(&atm_vcc->stats->rx_drop);
32493 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32494 break;
32495 case 0x1f: /* Reassembly abort: no buffers. */
32496 /* Silently increment error counter. */
32497 if (atm_vcc)
32498 - atomic_inc(&atm_vcc->stats->rx_drop);
32499 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32500 break;
32501 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
32502 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
32503 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
32504 index 204814e..cede831 100644
32505 --- a/drivers/atm/fore200e.c
32506 +++ b/drivers/atm/fore200e.c
32507 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
32508 #endif
32509 /* check error condition */
32510 if (*entry->status & STATUS_ERROR)
32511 - atomic_inc(&vcc->stats->tx_err);
32512 + atomic_inc_unchecked(&vcc->stats->tx_err);
32513 else
32514 - atomic_inc(&vcc->stats->tx);
32515 + atomic_inc_unchecked(&vcc->stats->tx);
32516 }
32517 }
32518
32519 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32520 if (skb == NULL) {
32521 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
32522
32523 - atomic_inc(&vcc->stats->rx_drop);
32524 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32525 return -ENOMEM;
32526 }
32527
32528 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32529
32530 dev_kfree_skb_any(skb);
32531
32532 - atomic_inc(&vcc->stats->rx_drop);
32533 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32534 return -ENOMEM;
32535 }
32536
32537 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32538
32539 vcc->push(vcc, skb);
32540 - atomic_inc(&vcc->stats->rx);
32541 + atomic_inc_unchecked(&vcc->stats->rx);
32542
32543 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32544
32545 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
32546 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
32547 fore200e->atm_dev->number,
32548 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
32549 - atomic_inc(&vcc->stats->rx_err);
32550 + atomic_inc_unchecked(&vcc->stats->rx_err);
32551 }
32552 }
32553
32554 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32555 goto retry_here;
32556 }
32557
32558 - atomic_inc(&vcc->stats->tx_err);
32559 + atomic_inc_unchecked(&vcc->stats->tx_err);
32560
32561 fore200e->tx_sat++;
32562 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32563 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32564 index 72b6960..cf9167a 100644
32565 --- a/drivers/atm/he.c
32566 +++ b/drivers/atm/he.c
32567 @@ -1699,7 +1699,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32568
32569 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32570 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32571 - atomic_inc(&vcc->stats->rx_drop);
32572 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32573 goto return_host_buffers;
32574 }
32575
32576 @@ -1726,7 +1726,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32577 RBRQ_LEN_ERR(he_dev->rbrq_head)
32578 ? "LEN_ERR" : "",
32579 vcc->vpi, vcc->vci);
32580 - atomic_inc(&vcc->stats->rx_err);
32581 + atomic_inc_unchecked(&vcc->stats->rx_err);
32582 goto return_host_buffers;
32583 }
32584
32585 @@ -1778,7 +1778,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32586 vcc->push(vcc, skb);
32587 spin_lock(&he_dev->global_lock);
32588
32589 - atomic_inc(&vcc->stats->rx);
32590 + atomic_inc_unchecked(&vcc->stats->rx);
32591
32592 return_host_buffers:
32593 ++pdus_assembled;
32594 @@ -2104,7 +2104,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32595 tpd->vcc->pop(tpd->vcc, tpd->skb);
32596 else
32597 dev_kfree_skb_any(tpd->skb);
32598 - atomic_inc(&tpd->vcc->stats->tx_err);
32599 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32600 }
32601 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32602 return;
32603 @@ -2516,7 +2516,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32604 vcc->pop(vcc, skb);
32605 else
32606 dev_kfree_skb_any(skb);
32607 - atomic_inc(&vcc->stats->tx_err);
32608 + atomic_inc_unchecked(&vcc->stats->tx_err);
32609 return -EINVAL;
32610 }
32611
32612 @@ -2527,7 +2527,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32613 vcc->pop(vcc, skb);
32614 else
32615 dev_kfree_skb_any(skb);
32616 - atomic_inc(&vcc->stats->tx_err);
32617 + atomic_inc_unchecked(&vcc->stats->tx_err);
32618 return -EINVAL;
32619 }
32620 #endif
32621 @@ -2539,7 +2539,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32622 vcc->pop(vcc, skb);
32623 else
32624 dev_kfree_skb_any(skb);
32625 - atomic_inc(&vcc->stats->tx_err);
32626 + atomic_inc_unchecked(&vcc->stats->tx_err);
32627 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32628 return -ENOMEM;
32629 }
32630 @@ -2581,7 +2581,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32631 vcc->pop(vcc, skb);
32632 else
32633 dev_kfree_skb_any(skb);
32634 - atomic_inc(&vcc->stats->tx_err);
32635 + atomic_inc_unchecked(&vcc->stats->tx_err);
32636 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32637 return -ENOMEM;
32638 }
32639 @@ -2612,7 +2612,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32640 __enqueue_tpd(he_dev, tpd, cid);
32641 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32642
32643 - atomic_inc(&vcc->stats->tx);
32644 + atomic_inc_unchecked(&vcc->stats->tx);
32645
32646 return 0;
32647 }
32648 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32649 index 1dc0519..1aadaf7 100644
32650 --- a/drivers/atm/horizon.c
32651 +++ b/drivers/atm/horizon.c
32652 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32653 {
32654 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32655 // VC layer stats
32656 - atomic_inc(&vcc->stats->rx);
32657 + atomic_inc_unchecked(&vcc->stats->rx);
32658 __net_timestamp(skb);
32659 // end of our responsibility
32660 vcc->push (vcc, skb);
32661 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32662 dev->tx_iovec = NULL;
32663
32664 // VC layer stats
32665 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32666 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32667
32668 // free the skb
32669 hrz_kfree_skb (skb);
32670 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32671 index 272f009..a18ba55 100644
32672 --- a/drivers/atm/idt77252.c
32673 +++ b/drivers/atm/idt77252.c
32674 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32675 else
32676 dev_kfree_skb(skb);
32677
32678 - atomic_inc(&vcc->stats->tx);
32679 + atomic_inc_unchecked(&vcc->stats->tx);
32680 }
32681
32682 atomic_dec(&scq->used);
32683 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32684 if ((sb = dev_alloc_skb(64)) == NULL) {
32685 printk("%s: Can't allocate buffers for aal0.\n",
32686 card->name);
32687 - atomic_add(i, &vcc->stats->rx_drop);
32688 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32689 break;
32690 }
32691 if (!atm_charge(vcc, sb->truesize)) {
32692 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32693 card->name);
32694 - atomic_add(i - 1, &vcc->stats->rx_drop);
32695 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32696 dev_kfree_skb(sb);
32697 break;
32698 }
32699 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32700 ATM_SKB(sb)->vcc = vcc;
32701 __net_timestamp(sb);
32702 vcc->push(vcc, sb);
32703 - atomic_inc(&vcc->stats->rx);
32704 + atomic_inc_unchecked(&vcc->stats->rx);
32705
32706 cell += ATM_CELL_PAYLOAD;
32707 }
32708 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32709 "(CDC: %08x)\n",
32710 card->name, len, rpp->len, readl(SAR_REG_CDC));
32711 recycle_rx_pool_skb(card, rpp);
32712 - atomic_inc(&vcc->stats->rx_err);
32713 + atomic_inc_unchecked(&vcc->stats->rx_err);
32714 return;
32715 }
32716 if (stat & SAR_RSQE_CRC) {
32717 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32718 recycle_rx_pool_skb(card, rpp);
32719 - atomic_inc(&vcc->stats->rx_err);
32720 + atomic_inc_unchecked(&vcc->stats->rx_err);
32721 return;
32722 }
32723 if (skb_queue_len(&rpp->queue) > 1) {
32724 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32725 RXPRINTK("%s: Can't alloc RX skb.\n",
32726 card->name);
32727 recycle_rx_pool_skb(card, rpp);
32728 - atomic_inc(&vcc->stats->rx_err);
32729 + atomic_inc_unchecked(&vcc->stats->rx_err);
32730 return;
32731 }
32732 if (!atm_charge(vcc, skb->truesize)) {
32733 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32734 __net_timestamp(skb);
32735
32736 vcc->push(vcc, skb);
32737 - atomic_inc(&vcc->stats->rx);
32738 + atomic_inc_unchecked(&vcc->stats->rx);
32739
32740 return;
32741 }
32742 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32743 __net_timestamp(skb);
32744
32745 vcc->push(vcc, skb);
32746 - atomic_inc(&vcc->stats->rx);
32747 + atomic_inc_unchecked(&vcc->stats->rx);
32748
32749 if (skb->truesize > SAR_FB_SIZE_3)
32750 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32751 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32752 if (vcc->qos.aal != ATM_AAL0) {
32753 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32754 card->name, vpi, vci);
32755 - atomic_inc(&vcc->stats->rx_drop);
32756 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32757 goto drop;
32758 }
32759
32760 if ((sb = dev_alloc_skb(64)) == NULL) {
32761 printk("%s: Can't allocate buffers for AAL0.\n",
32762 card->name);
32763 - atomic_inc(&vcc->stats->rx_err);
32764 + atomic_inc_unchecked(&vcc->stats->rx_err);
32765 goto drop;
32766 }
32767
32768 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32769 ATM_SKB(sb)->vcc = vcc;
32770 __net_timestamp(sb);
32771 vcc->push(vcc, sb);
32772 - atomic_inc(&vcc->stats->rx);
32773 + atomic_inc_unchecked(&vcc->stats->rx);
32774
32775 drop:
32776 skb_pull(queue, 64);
32777 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32778
32779 if (vc == NULL) {
32780 printk("%s: NULL connection in send().\n", card->name);
32781 - atomic_inc(&vcc->stats->tx_err);
32782 + atomic_inc_unchecked(&vcc->stats->tx_err);
32783 dev_kfree_skb(skb);
32784 return -EINVAL;
32785 }
32786 if (!test_bit(VCF_TX, &vc->flags)) {
32787 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32788 - atomic_inc(&vcc->stats->tx_err);
32789 + atomic_inc_unchecked(&vcc->stats->tx_err);
32790 dev_kfree_skb(skb);
32791 return -EINVAL;
32792 }
32793 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32794 break;
32795 default:
32796 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32797 - atomic_inc(&vcc->stats->tx_err);
32798 + atomic_inc_unchecked(&vcc->stats->tx_err);
32799 dev_kfree_skb(skb);
32800 return -EINVAL;
32801 }
32802
32803 if (skb_shinfo(skb)->nr_frags != 0) {
32804 printk("%s: No scatter-gather yet.\n", card->name);
32805 - atomic_inc(&vcc->stats->tx_err);
32806 + atomic_inc_unchecked(&vcc->stats->tx_err);
32807 dev_kfree_skb(skb);
32808 return -EINVAL;
32809 }
32810 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32811
32812 err = queue_skb(card, vc, skb, oam);
32813 if (err) {
32814 - atomic_inc(&vcc->stats->tx_err);
32815 + atomic_inc_unchecked(&vcc->stats->tx_err);
32816 dev_kfree_skb(skb);
32817 return err;
32818 }
32819 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32820 skb = dev_alloc_skb(64);
32821 if (!skb) {
32822 printk("%s: Out of memory in send_oam().\n", card->name);
32823 - atomic_inc(&vcc->stats->tx_err);
32824 + atomic_inc_unchecked(&vcc->stats->tx_err);
32825 return -ENOMEM;
32826 }
32827 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32828 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32829 index 4217f29..88f547a 100644
32830 --- a/drivers/atm/iphase.c
32831 +++ b/drivers/atm/iphase.c
32832 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32833 status = (u_short) (buf_desc_ptr->desc_mode);
32834 if (status & (RX_CER | RX_PTE | RX_OFL))
32835 {
32836 - atomic_inc(&vcc->stats->rx_err);
32837 + atomic_inc_unchecked(&vcc->stats->rx_err);
32838 IF_ERR(printk("IA: bad packet, dropping it");)
32839 if (status & RX_CER) {
32840 IF_ERR(printk(" cause: packet CRC error\n");)
32841 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32842 len = dma_addr - buf_addr;
32843 if (len > iadev->rx_buf_sz) {
32844 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32845 - atomic_inc(&vcc->stats->rx_err);
32846 + atomic_inc_unchecked(&vcc->stats->rx_err);
32847 goto out_free_desc;
32848 }
32849
32850 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32851 ia_vcc = INPH_IA_VCC(vcc);
32852 if (ia_vcc == NULL)
32853 {
32854 - atomic_inc(&vcc->stats->rx_err);
32855 + atomic_inc_unchecked(&vcc->stats->rx_err);
32856 atm_return(vcc, skb->truesize);
32857 dev_kfree_skb_any(skb);
32858 goto INCR_DLE;
32859 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32860 if ((length > iadev->rx_buf_sz) || (length >
32861 (skb->len - sizeof(struct cpcs_trailer))))
32862 {
32863 - atomic_inc(&vcc->stats->rx_err);
32864 + atomic_inc_unchecked(&vcc->stats->rx_err);
32865 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32866 length, skb->len);)
32867 atm_return(vcc, skb->truesize);
32868 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32869
32870 IF_RX(printk("rx_dle_intr: skb push");)
32871 vcc->push(vcc,skb);
32872 - atomic_inc(&vcc->stats->rx);
32873 + atomic_inc_unchecked(&vcc->stats->rx);
32874 iadev->rx_pkt_cnt++;
32875 }
32876 INCR_DLE:
32877 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32878 {
32879 struct k_sonet_stats *stats;
32880 stats = &PRIV(_ia_dev[board])->sonet_stats;
32881 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32882 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32883 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32884 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32885 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32886 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32887 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32888 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32889 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32890 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32891 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32892 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32893 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32894 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32895 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32896 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32897 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32898 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32899 }
32900 ia_cmds.status = 0;
32901 break;
32902 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32903 if ((desc == 0) || (desc > iadev->num_tx_desc))
32904 {
32905 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32906 - atomic_inc(&vcc->stats->tx);
32907 + atomic_inc_unchecked(&vcc->stats->tx);
32908 if (vcc->pop)
32909 vcc->pop(vcc, skb);
32910 else
32911 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32912 ATM_DESC(skb) = vcc->vci;
32913 skb_queue_tail(&iadev->tx_dma_q, skb);
32914
32915 - atomic_inc(&vcc->stats->tx);
32916 + atomic_inc_unchecked(&vcc->stats->tx);
32917 iadev->tx_pkt_cnt++;
32918 /* Increment transaction counter */
32919 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32920
32921 #if 0
32922 /* add flow control logic */
32923 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32924 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32925 if (iavcc->vc_desc_cnt > 10) {
32926 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32927 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32928 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32929 index fa7d701..1e404c7 100644
32930 --- a/drivers/atm/lanai.c
32931 +++ b/drivers/atm/lanai.c
32932 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32933 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32934 lanai_endtx(lanai, lvcc);
32935 lanai_free_skb(lvcc->tx.atmvcc, skb);
32936 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
32937 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
32938 }
32939
32940 /* Try to fill the buffer - don't call unless there is backlog */
32941 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
32942 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
32943 __net_timestamp(skb);
32944 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
32945 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
32946 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
32947 out:
32948 lvcc->rx.buf.ptr = end;
32949 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
32950 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32951 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
32952 "vcc %d\n", lanai->number, (unsigned int) s, vci);
32953 lanai->stats.service_rxnotaal5++;
32954 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32955 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32956 return 0;
32957 }
32958 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
32959 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32960 int bytes;
32961 read_unlock(&vcc_sklist_lock);
32962 DPRINTK("got trashed rx pdu on vci %d\n", vci);
32963 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32964 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32965 lvcc->stats.x.aal5.service_trash++;
32966 bytes = (SERVICE_GET_END(s) * 16) -
32967 (((unsigned long) lvcc->rx.buf.ptr) -
32968 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32969 }
32970 if (s & SERVICE_STREAM) {
32971 read_unlock(&vcc_sklist_lock);
32972 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32973 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32974 lvcc->stats.x.aal5.service_stream++;
32975 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
32976 "PDU on VCI %d!\n", lanai->number, vci);
32977 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32978 return 0;
32979 }
32980 DPRINTK("got rx crc error on vci %d\n", vci);
32981 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32982 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32983 lvcc->stats.x.aal5.service_rxcrc++;
32984 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
32985 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
32986 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
32987 index ed1d2b7..8cffc1f 100644
32988 --- a/drivers/atm/nicstar.c
32989 +++ b/drivers/atm/nicstar.c
32990 @@ -1654,7 +1654,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32991 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
32992 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
32993 card->index);
32994 - atomic_inc(&vcc->stats->tx_err);
32995 + atomic_inc_unchecked(&vcc->stats->tx_err);
32996 dev_kfree_skb_any(skb);
32997 return -EINVAL;
32998 }
32999 @@ -1662,7 +1662,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33000 if (!vc->tx) {
33001 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
33002 card->index);
33003 - atomic_inc(&vcc->stats->tx_err);
33004 + atomic_inc_unchecked(&vcc->stats->tx_err);
33005 dev_kfree_skb_any(skb);
33006 return -EINVAL;
33007 }
33008 @@ -1670,14 +1670,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33009 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
33010 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
33011 card->index);
33012 - atomic_inc(&vcc->stats->tx_err);
33013 + atomic_inc_unchecked(&vcc->stats->tx_err);
33014 dev_kfree_skb_any(skb);
33015 return -EINVAL;
33016 }
33017
33018 if (skb_shinfo(skb)->nr_frags != 0) {
33019 printk("nicstar%d: No scatter-gather yet.\n", card->index);
33020 - atomic_inc(&vcc->stats->tx_err);
33021 + atomic_inc_unchecked(&vcc->stats->tx_err);
33022 dev_kfree_skb_any(skb);
33023 return -EINVAL;
33024 }
33025 @@ -1725,11 +1725,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33026 }
33027
33028 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
33029 - atomic_inc(&vcc->stats->tx_err);
33030 + atomic_inc_unchecked(&vcc->stats->tx_err);
33031 dev_kfree_skb_any(skb);
33032 return -EIO;
33033 }
33034 - atomic_inc(&vcc->stats->tx);
33035 + atomic_inc_unchecked(&vcc->stats->tx);
33036
33037 return 0;
33038 }
33039 @@ -2046,14 +2046,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33040 printk
33041 ("nicstar%d: Can't allocate buffers for aal0.\n",
33042 card->index);
33043 - atomic_add(i, &vcc->stats->rx_drop);
33044 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
33045 break;
33046 }
33047 if (!atm_charge(vcc, sb->truesize)) {
33048 RXPRINTK
33049 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
33050 card->index);
33051 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
33052 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
33053 dev_kfree_skb_any(sb);
33054 break;
33055 }
33056 @@ -2068,7 +2068,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33057 ATM_SKB(sb)->vcc = vcc;
33058 __net_timestamp(sb);
33059 vcc->push(vcc, sb);
33060 - atomic_inc(&vcc->stats->rx);
33061 + atomic_inc_unchecked(&vcc->stats->rx);
33062 cell += ATM_CELL_PAYLOAD;
33063 }
33064
33065 @@ -2085,7 +2085,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33066 if (iovb == NULL) {
33067 printk("nicstar%d: Out of iovec buffers.\n",
33068 card->index);
33069 - atomic_inc(&vcc->stats->rx_drop);
33070 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33071 recycle_rx_buf(card, skb);
33072 return;
33073 }
33074 @@ -2109,7 +2109,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33075 small or large buffer itself. */
33076 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
33077 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
33078 - atomic_inc(&vcc->stats->rx_err);
33079 + atomic_inc_unchecked(&vcc->stats->rx_err);
33080 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
33081 NS_MAX_IOVECS);
33082 NS_PRV_IOVCNT(iovb) = 0;
33083 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33084 ("nicstar%d: Expected a small buffer, and this is not one.\n",
33085 card->index);
33086 which_list(card, skb);
33087 - atomic_inc(&vcc->stats->rx_err);
33088 + atomic_inc_unchecked(&vcc->stats->rx_err);
33089 recycle_rx_buf(card, skb);
33090 vc->rx_iov = NULL;
33091 recycle_iov_buf(card, iovb);
33092 @@ -2142,7 +2142,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33093 ("nicstar%d: Expected a large buffer, and this is not one.\n",
33094 card->index);
33095 which_list(card, skb);
33096 - atomic_inc(&vcc->stats->rx_err);
33097 + atomic_inc_unchecked(&vcc->stats->rx_err);
33098 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
33099 NS_PRV_IOVCNT(iovb));
33100 vc->rx_iov = NULL;
33101 @@ -2165,7 +2165,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33102 printk(" - PDU size mismatch.\n");
33103 else
33104 printk(".\n");
33105 - atomic_inc(&vcc->stats->rx_err);
33106 + atomic_inc_unchecked(&vcc->stats->rx_err);
33107 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
33108 NS_PRV_IOVCNT(iovb));
33109 vc->rx_iov = NULL;
33110 @@ -2179,7 +2179,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33111 /* skb points to a small buffer */
33112 if (!atm_charge(vcc, skb->truesize)) {
33113 push_rxbufs(card, skb);
33114 - atomic_inc(&vcc->stats->rx_drop);
33115 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33116 } else {
33117 skb_put(skb, len);
33118 dequeue_sm_buf(card, skb);
33119 @@ -2189,7 +2189,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33120 ATM_SKB(skb)->vcc = vcc;
33121 __net_timestamp(skb);
33122 vcc->push(vcc, skb);
33123 - atomic_inc(&vcc->stats->rx);
33124 + atomic_inc_unchecked(&vcc->stats->rx);
33125 }
33126 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
33127 struct sk_buff *sb;
33128 @@ -2200,7 +2200,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33129 if (len <= NS_SMBUFSIZE) {
33130 if (!atm_charge(vcc, sb->truesize)) {
33131 push_rxbufs(card, sb);
33132 - atomic_inc(&vcc->stats->rx_drop);
33133 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33134 } else {
33135 skb_put(sb, len);
33136 dequeue_sm_buf(card, sb);
33137 @@ -2210,7 +2210,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33138 ATM_SKB(sb)->vcc = vcc;
33139 __net_timestamp(sb);
33140 vcc->push(vcc, sb);
33141 - atomic_inc(&vcc->stats->rx);
33142 + atomic_inc_unchecked(&vcc->stats->rx);
33143 }
33144
33145 push_rxbufs(card, skb);
33146 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33147
33148 if (!atm_charge(vcc, skb->truesize)) {
33149 push_rxbufs(card, skb);
33150 - atomic_inc(&vcc->stats->rx_drop);
33151 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33152 } else {
33153 dequeue_lg_buf(card, skb);
33154 #ifdef NS_USE_DESTRUCTORS
33155 @@ -2232,7 +2232,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33156 ATM_SKB(skb)->vcc = vcc;
33157 __net_timestamp(skb);
33158 vcc->push(vcc, skb);
33159 - atomic_inc(&vcc->stats->rx);
33160 + atomic_inc_unchecked(&vcc->stats->rx);
33161 }
33162
33163 push_rxbufs(card, sb);
33164 @@ -2253,7 +2253,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33165 printk
33166 ("nicstar%d: Out of huge buffers.\n",
33167 card->index);
33168 - atomic_inc(&vcc->stats->rx_drop);
33169 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33170 recycle_iovec_rx_bufs(card,
33171 (struct iovec *)
33172 iovb->data,
33173 @@ -2304,7 +2304,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33174 card->hbpool.count++;
33175 } else
33176 dev_kfree_skb_any(hb);
33177 - atomic_inc(&vcc->stats->rx_drop);
33178 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33179 } else {
33180 /* Copy the small buffer to the huge buffer */
33181 sb = (struct sk_buff *)iov->iov_base;
33182 @@ -2341,7 +2341,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33183 #endif /* NS_USE_DESTRUCTORS */
33184 __net_timestamp(hb);
33185 vcc->push(vcc, hb);
33186 - atomic_inc(&vcc->stats->rx);
33187 + atomic_inc_unchecked(&vcc->stats->rx);
33188 }
33189 }
33190
33191 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
33192 index 0474a89..06ea4a1 100644
33193 --- a/drivers/atm/solos-pci.c
33194 +++ b/drivers/atm/solos-pci.c
33195 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
33196 }
33197 atm_charge(vcc, skb->truesize);
33198 vcc->push(vcc, skb);
33199 - atomic_inc(&vcc->stats->rx);
33200 + atomic_inc_unchecked(&vcc->stats->rx);
33201 break;
33202
33203 case PKT_STATUS:
33204 @@ -1117,7 +1117,7 @@ static uint32_t fpga_tx(struct solos_card *card)
33205 vcc = SKB_CB(oldskb)->vcc;
33206
33207 if (vcc) {
33208 - atomic_inc(&vcc->stats->tx);
33209 + atomic_inc_unchecked(&vcc->stats->tx);
33210 solos_pop(vcc, oldskb);
33211 } else {
33212 dev_kfree_skb_irq(oldskb);
33213 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
33214 index 0215934..ce9f5b1 100644
33215 --- a/drivers/atm/suni.c
33216 +++ b/drivers/atm/suni.c
33217 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
33218
33219
33220 #define ADD_LIMITED(s,v) \
33221 - atomic_add((v),&stats->s); \
33222 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
33223 + atomic_add_unchecked((v),&stats->s); \
33224 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
33225
33226
33227 static void suni_hz(unsigned long from_timer)
33228 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
33229 index 5120a96..e2572bd 100644
33230 --- a/drivers/atm/uPD98402.c
33231 +++ b/drivers/atm/uPD98402.c
33232 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
33233 struct sonet_stats tmp;
33234 int error = 0;
33235
33236 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33237 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33238 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
33239 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
33240 if (zero && !error) {
33241 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
33242
33243
33244 #define ADD_LIMITED(s,v) \
33245 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
33246 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
33247 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33248 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
33249 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
33250 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33251
33252
33253 static void stat_event(struct atm_dev *dev)
33254 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
33255 if (reason & uPD98402_INT_PFM) stat_event(dev);
33256 if (reason & uPD98402_INT_PCO) {
33257 (void) GET(PCOCR); /* clear interrupt cause */
33258 - atomic_add(GET(HECCT),
33259 + atomic_add_unchecked(GET(HECCT),
33260 &PRIV(dev)->sonet_stats.uncorr_hcs);
33261 }
33262 if ((reason & uPD98402_INT_RFO) &&
33263 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
33264 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
33265 uPD98402_INT_LOS),PIMR); /* enable them */
33266 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
33267 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33268 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
33269 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
33270 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33271 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
33272 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
33273 return 0;
33274 }
33275
33276 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
33277 index 969c3c2..9b72956 100644
33278 --- a/drivers/atm/zatm.c
33279 +++ b/drivers/atm/zatm.c
33280 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33281 }
33282 if (!size) {
33283 dev_kfree_skb_irq(skb);
33284 - if (vcc) atomic_inc(&vcc->stats->rx_err);
33285 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
33286 continue;
33287 }
33288 if (!atm_charge(vcc,skb->truesize)) {
33289 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33290 skb->len = size;
33291 ATM_SKB(skb)->vcc = vcc;
33292 vcc->push(vcc,skb);
33293 - atomic_inc(&vcc->stats->rx);
33294 + atomic_inc_unchecked(&vcc->stats->rx);
33295 }
33296 zout(pos & 0xffff,MTA(mbx));
33297 #if 0 /* probably a stupid idea */
33298 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
33299 skb_queue_head(&zatm_vcc->backlog,skb);
33300 break;
33301 }
33302 - atomic_inc(&vcc->stats->tx);
33303 + atomic_inc_unchecked(&vcc->stats->tx);
33304 wake_up(&zatm_vcc->tx_wait);
33305 }
33306
33307 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
33308 index 6856303..0602d70 100644
33309 --- a/drivers/base/bus.c
33310 +++ b/drivers/base/bus.c
33311 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
33312 return -EINVAL;
33313
33314 mutex_lock(&subsys->p->mutex);
33315 - list_add_tail(&sif->node, &subsys->p->interfaces);
33316 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
33317 if (sif->add_dev) {
33318 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33319 while ((dev = subsys_dev_iter_next(&iter)))
33320 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
33321 subsys = sif->subsys;
33322
33323 mutex_lock(&subsys->p->mutex);
33324 - list_del_init(&sif->node);
33325 + pax_list_del_init((struct list_head *)&sif->node);
33326 if (sif->remove_dev) {
33327 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33328 while ((dev = subsys_dev_iter_next(&iter)))
33329 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
33330 index 17cf7ca..7e553e1 100644
33331 --- a/drivers/base/devtmpfs.c
33332 +++ b/drivers/base/devtmpfs.c
33333 @@ -347,7 +347,7 @@ int devtmpfs_mount(const char *mntdir)
33334 if (!thread)
33335 return 0;
33336
33337 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
33338 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
33339 if (err)
33340 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
33341 else
33342 diff --git a/drivers/base/node.c b/drivers/base/node.c
33343 index fac124a..66bd4ab 100644
33344 --- a/drivers/base/node.c
33345 +++ b/drivers/base/node.c
33346 @@ -625,7 +625,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
33347 struct node_attr {
33348 struct device_attribute attr;
33349 enum node_states state;
33350 -};
33351 +} __do_const;
33352
33353 static ssize_t show_node_state(struct device *dev,
33354 struct device_attribute *attr, char *buf)
33355 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
33356 index acc3a8d..981c236 100644
33357 --- a/drivers/base/power/domain.c
33358 +++ b/drivers/base/power/domain.c
33359 @@ -1851,7 +1851,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
33360 {
33361 struct cpuidle_driver *cpuidle_drv;
33362 struct gpd_cpu_data *cpu_data;
33363 - struct cpuidle_state *idle_state;
33364 + cpuidle_state_no_const *idle_state;
33365 int ret = 0;
33366
33367 if (IS_ERR_OR_NULL(genpd) || state < 0)
33368 @@ -1919,7 +1919,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
33369 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
33370 {
33371 struct gpd_cpu_data *cpu_data;
33372 - struct cpuidle_state *idle_state;
33373 + cpuidle_state_no_const *idle_state;
33374 int ret = 0;
33375
33376 if (IS_ERR_OR_NULL(genpd))
33377 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
33378 index e6ee5e8..98ad7fc 100644
33379 --- a/drivers/base/power/wakeup.c
33380 +++ b/drivers/base/power/wakeup.c
33381 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
33382 * They need to be modified together atomically, so it's better to use one
33383 * atomic variable to hold them both.
33384 */
33385 -static atomic_t combined_event_count = ATOMIC_INIT(0);
33386 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
33387
33388 #define IN_PROGRESS_BITS (sizeof(int) * 4)
33389 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
33390
33391 static void split_counters(unsigned int *cnt, unsigned int *inpr)
33392 {
33393 - unsigned int comb = atomic_read(&combined_event_count);
33394 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
33395
33396 *cnt = (comb >> IN_PROGRESS_BITS);
33397 *inpr = comb & MAX_IN_PROGRESS;
33398 @@ -389,7 +389,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
33399 ws->start_prevent_time = ws->last_time;
33400
33401 /* Increment the counter of events in progress. */
33402 - cec = atomic_inc_return(&combined_event_count);
33403 + cec = atomic_inc_return_unchecked(&combined_event_count);
33404
33405 trace_wakeup_source_activate(ws->name, cec);
33406 }
33407 @@ -515,7 +515,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
33408 * Increment the counter of registered wakeup events and decrement the
33409 * couter of wakeup events in progress simultaneously.
33410 */
33411 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
33412 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
33413 trace_wakeup_source_deactivate(ws->name, cec);
33414
33415 split_counters(&cnt, &inpr);
33416 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
33417 index e8d11b6..7b1b36f 100644
33418 --- a/drivers/base/syscore.c
33419 +++ b/drivers/base/syscore.c
33420 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
33421 void register_syscore_ops(struct syscore_ops *ops)
33422 {
33423 mutex_lock(&syscore_ops_lock);
33424 - list_add_tail(&ops->node, &syscore_ops_list);
33425 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
33426 mutex_unlock(&syscore_ops_lock);
33427 }
33428 EXPORT_SYMBOL_GPL(register_syscore_ops);
33429 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
33430 void unregister_syscore_ops(struct syscore_ops *ops)
33431 {
33432 mutex_lock(&syscore_ops_lock);
33433 - list_del(&ops->node);
33434 + pax_list_del((struct list_head *)&ops->node);
33435 mutex_unlock(&syscore_ops_lock);
33436 }
33437 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
33438 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
33439 index ade58bc..867143d 100644
33440 --- a/drivers/block/cciss.c
33441 +++ b/drivers/block/cciss.c
33442 @@ -1196,6 +1196,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
33443 int err;
33444 u32 cp;
33445
33446 + memset(&arg64, 0, sizeof(arg64));
33447 +
33448 err = 0;
33449 err |=
33450 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
33451 @@ -3005,7 +3007,7 @@ static void start_io(ctlr_info_t *h)
33452 while (!list_empty(&h->reqQ)) {
33453 c = list_entry(h->reqQ.next, CommandList_struct, list);
33454 /* can't do anything if fifo is full */
33455 - if ((h->access.fifo_full(h))) {
33456 + if ((h->access->fifo_full(h))) {
33457 dev_warn(&h->pdev->dev, "fifo full\n");
33458 break;
33459 }
33460 @@ -3015,7 +3017,7 @@ static void start_io(ctlr_info_t *h)
33461 h->Qdepth--;
33462
33463 /* Tell the controller execute command */
33464 - h->access.submit_command(h, c);
33465 + h->access->submit_command(h, c);
33466
33467 /* Put job onto the completed Q */
33468 addQ(&h->cmpQ, c);
33469 @@ -3441,17 +3443,17 @@ startio:
33470
33471 static inline unsigned long get_next_completion(ctlr_info_t *h)
33472 {
33473 - return h->access.command_completed(h);
33474 + return h->access->command_completed(h);
33475 }
33476
33477 static inline int interrupt_pending(ctlr_info_t *h)
33478 {
33479 - return h->access.intr_pending(h);
33480 + return h->access->intr_pending(h);
33481 }
33482
33483 static inline long interrupt_not_for_us(ctlr_info_t *h)
33484 {
33485 - return ((h->access.intr_pending(h) == 0) ||
33486 + return ((h->access->intr_pending(h) == 0) ||
33487 (h->interrupts_enabled == 0));
33488 }
33489
33490 @@ -3484,7 +3486,7 @@ static inline u32 next_command(ctlr_info_t *h)
33491 u32 a;
33492
33493 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
33494 - return h->access.command_completed(h);
33495 + return h->access->command_completed(h);
33496
33497 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
33498 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
33499 @@ -4041,7 +4043,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
33500 trans_support & CFGTBL_Trans_use_short_tags);
33501
33502 /* Change the access methods to the performant access methods */
33503 - h->access = SA5_performant_access;
33504 + h->access = &SA5_performant_access;
33505 h->transMethod = CFGTBL_Trans_Performant;
33506
33507 return;
33508 @@ -4310,7 +4312,7 @@ static int cciss_pci_init(ctlr_info_t *h)
33509 if (prod_index < 0)
33510 return -ENODEV;
33511 h->product_name = products[prod_index].product_name;
33512 - h->access = *(products[prod_index].access);
33513 + h->access = products[prod_index].access;
33514
33515 if (cciss_board_disabled(h)) {
33516 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
33517 @@ -5032,7 +5034,7 @@ reinit_after_soft_reset:
33518 }
33519
33520 /* make sure the board interrupts are off */
33521 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33522 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33523 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
33524 if (rc)
33525 goto clean2;
33526 @@ -5082,7 +5084,7 @@ reinit_after_soft_reset:
33527 * fake ones to scoop up any residual completions.
33528 */
33529 spin_lock_irqsave(&h->lock, flags);
33530 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33531 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33532 spin_unlock_irqrestore(&h->lock, flags);
33533 free_irq(h->intr[h->intr_mode], h);
33534 rc = cciss_request_irq(h, cciss_msix_discard_completions,
33535 @@ -5102,9 +5104,9 @@ reinit_after_soft_reset:
33536 dev_info(&h->pdev->dev, "Board READY.\n");
33537 dev_info(&h->pdev->dev,
33538 "Waiting for stale completions to drain.\n");
33539 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33540 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33541 msleep(10000);
33542 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33543 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33544
33545 rc = controller_reset_failed(h->cfgtable);
33546 if (rc)
33547 @@ -5127,7 +5129,7 @@ reinit_after_soft_reset:
33548 cciss_scsi_setup(h);
33549
33550 /* Turn the interrupts on so we can service requests */
33551 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33552 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33553
33554 /* Get the firmware version */
33555 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33556 @@ -5199,7 +5201,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33557 kfree(flush_buf);
33558 if (return_code != IO_OK)
33559 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33560 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33561 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33562 free_irq(h->intr[h->intr_mode], h);
33563 }
33564
33565 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33566 index 7fda30e..eb5dfe0 100644
33567 --- a/drivers/block/cciss.h
33568 +++ b/drivers/block/cciss.h
33569 @@ -101,7 +101,7 @@ struct ctlr_info
33570 /* information about each logical volume */
33571 drive_info_struct *drv[CISS_MAX_LUN];
33572
33573 - struct access_method access;
33574 + struct access_method *access;
33575
33576 /* queue and queue Info */
33577 struct list_head reqQ;
33578 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33579 index 3f08713..56a586a 100644
33580 --- a/drivers/block/cpqarray.c
33581 +++ b/drivers/block/cpqarray.c
33582 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33583 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33584 goto Enomem4;
33585 }
33586 - hba[i]->access.set_intr_mask(hba[i], 0);
33587 + hba[i]->access->set_intr_mask(hba[i], 0);
33588 if (request_irq(hba[i]->intr, do_ida_intr,
33589 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33590 {
33591 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33592 add_timer(&hba[i]->timer);
33593
33594 /* Enable IRQ now that spinlock and rate limit timer are set up */
33595 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33596 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33597
33598 for(j=0; j<NWD; j++) {
33599 struct gendisk *disk = ida_gendisk[i][j];
33600 @@ -694,7 +694,7 @@ DBGINFO(
33601 for(i=0; i<NR_PRODUCTS; i++) {
33602 if (board_id == products[i].board_id) {
33603 c->product_name = products[i].product_name;
33604 - c->access = *(products[i].access);
33605 + c->access = products[i].access;
33606 break;
33607 }
33608 }
33609 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33610 hba[ctlr]->intr = intr;
33611 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33612 hba[ctlr]->product_name = products[j].product_name;
33613 - hba[ctlr]->access = *(products[j].access);
33614 + hba[ctlr]->access = products[j].access;
33615 hba[ctlr]->ctlr = ctlr;
33616 hba[ctlr]->board_id = board_id;
33617 hba[ctlr]->pci_dev = NULL; /* not PCI */
33618 @@ -980,7 +980,7 @@ static void start_io(ctlr_info_t *h)
33619
33620 while((c = h->reqQ) != NULL) {
33621 /* Can't do anything if we're busy */
33622 - if (h->access.fifo_full(h) == 0)
33623 + if (h->access->fifo_full(h) == 0)
33624 return;
33625
33626 /* Get the first entry from the request Q */
33627 @@ -988,7 +988,7 @@ static void start_io(ctlr_info_t *h)
33628 h->Qdepth--;
33629
33630 /* Tell the controller to do our bidding */
33631 - h->access.submit_command(h, c);
33632 + h->access->submit_command(h, c);
33633
33634 /* Get onto the completion Q */
33635 addQ(&h->cmpQ, c);
33636 @@ -1050,7 +1050,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33637 unsigned long flags;
33638 __u32 a,a1;
33639
33640 - istat = h->access.intr_pending(h);
33641 + istat = h->access->intr_pending(h);
33642 /* Is this interrupt for us? */
33643 if (istat == 0)
33644 return IRQ_NONE;
33645 @@ -1061,7 +1061,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33646 */
33647 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33648 if (istat & FIFO_NOT_EMPTY) {
33649 - while((a = h->access.command_completed(h))) {
33650 + while((a = h->access->command_completed(h))) {
33651 a1 = a; a &= ~3;
33652 if ((c = h->cmpQ) == NULL)
33653 {
33654 @@ -1449,11 +1449,11 @@ static int sendcmd(
33655 /*
33656 * Disable interrupt
33657 */
33658 - info_p->access.set_intr_mask(info_p, 0);
33659 + info_p->access->set_intr_mask(info_p, 0);
33660 /* Make sure there is room in the command FIFO */
33661 /* Actually it should be completely empty at this time. */
33662 for (i = 200000; i > 0; i--) {
33663 - temp = info_p->access.fifo_full(info_p);
33664 + temp = info_p->access->fifo_full(info_p);
33665 if (temp != 0) {
33666 break;
33667 }
33668 @@ -1466,7 +1466,7 @@ DBG(
33669 /*
33670 * Send the cmd
33671 */
33672 - info_p->access.submit_command(info_p, c);
33673 + info_p->access->submit_command(info_p, c);
33674 complete = pollcomplete(ctlr);
33675
33676 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33677 @@ -1549,9 +1549,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33678 * we check the new geometry. Then turn interrupts back on when
33679 * we're done.
33680 */
33681 - host->access.set_intr_mask(host, 0);
33682 + host->access->set_intr_mask(host, 0);
33683 getgeometry(ctlr);
33684 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33685 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33686
33687 for(i=0; i<NWD; i++) {
33688 struct gendisk *disk = ida_gendisk[ctlr][i];
33689 @@ -1591,7 +1591,7 @@ static int pollcomplete(int ctlr)
33690 /* Wait (up to 2 seconds) for a command to complete */
33691
33692 for (i = 200000; i > 0; i--) {
33693 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33694 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33695 if (done == 0) {
33696 udelay(10); /* a short fixed delay */
33697 } else
33698 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33699 index be73e9d..7fbf140 100644
33700 --- a/drivers/block/cpqarray.h
33701 +++ b/drivers/block/cpqarray.h
33702 @@ -99,7 +99,7 @@ struct ctlr_info {
33703 drv_info_t drv[NWD];
33704 struct proc_dir_entry *proc;
33705
33706 - struct access_method access;
33707 + struct access_method *access;
33708
33709 cmdlist_t *reqQ;
33710 cmdlist_t *cmpQ;
33711 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33712 index 6b51afa..17e1191 100644
33713 --- a/drivers/block/drbd/drbd_int.h
33714 +++ b/drivers/block/drbd/drbd_int.h
33715 @@ -582,7 +582,7 @@ struct drbd_epoch {
33716 struct drbd_tconn *tconn;
33717 struct list_head list;
33718 unsigned int barrier_nr;
33719 - atomic_t epoch_size; /* increased on every request added. */
33720 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33721 atomic_t active; /* increased on every req. added, and dec on every finished. */
33722 unsigned long flags;
33723 };
33724 @@ -1011,7 +1011,7 @@ struct drbd_conf {
33725 int al_tr_cycle;
33726 int al_tr_pos; /* position of the next transaction in the journal */
33727 wait_queue_head_t seq_wait;
33728 - atomic_t packet_seq;
33729 + atomic_unchecked_t packet_seq;
33730 unsigned int peer_seq;
33731 spinlock_t peer_seq_lock;
33732 unsigned int minor;
33733 @@ -1527,7 +1527,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33734 char __user *uoptval;
33735 int err;
33736
33737 - uoptval = (char __user __force *)optval;
33738 + uoptval = (char __force_user *)optval;
33739
33740 set_fs(KERNEL_DS);
33741 if (level == SOL_SOCKET)
33742 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33743 index 8c13eeb..217adee 100644
33744 --- a/drivers/block/drbd/drbd_main.c
33745 +++ b/drivers/block/drbd/drbd_main.c
33746 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33747 p->sector = sector;
33748 p->block_id = block_id;
33749 p->blksize = blksize;
33750 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33751 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33752 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33753 }
33754
33755 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33756 return -EIO;
33757 p->sector = cpu_to_be64(req->i.sector);
33758 p->block_id = (unsigned long)req;
33759 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33760 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33761 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33762 if (mdev->state.conn >= C_SYNC_SOURCE &&
33763 mdev->state.conn <= C_PAUSED_SYNC_T)
33764 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33765 {
33766 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33767
33768 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33769 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33770 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33771 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33772 kfree(tconn->current_epoch);
33773
33774 idr_destroy(&tconn->volumes);
33775 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33776 index a9eccfc..f5efe87 100644
33777 --- a/drivers/block/drbd/drbd_receiver.c
33778 +++ b/drivers/block/drbd/drbd_receiver.c
33779 @@ -833,7 +833,7 @@ int drbd_connected(struct drbd_conf *mdev)
33780 {
33781 int err;
33782
33783 - atomic_set(&mdev->packet_seq, 0);
33784 + atomic_set_unchecked(&mdev->packet_seq, 0);
33785 mdev->peer_seq = 0;
33786
33787 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33788 @@ -1191,7 +1191,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33789 do {
33790 next_epoch = NULL;
33791
33792 - epoch_size = atomic_read(&epoch->epoch_size);
33793 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33794
33795 switch (ev & ~EV_CLEANUP) {
33796 case EV_PUT:
33797 @@ -1231,7 +1231,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33798 rv = FE_DESTROYED;
33799 } else {
33800 epoch->flags = 0;
33801 - atomic_set(&epoch->epoch_size, 0);
33802 + atomic_set_unchecked(&epoch->epoch_size, 0);
33803 /* atomic_set(&epoch->active, 0); is already zero */
33804 if (rv == FE_STILL_LIVE)
33805 rv = FE_RECYCLED;
33806 @@ -1449,7 +1449,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33807 conn_wait_active_ee_empty(tconn);
33808 drbd_flush(tconn);
33809
33810 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33811 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33812 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33813 if (epoch)
33814 break;
33815 @@ -1462,11 +1462,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33816 }
33817
33818 epoch->flags = 0;
33819 - atomic_set(&epoch->epoch_size, 0);
33820 + atomic_set_unchecked(&epoch->epoch_size, 0);
33821 atomic_set(&epoch->active, 0);
33822
33823 spin_lock(&tconn->epoch_lock);
33824 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33825 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33826 list_add(&epoch->list, &tconn->current_epoch->list);
33827 tconn->current_epoch = epoch;
33828 tconn->epochs++;
33829 @@ -2170,7 +2170,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33830
33831 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33832 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33833 - atomic_inc(&tconn->current_epoch->epoch_size);
33834 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33835 err2 = drbd_drain_block(mdev, pi->size);
33836 if (!err)
33837 err = err2;
33838 @@ -2204,7 +2204,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33839
33840 spin_lock(&tconn->epoch_lock);
33841 peer_req->epoch = tconn->current_epoch;
33842 - atomic_inc(&peer_req->epoch->epoch_size);
33843 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33844 atomic_inc(&peer_req->epoch->active);
33845 spin_unlock(&tconn->epoch_lock);
33846
33847 @@ -4346,7 +4346,7 @@ struct data_cmd {
33848 int expect_payload;
33849 size_t pkt_size;
33850 int (*fn)(struct drbd_tconn *, struct packet_info *);
33851 -};
33852 +} __do_const;
33853
33854 static struct data_cmd drbd_cmd_handler[] = {
33855 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33856 @@ -4466,7 +4466,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33857 if (!list_empty(&tconn->current_epoch->list))
33858 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33859 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33860 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33861 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33862 tconn->send.seen_any_write_yet = false;
33863
33864 conn_info(tconn, "Connection closed\n");
33865 @@ -5222,7 +5222,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33866 struct asender_cmd {
33867 size_t pkt_size;
33868 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33869 -};
33870 +} __do_const;
33871
33872 static struct asender_cmd asender_tbl[] = {
33873 [P_PING] = { 0, got_Ping },
33874 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33875 index f74f2c0..bb668af 100644
33876 --- a/drivers/block/loop.c
33877 +++ b/drivers/block/loop.c
33878 @@ -226,7 +226,7 @@ static int __do_lo_send_write(struct file *file,
33879 mm_segment_t old_fs = get_fs();
33880
33881 set_fs(get_ds());
33882 - bw = file->f_op->write(file, buf, len, &pos);
33883 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33884 set_fs(old_fs);
33885 if (likely(bw == len))
33886 return 0;
33887 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33888 index d620b44..587561e 100644
33889 --- a/drivers/cdrom/cdrom.c
33890 +++ b/drivers/cdrom/cdrom.c
33891 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33892 ENSURE(reset, CDC_RESET);
33893 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33894 cdi->mc_flags = 0;
33895 - cdo->n_minors = 0;
33896 cdi->options = CDO_USE_FFLAGS;
33897
33898 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33899 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33900 else
33901 cdi->cdda_method = CDDA_OLD;
33902
33903 - if (!cdo->generic_packet)
33904 - cdo->generic_packet = cdrom_dummy_generic_packet;
33905 + if (!cdo->generic_packet) {
33906 + pax_open_kernel();
33907 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33908 + pax_close_kernel();
33909 + }
33910
33911 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33912 mutex_lock(&cdrom_mutex);
33913 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33914 if (cdi->exit)
33915 cdi->exit(cdi);
33916
33917 - cdi->ops->n_minors--;
33918 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33919 }
33920
33921 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33922 index d59cdcb..11afddf 100644
33923 --- a/drivers/cdrom/gdrom.c
33924 +++ b/drivers/cdrom/gdrom.c
33925 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33926 .audio_ioctl = gdrom_audio_ioctl,
33927 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
33928 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
33929 - .n_minors = 1,
33930 };
33931
33932 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
33933 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
33934 index 72bedad..8181ce1 100644
33935 --- a/drivers/char/Kconfig
33936 +++ b/drivers/char/Kconfig
33937 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
33938
33939 config DEVKMEM
33940 bool "/dev/kmem virtual device support"
33941 - default y
33942 + default n
33943 + depends on !GRKERNSEC_KMEM
33944 help
33945 Say Y here if you want to support the /dev/kmem device. The
33946 /dev/kmem device is rarely used, but can be used for certain
33947 @@ -581,6 +582,7 @@ config DEVPORT
33948 bool
33949 depends on !M68K
33950 depends on ISA || PCI
33951 + depends on !GRKERNSEC_KMEM
33952 default y
33953
33954 source "drivers/s390/char/Kconfig"
33955 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
33956 index 2e04433..22afc64 100644
33957 --- a/drivers/char/agp/frontend.c
33958 +++ b/drivers/char/agp/frontend.c
33959 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33960 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
33961 return -EFAULT;
33962
33963 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
33964 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
33965 return -EFAULT;
33966
33967 client = agp_find_client_by_pid(reserve.pid);
33968 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
33969 index 21cb980..f15107c 100644
33970 --- a/drivers/char/genrtc.c
33971 +++ b/drivers/char/genrtc.c
33972 @@ -272,6 +272,7 @@ static int gen_rtc_ioctl(struct file *file,
33973 switch (cmd) {
33974
33975 case RTC_PLL_GET:
33976 + memset(&pll, 0, sizeof(pll));
33977 if (get_rtc_pll(&pll))
33978 return -EINVAL;
33979 else
33980 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
33981 index fe6d4be..89f32100 100644
33982 --- a/drivers/char/hpet.c
33983 +++ b/drivers/char/hpet.c
33984 @@ -571,7 +571,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
33985 }
33986
33987 static int
33988 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
33989 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
33990 struct hpet_info *info)
33991 {
33992 struct hpet_timer __iomem *timer;
33993 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
33994 index 053201b0..8335cce 100644
33995 --- a/drivers/char/ipmi/ipmi_msghandler.c
33996 +++ b/drivers/char/ipmi/ipmi_msghandler.c
33997 @@ -420,7 +420,7 @@ struct ipmi_smi {
33998 struct proc_dir_entry *proc_dir;
33999 char proc_dir_name[10];
34000
34001 - atomic_t stats[IPMI_NUM_STATS];
34002 + atomic_unchecked_t stats[IPMI_NUM_STATS];
34003
34004 /*
34005 * run_to_completion duplicate of smb_info, smi_info
34006 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
34007
34008
34009 #define ipmi_inc_stat(intf, stat) \
34010 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
34011 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
34012 #define ipmi_get_stat(intf, stat) \
34013 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
34014 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
34015
34016 static int is_lan_addr(struct ipmi_addr *addr)
34017 {
34018 @@ -2884,7 +2884,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
34019 INIT_LIST_HEAD(&intf->cmd_rcvrs);
34020 init_waitqueue_head(&intf->waitq);
34021 for (i = 0; i < IPMI_NUM_STATS; i++)
34022 - atomic_set(&intf->stats[i], 0);
34023 + atomic_set_unchecked(&intf->stats[i], 0);
34024
34025 intf->proc_dir = NULL;
34026
34027 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
34028 index 1c7fdcd..4899100 100644
34029 --- a/drivers/char/ipmi/ipmi_si_intf.c
34030 +++ b/drivers/char/ipmi/ipmi_si_intf.c
34031 @@ -275,7 +275,7 @@ struct smi_info {
34032 unsigned char slave_addr;
34033
34034 /* Counters and things for the proc filesystem. */
34035 - atomic_t stats[SI_NUM_STATS];
34036 + atomic_unchecked_t stats[SI_NUM_STATS];
34037
34038 struct task_struct *thread;
34039
34040 @@ -284,9 +284,9 @@ struct smi_info {
34041 };
34042
34043 #define smi_inc_stat(smi, stat) \
34044 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
34045 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
34046 #define smi_get_stat(smi, stat) \
34047 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
34048 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
34049
34050 #define SI_MAX_PARMS 4
34051
34052 @@ -3225,7 +3225,7 @@ static int try_smi_init(struct smi_info *new_smi)
34053 atomic_set(&new_smi->req_events, 0);
34054 new_smi->run_to_completion = 0;
34055 for (i = 0; i < SI_NUM_STATS; i++)
34056 - atomic_set(&new_smi->stats[i], 0);
34057 + atomic_set_unchecked(&new_smi->stats[i], 0);
34058
34059 new_smi->interrupt_disabled = 1;
34060 atomic_set(&new_smi->stop_operation, 0);
34061 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
34062 index c6fa3bc..4ca3e42 100644
34063 --- a/drivers/char/mem.c
34064 +++ b/drivers/char/mem.c
34065 @@ -18,6 +18,7 @@
34066 #include <linux/raw.h>
34067 #include <linux/tty.h>
34068 #include <linux/capability.h>
34069 +#include <linux/security.h>
34070 #include <linux/ptrace.h>
34071 #include <linux/device.h>
34072 #include <linux/highmem.h>
34073 @@ -37,6 +38,10 @@
34074
34075 #define DEVPORT_MINOR 4
34076
34077 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34078 +extern const struct file_operations grsec_fops;
34079 +#endif
34080 +
34081 static inline unsigned long size_inside_page(unsigned long start,
34082 unsigned long size)
34083 {
34084 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34085
34086 while (cursor < to) {
34087 if (!devmem_is_allowed(pfn)) {
34088 +#ifdef CONFIG_GRKERNSEC_KMEM
34089 + gr_handle_mem_readwrite(from, to);
34090 +#else
34091 printk(KERN_INFO
34092 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
34093 current->comm, from, to);
34094 +#endif
34095 return 0;
34096 }
34097 cursor += PAGE_SIZE;
34098 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34099 }
34100 return 1;
34101 }
34102 +#elif defined(CONFIG_GRKERNSEC_KMEM)
34103 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34104 +{
34105 + return 0;
34106 +}
34107 #else
34108 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34109 {
34110 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34111
34112 while (count > 0) {
34113 unsigned long remaining;
34114 + char *temp;
34115
34116 sz = size_inside_page(p, count);
34117
34118 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34119 if (!ptr)
34120 return -EFAULT;
34121
34122 - remaining = copy_to_user(buf, ptr, sz);
34123 +#ifdef CONFIG_PAX_USERCOPY
34124 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34125 + if (!temp) {
34126 + unxlate_dev_mem_ptr(p, ptr);
34127 + return -ENOMEM;
34128 + }
34129 + memcpy(temp, ptr, sz);
34130 +#else
34131 + temp = ptr;
34132 +#endif
34133 +
34134 + remaining = copy_to_user(buf, temp, sz);
34135 +
34136 +#ifdef CONFIG_PAX_USERCOPY
34137 + kfree(temp);
34138 +#endif
34139 +
34140 unxlate_dev_mem_ptr(p, ptr);
34141 if (remaining)
34142 return -EFAULT;
34143 @@ -398,9 +429,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34144 size_t count, loff_t *ppos)
34145 {
34146 unsigned long p = *ppos;
34147 - ssize_t low_count, read, sz;
34148 + ssize_t low_count, read, sz, err = 0;
34149 char * kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
34150 - int err = 0;
34151
34152 read = 0;
34153 if (p < (unsigned long) high_memory) {
34154 @@ -422,6 +452,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34155 }
34156 #endif
34157 while (low_count > 0) {
34158 + char *temp;
34159 +
34160 sz = size_inside_page(p, low_count);
34161
34162 /*
34163 @@ -431,7 +463,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34164 */
34165 kbuf = xlate_dev_kmem_ptr((char *)p);
34166
34167 - if (copy_to_user(buf, kbuf, sz))
34168 +#ifdef CONFIG_PAX_USERCOPY
34169 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34170 + if (!temp)
34171 + return -ENOMEM;
34172 + memcpy(temp, kbuf, sz);
34173 +#else
34174 + temp = kbuf;
34175 +#endif
34176 +
34177 + err = copy_to_user(buf, temp, sz);
34178 +
34179 +#ifdef CONFIG_PAX_USERCOPY
34180 + kfree(temp);
34181 +#endif
34182 +
34183 + if (err)
34184 return -EFAULT;
34185 buf += sz;
34186 p += sz;
34187 @@ -833,6 +880,9 @@ static const struct memdev {
34188 #ifdef CONFIG_CRASH_DUMP
34189 [12] = { "oldmem", 0, &oldmem_fops, NULL },
34190 #endif
34191 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34192 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
34193 +#endif
34194 };
34195
34196 static int memory_open(struct inode *inode, struct file *filp)
34197 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
34198 index 9df78e2..01ba9ae 100644
34199 --- a/drivers/char/nvram.c
34200 +++ b/drivers/char/nvram.c
34201 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
34202
34203 spin_unlock_irq(&rtc_lock);
34204
34205 - if (copy_to_user(buf, contents, tmp - contents))
34206 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
34207 return -EFAULT;
34208
34209 *ppos = i;
34210 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
34211 index b66eaa0..2619d1b 100644
34212 --- a/drivers/char/pcmcia/synclink_cs.c
34213 +++ b/drivers/char/pcmcia/synclink_cs.c
34214 @@ -2348,9 +2348,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34215
34216 if (debug_level >= DEBUG_LEVEL_INFO)
34217 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
34218 - __FILE__,__LINE__, info->device_name, port->count);
34219 + __FILE__,__LINE__, info->device_name, atomic_read(&port->count));
34220
34221 - WARN_ON(!port->count);
34222 + WARN_ON(!atomic_read(&port->count));
34223
34224 if (tty_port_close_start(port, tty, filp) == 0)
34225 goto cleanup;
34226 @@ -2368,7 +2368,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34227 cleanup:
34228 if (debug_level >= DEBUG_LEVEL_INFO)
34229 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__,__LINE__,
34230 - tty->driver->name, port->count);
34231 + tty->driver->name, atomic_read(&port->count));
34232 }
34233
34234 /* Wait until the transmitter is empty.
34235 @@ -2510,7 +2510,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34236
34237 if (debug_level >= DEBUG_LEVEL_INFO)
34238 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
34239 - __FILE__,__LINE__,tty->driver->name, port->count);
34240 + __FILE__,__LINE__,tty->driver->name, atomic_read(&port->count));
34241
34242 /* If port is closing, signal caller to try again */
34243 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
34244 @@ -2530,11 +2530,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34245 goto cleanup;
34246 }
34247 spin_lock(&port->lock);
34248 - port->count++;
34249 + atomic_inc(&port->count);
34250 spin_unlock(&port->lock);
34251 spin_unlock_irqrestore(&info->netlock, flags);
34252
34253 - if (port->count == 1) {
34254 + if (atomic_read(&port->count) == 1) {
34255 /* 1st open on this device, init hardware */
34256 retval = startup(info, tty);
34257 if (retval < 0)
34258 @@ -3889,7 +3889,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
34259 unsigned short new_crctype;
34260
34261 /* return error if TTY interface open */
34262 - if (info->port.count)
34263 + if (atomic_read(&info->port.count))
34264 return -EBUSY;
34265
34266 switch (encoding)
34267 @@ -3992,7 +3992,7 @@ static int hdlcdev_open(struct net_device *dev)
34268
34269 /* arbitrate between network and tty opens */
34270 spin_lock_irqsave(&info->netlock, flags);
34271 - if (info->port.count != 0 || info->netcount != 0) {
34272 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
34273 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
34274 spin_unlock_irqrestore(&info->netlock, flags);
34275 return -EBUSY;
34276 @@ -4081,7 +4081,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
34277 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
34278
34279 /* return error if TTY interface open */
34280 - if (info->port.count)
34281 + if (atomic_read(&info->port.count))
34282 return -EBUSY;
34283
34284 if (cmd != SIOCWANDEV)
34285 diff --git a/drivers/char/random.c b/drivers/char/random.c
34286 index 57d4b15..253207b 100644
34287 --- a/drivers/char/random.c
34288 +++ b/drivers/char/random.c
34289 @@ -272,8 +272,13 @@
34290 /*
34291 * Configuration information
34292 */
34293 +#ifdef CONFIG_GRKERNSEC_RANDNET
34294 +#define INPUT_POOL_WORDS 512
34295 +#define OUTPUT_POOL_WORDS 128
34296 +#else
34297 #define INPUT_POOL_WORDS 128
34298 #define OUTPUT_POOL_WORDS 32
34299 +#endif
34300 #define SEC_XFER_SIZE 512
34301 #define EXTRACT_SIZE 10
34302
34303 @@ -313,10 +318,17 @@ static struct poolinfo {
34304 int poolwords;
34305 int tap1, tap2, tap3, tap4, tap5;
34306 } poolinfo_table[] = {
34307 +#ifdef CONFIG_GRKERNSEC_RANDNET
34308 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
34309 + { 512, 411, 308, 208, 104, 1 },
34310 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
34311 + { 128, 103, 76, 51, 25, 1 },
34312 +#else
34313 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
34314 { 128, 103, 76, 51, 25, 1 },
34315 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
34316 { 32, 26, 20, 14, 7, 1 },
34317 +#endif
34318 #if 0
34319 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
34320 { 2048, 1638, 1231, 819, 411, 1 },
34321 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
34322 input_rotate += i ? 7 : 14;
34323 }
34324
34325 - ACCESS_ONCE(r->input_rotate) = input_rotate;
34326 - ACCESS_ONCE(r->add_ptr) = i;
34327 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
34328 + ACCESS_ONCE_RW(r->add_ptr) = i;
34329 smp_wmb();
34330
34331 if (out)
34332 @@ -1024,7 +1036,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
34333
34334 extract_buf(r, tmp);
34335 i = min_t(int, nbytes, EXTRACT_SIZE);
34336 - if (copy_to_user(buf, tmp, i)) {
34337 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
34338 ret = -EFAULT;
34339 break;
34340 }
34341 @@ -1360,7 +1372,7 @@ EXPORT_SYMBOL(generate_random_uuid);
34342 #include <linux/sysctl.h>
34343
34344 static int min_read_thresh = 8, min_write_thresh;
34345 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
34346 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
34347 static int max_write_thresh = INPUT_POOL_WORDS * 32;
34348 static char sysctl_bootid[16];
34349
34350 @@ -1376,7 +1388,7 @@ static char sysctl_bootid[16];
34351 static int proc_do_uuid(ctl_table *table, int write,
34352 void __user *buffer, size_t *lenp, loff_t *ppos)
34353 {
34354 - ctl_table fake_table;
34355 + ctl_table_no_const fake_table;
34356 unsigned char buf[64], tmp_uuid[16], *uuid;
34357
34358 uuid = table->data;
34359 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
34360 index d780295..b29f3a8 100644
34361 --- a/drivers/char/sonypi.c
34362 +++ b/drivers/char/sonypi.c
34363 @@ -54,6 +54,7 @@
34364
34365 #include <asm/uaccess.h>
34366 #include <asm/io.h>
34367 +#include <asm/local.h>
34368
34369 #include <linux/sonypi.h>
34370
34371 @@ -490,7 +491,7 @@ static struct sonypi_device {
34372 spinlock_t fifo_lock;
34373 wait_queue_head_t fifo_proc_list;
34374 struct fasync_struct *fifo_async;
34375 - int open_count;
34376 + local_t open_count;
34377 int model;
34378 struct input_dev *input_jog_dev;
34379 struct input_dev *input_key_dev;
34380 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
34381 static int sonypi_misc_release(struct inode *inode, struct file *file)
34382 {
34383 mutex_lock(&sonypi_device.lock);
34384 - sonypi_device.open_count--;
34385 + local_dec(&sonypi_device.open_count);
34386 mutex_unlock(&sonypi_device.lock);
34387 return 0;
34388 }
34389 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
34390 {
34391 mutex_lock(&sonypi_device.lock);
34392 /* Flush input queue on first open */
34393 - if (!sonypi_device.open_count)
34394 + if (!local_read(&sonypi_device.open_count))
34395 kfifo_reset(&sonypi_device.fifo);
34396 - sonypi_device.open_count++;
34397 + local_inc(&sonypi_device.open_count);
34398 mutex_unlock(&sonypi_device.lock);
34399
34400 return 0;
34401 diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
34402 index 93211df..c7805f7 100644
34403 --- a/drivers/char/tpm/tpm.c
34404 +++ b/drivers/char/tpm/tpm.c
34405 @@ -410,7 +410,7 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
34406 chip->vendor.req_complete_val)
34407 goto out_recv;
34408
34409 - if ((status == chip->vendor.req_canceled)) {
34410 + if (status == chip->vendor.req_canceled) {
34411 dev_err(chip->dev, "Operation Canceled\n");
34412 rc = -ECANCELED;
34413 goto out;
34414 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
34415 index 56051d0..11cf3b7 100644
34416 --- a/drivers/char/tpm/tpm_acpi.c
34417 +++ b/drivers/char/tpm/tpm_acpi.c
34418 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
34419 virt = acpi_os_map_memory(start, len);
34420 if (!virt) {
34421 kfree(log->bios_event_log);
34422 + log->bios_event_log = NULL;
34423 printk("%s: ERROR - Unable to map memory\n", __func__);
34424 return -EIO;
34425 }
34426
34427 - memcpy_fromio(log->bios_event_log, virt, len);
34428 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
34429
34430 acpi_os_unmap_memory(virt, len);
34431 return 0;
34432 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
34433 index 84ddc55..1d32f1e 100644
34434 --- a/drivers/char/tpm/tpm_eventlog.c
34435 +++ b/drivers/char/tpm/tpm_eventlog.c
34436 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
34437 event = addr;
34438
34439 if ((event->event_type == 0 && event->event_size == 0) ||
34440 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
34441 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
34442 return NULL;
34443
34444 return addr;
34445 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
34446 return NULL;
34447
34448 if ((event->event_type == 0 && event->event_size == 0) ||
34449 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
34450 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
34451 return NULL;
34452
34453 (*pos)++;
34454 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
34455 int i;
34456
34457 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
34458 - seq_putc(m, data[i]);
34459 + if (!seq_putc(m, data[i]))
34460 + return -EFAULT;
34461
34462 return 0;
34463 }
34464 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
34465 index a4b7aa0..2faa0bc 100644
34466 --- a/drivers/char/virtio_console.c
34467 +++ b/drivers/char/virtio_console.c
34468 @@ -685,7 +685,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
34469 if (to_user) {
34470 ssize_t ret;
34471
34472 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
34473 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
34474 if (ret)
34475 return -EFAULT;
34476 } else {
34477 @@ -784,7 +784,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
34478 if (!port_has_data(port) && !port->host_connected)
34479 return 0;
34480
34481 - return fill_readbuf(port, ubuf, count, true);
34482 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
34483 }
34484
34485 static int wait_port_writable(struct port *port, bool nonblock)
34486 diff --git a/drivers/clocksource/arm_generic.c b/drivers/clocksource/arm_generic.c
34487 index 8ae1a61..9c00613 100644
34488 --- a/drivers/clocksource/arm_generic.c
34489 +++ b/drivers/clocksource/arm_generic.c
34490 @@ -181,7 +181,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34491 return NOTIFY_OK;
34492 }
34493
34494 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
34495 +static struct notifier_block arch_timer_cpu_nb = {
34496 .notifier_call = arch_timer_cpu_notify,
34497 };
34498
34499 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
34500 index 7b0d49d..134fac9 100644
34501 --- a/drivers/cpufreq/acpi-cpufreq.c
34502 +++ b/drivers/cpufreq/acpi-cpufreq.c
34503 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
34504 return sprintf(buf, "%u\n", boost_enabled);
34505 }
34506
34507 -static struct global_attr global_boost = __ATTR(boost, 0644,
34508 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
34509 show_global_boost,
34510 store_global_boost);
34511
34512 @@ -712,8 +712,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34513 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
34514 per_cpu(acfreq_data, cpu) = data;
34515
34516 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
34517 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34518 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
34519 + pax_open_kernel();
34520 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34521 + pax_close_kernel();
34522 + }
34523
34524 result = acpi_processor_register_performance(data->acpi_data, cpu);
34525 if (result)
34526 @@ -835,7 +838,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34527 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
34528 break;
34529 case ACPI_ADR_SPACE_FIXED_HARDWARE:
34530 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34531 + pax_open_kernel();
34532 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34533 + pax_close_kernel();
34534 policy->cur = get_cur_freq_on_cpu(cpu);
34535 break;
34536 default:
34537 @@ -846,8 +851,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34538 acpi_processor_notify_smm(THIS_MODULE);
34539
34540 /* Check for APERF/MPERF support in hardware */
34541 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
34542 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34543 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
34544 + pax_open_kernel();
34545 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34546 + pax_close_kernel();
34547 + }
34548
34549 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
34550 for (i = 0; i < perf->state_count; i++)
34551 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
34552 index 1f93dbd..305cef1 100644
34553 --- a/drivers/cpufreq/cpufreq.c
34554 +++ b/drivers/cpufreq/cpufreq.c
34555 @@ -1843,7 +1843,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34556 return NOTIFY_OK;
34557 }
34558
34559 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34560 +static struct notifier_block cpufreq_cpu_notifier = {
34561 .notifier_call = cpufreq_cpu_callback,
34562 };
34563
34564 @@ -1875,8 +1875,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34565
34566 pr_debug("trying to register driver %s\n", driver_data->name);
34567
34568 - if (driver_data->setpolicy)
34569 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34570 + if (driver_data->setpolicy) {
34571 + pax_open_kernel();
34572 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34573 + pax_close_kernel();
34574 + }
34575
34576 spin_lock_irqsave(&cpufreq_driver_lock, flags);
34577 if (cpufreq_driver) {
34578 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34579 index 6c5f1d3..c7e2f35e 100644
34580 --- a/drivers/cpufreq/cpufreq_governor.c
34581 +++ b/drivers/cpufreq/cpufreq_governor.c
34582 @@ -243,7 +243,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34583 * governor, thus we are bound to jiffes/HZ
34584 */
34585 if (dbs_data->governor == GOV_CONSERVATIVE) {
34586 - struct cs_ops *ops = dbs_data->gov_ops;
34587 + const struct cs_ops *ops = dbs_data->gov_ops;
34588
34589 cpufreq_register_notifier(ops->notifier_block,
34590 CPUFREQ_TRANSITION_NOTIFIER);
34591 @@ -251,7 +251,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34592 dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO *
34593 jiffies_to_usecs(10);
34594 } else {
34595 - struct od_ops *ops = dbs_data->gov_ops;
34596 + const struct od_ops *ops = dbs_data->gov_ops;
34597
34598 od_tuners->io_is_busy = ops->io_busy();
34599 }
34600 @@ -268,7 +268,7 @@ second_time:
34601 cs_dbs_info->enable = 1;
34602 cs_dbs_info->requested_freq = policy->cur;
34603 } else {
34604 - struct od_ops *ops = dbs_data->gov_ops;
34605 + const struct od_ops *ops = dbs_data->gov_ops;
34606 od_dbs_info->rate_mult = 1;
34607 od_dbs_info->sample_type = OD_NORMAL_SAMPLE;
34608 ops->powersave_bias_init_cpu(cpu);
34609 @@ -289,7 +289,7 @@ second_time:
34610 mutex_destroy(&cpu_cdbs->timer_mutex);
34611 dbs_data->enable--;
34612 if (!dbs_data->enable) {
34613 - struct cs_ops *ops = dbs_data->gov_ops;
34614 + const struct cs_ops *ops = dbs_data->gov_ops;
34615
34616 sysfs_remove_group(cpufreq_global_kobject,
34617 dbs_data->attr_group);
34618 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34619 index f661654..6c8e638 100644
34620 --- a/drivers/cpufreq/cpufreq_governor.h
34621 +++ b/drivers/cpufreq/cpufreq_governor.h
34622 @@ -142,7 +142,7 @@ struct dbs_data {
34623 void (*gov_check_cpu)(int cpu, unsigned int load);
34624
34625 /* Governor specific ops, see below */
34626 - void *gov_ops;
34627 + const void *gov_ops;
34628 };
34629
34630 /* Governor specific ops, will be passed to dbs_data->gov_ops */
34631 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34632 index 9d7732b..0b1a793 100644
34633 --- a/drivers/cpufreq/cpufreq_stats.c
34634 +++ b/drivers/cpufreq/cpufreq_stats.c
34635 @@ -340,7 +340,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34636 }
34637
34638 /* priority=1 so this will get called before cpufreq_remove_dev */
34639 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34640 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34641 .notifier_call = cpufreq_stat_cpu_callback,
34642 .priority = 1,
34643 };
34644 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34645 index 827629c9..0bc6a03 100644
34646 --- a/drivers/cpufreq/p4-clockmod.c
34647 +++ b/drivers/cpufreq/p4-clockmod.c
34648 @@ -167,10 +167,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34649 case 0x0F: /* Core Duo */
34650 case 0x16: /* Celeron Core */
34651 case 0x1C: /* Atom */
34652 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34653 + pax_open_kernel();
34654 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34655 + pax_close_kernel();
34656 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34657 case 0x0D: /* Pentium M (Dothan) */
34658 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34659 + pax_open_kernel();
34660 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34661 + pax_close_kernel();
34662 /* fall through */
34663 case 0x09: /* Pentium M (Banias) */
34664 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34665 @@ -182,7 +186,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34666
34667 /* on P-4s, the TSC runs with constant frequency independent whether
34668 * throttling is active or not. */
34669 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34670 + pax_open_kernel();
34671 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34672 + pax_close_kernel();
34673
34674 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34675 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34676 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34677 index 3a953d5..f5993f6 100644
34678 --- a/drivers/cpufreq/speedstep-centrino.c
34679 +++ b/drivers/cpufreq/speedstep-centrino.c
34680 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34681 !cpu_has(cpu, X86_FEATURE_EST))
34682 return -ENODEV;
34683
34684 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34685 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34686 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34687 + pax_open_kernel();
34688 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34689 + pax_close_kernel();
34690 + }
34691
34692 if (policy->cpu != 0)
34693 return -ENODEV;
34694 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34695 index e1f6860..f8de20b 100644
34696 --- a/drivers/cpuidle/cpuidle.c
34697 +++ b/drivers/cpuidle/cpuidle.c
34698 @@ -279,7 +279,7 @@ static int poll_idle(struct cpuidle_device *dev,
34699
34700 static void poll_idle_init(struct cpuidle_driver *drv)
34701 {
34702 - struct cpuidle_state *state = &drv->states[0];
34703 + cpuidle_state_no_const *state = &drv->states[0];
34704
34705 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34706 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34707 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34708 index ea2f8e7..70ac501 100644
34709 --- a/drivers/cpuidle/governor.c
34710 +++ b/drivers/cpuidle/governor.c
34711 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34712 mutex_lock(&cpuidle_lock);
34713 if (__cpuidle_find_governor(gov->name) == NULL) {
34714 ret = 0;
34715 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34716 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34717 if (!cpuidle_curr_governor ||
34718 cpuidle_curr_governor->rating < gov->rating)
34719 cpuidle_switch_governor(gov);
34720 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34721 new_gov = cpuidle_replace_governor(gov->rating);
34722 cpuidle_switch_governor(new_gov);
34723 }
34724 - list_del(&gov->governor_list);
34725 + pax_list_del((struct list_head *)&gov->governor_list);
34726 mutex_unlock(&cpuidle_lock);
34727 }
34728
34729 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34730 index 428754a..8bdf9cc 100644
34731 --- a/drivers/cpuidle/sysfs.c
34732 +++ b/drivers/cpuidle/sysfs.c
34733 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34734 NULL
34735 };
34736
34737 -static struct attribute_group cpuidle_attr_group = {
34738 +static attribute_group_no_const cpuidle_attr_group = {
34739 .attrs = cpuidle_default_attrs,
34740 .name = "cpuidle",
34741 };
34742 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34743 index 3b36797..289c16a 100644
34744 --- a/drivers/devfreq/devfreq.c
34745 +++ b/drivers/devfreq/devfreq.c
34746 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34747 goto err_out;
34748 }
34749
34750 - list_add(&governor->node, &devfreq_governor_list);
34751 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34752
34753 list_for_each_entry(devfreq, &devfreq_list, node) {
34754 int ret = 0;
34755 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34756 }
34757 }
34758
34759 - list_del(&governor->node);
34760 + pax_list_del((struct list_head *)&governor->node);
34761 err_out:
34762 mutex_unlock(&devfreq_list_lock);
34763
34764 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34765 index b70709b..1d8d02a 100644
34766 --- a/drivers/dma/sh/shdma.c
34767 +++ b/drivers/dma/sh/shdma.c
34768 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34769 return ret;
34770 }
34771
34772 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34773 +static struct notifier_block sh_dmae_nmi_notifier = {
34774 .notifier_call = sh_dmae_nmi_handler,
34775
34776 /* Run before NMI debug handler and KGDB */
34777 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34778 index 0ca1ca7..6e6f454 100644
34779 --- a/drivers/edac/edac_mc_sysfs.c
34780 +++ b/drivers/edac/edac_mc_sysfs.c
34781 @@ -148,7 +148,7 @@ static const char *edac_caps[] = {
34782 struct dev_ch_attribute {
34783 struct device_attribute attr;
34784 int channel;
34785 -};
34786 +} __do_const;
34787
34788 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34789 struct dev_ch_attribute dev_attr_legacy_##_name = \
34790 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34791 index 0056c4d..23b54d9 100644
34792 --- a/drivers/edac/edac_pci_sysfs.c
34793 +++ b/drivers/edac/edac_pci_sysfs.c
34794 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34795 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34796 static int edac_pci_poll_msec = 1000; /* one second workq period */
34797
34798 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34799 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34800 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34801 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34802
34803 static struct kobject *edac_pci_top_main_kobj;
34804 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34805 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34806 void *value;
34807 ssize_t(*show) (void *, char *);
34808 ssize_t(*store) (void *, const char *, size_t);
34809 -};
34810 +} __do_const;
34811
34812 /* Set of show/store abstract level functions for PCI Parity object */
34813 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
34814 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34815 edac_printk(KERN_CRIT, EDAC_PCI,
34816 "Signaled System Error on %s\n",
34817 pci_name(dev));
34818 - atomic_inc(&pci_nonparity_count);
34819 + atomic_inc_unchecked(&pci_nonparity_count);
34820 }
34821
34822 if (status & (PCI_STATUS_PARITY)) {
34823 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34824 "Master Data Parity Error on %s\n",
34825 pci_name(dev));
34826
34827 - atomic_inc(&pci_parity_count);
34828 + atomic_inc_unchecked(&pci_parity_count);
34829 }
34830
34831 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34832 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34833 "Detected Parity Error on %s\n",
34834 pci_name(dev));
34835
34836 - atomic_inc(&pci_parity_count);
34837 + atomic_inc_unchecked(&pci_parity_count);
34838 }
34839 }
34840
34841 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34842 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
34843 "Signaled System Error on %s\n",
34844 pci_name(dev));
34845 - atomic_inc(&pci_nonparity_count);
34846 + atomic_inc_unchecked(&pci_nonparity_count);
34847 }
34848
34849 if (status & (PCI_STATUS_PARITY)) {
34850 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34851 "Master Data Parity Error on "
34852 "%s\n", pci_name(dev));
34853
34854 - atomic_inc(&pci_parity_count);
34855 + atomic_inc_unchecked(&pci_parity_count);
34856 }
34857
34858 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34859 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34860 "Detected Parity Error on %s\n",
34861 pci_name(dev));
34862
34863 - atomic_inc(&pci_parity_count);
34864 + atomic_inc_unchecked(&pci_parity_count);
34865 }
34866 }
34867 }
34868 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
34869 if (!check_pci_errors)
34870 return;
34871
34872 - before_count = atomic_read(&pci_parity_count);
34873 + before_count = atomic_read_unchecked(&pci_parity_count);
34874
34875 /* scan all PCI devices looking for a Parity Error on devices and
34876 * bridges.
34877 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
34878 /* Only if operator has selected panic on PCI Error */
34879 if (edac_pci_get_panic_on_pe()) {
34880 /* If the count is different 'after' from 'before' */
34881 - if (before_count != atomic_read(&pci_parity_count))
34882 + if (before_count != atomic_read_unchecked(&pci_parity_count))
34883 panic("EDAC: PCI Parity Error");
34884 }
34885 }
34886 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
34887 index 6796799..99e8377 100644
34888 --- a/drivers/edac/mce_amd.h
34889 +++ b/drivers/edac/mce_amd.h
34890 @@ -78,7 +78,7 @@ extern const char * const ii_msgs[];
34891 struct amd_decoder_ops {
34892 bool (*mc0_mce)(u16, u8);
34893 bool (*mc1_mce)(u16, u8);
34894 -};
34895 +} __no_const;
34896
34897 void amd_report_gart_errors(bool);
34898 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
34899 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
34900 index 57ea7f4..789e3c3 100644
34901 --- a/drivers/firewire/core-card.c
34902 +++ b/drivers/firewire/core-card.c
34903 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
34904
34905 void fw_core_remove_card(struct fw_card *card)
34906 {
34907 - struct fw_card_driver dummy_driver = dummy_driver_template;
34908 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
34909
34910 card->driver->update_phy_reg(card, 4,
34911 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
34912 diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
34913 index f8d2287..5aaf4db 100644
34914 --- a/drivers/firewire/core-cdev.c
34915 +++ b/drivers/firewire/core-cdev.c
34916 @@ -1365,8 +1365,7 @@ static int init_iso_resource(struct client *client,
34917 int ret;
34918
34919 if ((request->channels == 0 && request->bandwidth == 0) ||
34920 - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL ||
34921 - request->bandwidth < 0)
34922 + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
34923 return -EINVAL;
34924
34925 r = kmalloc(sizeof(*r), GFP_KERNEL);
34926 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
34927 index af3e8aa..eb2f227 100644
34928 --- a/drivers/firewire/core-device.c
34929 +++ b/drivers/firewire/core-device.c
34930 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
34931 struct config_rom_attribute {
34932 struct device_attribute attr;
34933 u32 key;
34934 -};
34935 +} __do_const;
34936
34937 static ssize_t show_immediate(struct device *dev,
34938 struct device_attribute *dattr, char *buf)
34939 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
34940 index 28a94c7..58da63a 100644
34941 --- a/drivers/firewire/core-transaction.c
34942 +++ b/drivers/firewire/core-transaction.c
34943 @@ -38,6 +38,7 @@
34944 #include <linux/timer.h>
34945 #include <linux/types.h>
34946 #include <linux/workqueue.h>
34947 +#include <linux/sched.h>
34948
34949 #include <asm/byteorder.h>
34950
34951 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
34952 index 515a42c..5ecf3ba 100644
34953 --- a/drivers/firewire/core.h
34954 +++ b/drivers/firewire/core.h
34955 @@ -111,6 +111,7 @@ struct fw_card_driver {
34956
34957 int (*stop_iso)(struct fw_iso_context *ctx);
34958 };
34959 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
34960
34961 void fw_card_initialize(struct fw_card *card,
34962 const struct fw_card_driver *driver, struct device *device);
34963 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
34964 index 94a58a0..f5eba42 100644
34965 --- a/drivers/firmware/dmi-id.c
34966 +++ b/drivers/firmware/dmi-id.c
34967 @@ -16,7 +16,7 @@
34968 struct dmi_device_attribute{
34969 struct device_attribute dev_attr;
34970 int field;
34971 -};
34972 +} __do_const;
34973 #define to_dmi_dev_attr(_dev_attr) \
34974 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
34975
34976 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
34977 index 4cd392d..4b629e1 100644
34978 --- a/drivers/firmware/dmi_scan.c
34979 +++ b/drivers/firmware/dmi_scan.c
34980 @@ -490,11 +490,6 @@ void __init dmi_scan_machine(void)
34981 }
34982 }
34983 else {
34984 - /*
34985 - * no iounmap() for that ioremap(); it would be a no-op, but
34986 - * it's so early in setup that sucker gets confused into doing
34987 - * what it shouldn't if we actually call it.
34988 - */
34989 p = dmi_ioremap(0xF0000, 0x10000);
34990 if (p == NULL)
34991 goto error;
34992 @@ -769,7 +764,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
34993 if (buf == NULL)
34994 return -1;
34995
34996 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
34997 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
34998
34999 iounmap(buf);
35000 return 0;
35001 diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
35002 index b07cb37..2a51037 100644
35003 --- a/drivers/firmware/efivars.c
35004 +++ b/drivers/firmware/efivars.c
35005 @@ -138,7 +138,7 @@ struct efivar_attribute {
35006 };
35007
35008 static struct efivars __efivars;
35009 -static struct efivar_operations ops;
35010 +static efivar_operations_no_const ops __read_only;
35011
35012 #define PSTORE_EFI_ATTRIBUTES \
35013 (EFI_VARIABLE_NON_VOLATILE | \
35014 @@ -1834,7 +1834,7 @@ efivar_create_sysfs_entry(struct efivars *efivars,
35015 static int
35016 create_efivars_bin_attributes(struct efivars *efivars)
35017 {
35018 - struct bin_attribute *attr;
35019 + bin_attribute_no_const *attr;
35020 int error;
35021
35022 /* new_var */
35023 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
35024 index 2a90ba6..07f3733 100644
35025 --- a/drivers/firmware/google/memconsole.c
35026 +++ b/drivers/firmware/google/memconsole.c
35027 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
35028 if (!found_memconsole())
35029 return -ENODEV;
35030
35031 - memconsole_bin_attr.size = memconsole_length;
35032 + pax_open_kernel();
35033 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
35034 + pax_close_kernel();
35035
35036 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
35037
35038 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
35039 index 6f2306d..af9476a 100644
35040 --- a/drivers/gpio/gpio-ich.c
35041 +++ b/drivers/gpio/gpio-ich.c
35042 @@ -69,7 +69,7 @@ struct ichx_desc {
35043 /* Some chipsets have quirks, let these use their own request/get */
35044 int (*request)(struct gpio_chip *chip, unsigned offset);
35045 int (*get)(struct gpio_chip *chip, unsigned offset);
35046 -};
35047 +} __do_const;
35048
35049 static struct {
35050 spinlock_t lock;
35051 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
35052 index 9902732..64b62dd 100644
35053 --- a/drivers/gpio/gpio-vr41xx.c
35054 +++ b/drivers/gpio/gpio-vr41xx.c
35055 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
35056 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
35057 maskl, pendl, maskh, pendh);
35058
35059 - atomic_inc(&irq_err_count);
35060 + atomic_inc_unchecked(&irq_err_count);
35061
35062 return -EINVAL;
35063 }
35064 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
35065 index 7b2d378..cc947ea 100644
35066 --- a/drivers/gpu/drm/drm_crtc_helper.c
35067 +++ b/drivers/gpu/drm/drm_crtc_helper.c
35068 @@ -319,7 +319,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
35069 struct drm_crtc *tmp;
35070 int crtc_mask = 1;
35071
35072 - WARN(!crtc, "checking null crtc?\n");
35073 + BUG_ON(!crtc);
35074
35075 dev = crtc->dev;
35076
35077 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
35078 index be174ca..7f38143 100644
35079 --- a/drivers/gpu/drm/drm_drv.c
35080 +++ b/drivers/gpu/drm/drm_drv.c
35081 @@ -307,7 +307,7 @@ module_exit(drm_core_exit);
35082 /**
35083 * Copy and IOCTL return string to user space
35084 */
35085 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
35086 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
35087 {
35088 int len;
35089
35090 @@ -377,7 +377,7 @@ long drm_ioctl(struct file *filp,
35091 struct drm_file *file_priv = filp->private_data;
35092 struct drm_device *dev;
35093 struct drm_ioctl_desc *ioctl;
35094 - drm_ioctl_t *func;
35095 + drm_ioctl_no_const_t func;
35096 unsigned int nr = DRM_IOCTL_NR(cmd);
35097 int retcode = -EINVAL;
35098 char stack_kdata[128];
35099 @@ -390,7 +390,7 @@ long drm_ioctl(struct file *filp,
35100 return -ENODEV;
35101
35102 atomic_inc(&dev->ioctl_count);
35103 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
35104 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
35105 ++file_priv->ioctl_count;
35106
35107 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
35108 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
35109 index 133b413..fd68225 100644
35110 --- a/drivers/gpu/drm/drm_fops.c
35111 +++ b/drivers/gpu/drm/drm_fops.c
35112 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
35113 }
35114
35115 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
35116 - atomic_set(&dev->counts[i], 0);
35117 + atomic_set_unchecked(&dev->counts[i], 0);
35118
35119 dev->sigdata.lock = NULL;
35120
35121 @@ -134,7 +134,7 @@ int drm_open(struct inode *inode, struct file *filp)
35122 if (drm_device_is_unplugged(dev))
35123 return -ENODEV;
35124
35125 - if (!dev->open_count++)
35126 + if (local_inc_return(&dev->open_count) == 1)
35127 need_setup = 1;
35128 mutex_lock(&dev->struct_mutex);
35129 old_mapping = dev->dev_mapping;
35130 @@ -149,7 +149,7 @@ int drm_open(struct inode *inode, struct file *filp)
35131 retcode = drm_open_helper(inode, filp, dev);
35132 if (retcode)
35133 goto err_undo;
35134 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
35135 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
35136 if (need_setup) {
35137 retcode = drm_setup(dev);
35138 if (retcode)
35139 @@ -164,7 +164,7 @@ err_undo:
35140 iput(container_of(dev->dev_mapping, struct inode, i_data));
35141 dev->dev_mapping = old_mapping;
35142 mutex_unlock(&dev->struct_mutex);
35143 - dev->open_count--;
35144 + local_dec(&dev->open_count);
35145 return retcode;
35146 }
35147 EXPORT_SYMBOL(drm_open);
35148 @@ -438,7 +438,7 @@ int drm_release(struct inode *inode, struct file *filp)
35149
35150 mutex_lock(&drm_global_mutex);
35151
35152 - DRM_DEBUG("open_count = %d\n", dev->open_count);
35153 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
35154
35155 if (dev->driver->preclose)
35156 dev->driver->preclose(dev, file_priv);
35157 @@ -447,10 +447,10 @@ int drm_release(struct inode *inode, struct file *filp)
35158 * Begin inline drm_release
35159 */
35160
35161 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
35162 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
35163 task_pid_nr(current),
35164 (long)old_encode_dev(file_priv->minor->device),
35165 - dev->open_count);
35166 + local_read(&dev->open_count));
35167
35168 /* Release any auth tokens that might point to this file_priv,
35169 (do that under the drm_global_mutex) */
35170 @@ -547,8 +547,8 @@ int drm_release(struct inode *inode, struct file *filp)
35171 * End inline drm_release
35172 */
35173
35174 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
35175 - if (!--dev->open_count) {
35176 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
35177 + if (local_dec_and_test(&dev->open_count)) {
35178 if (atomic_read(&dev->ioctl_count)) {
35179 DRM_ERROR("Device busy: %d\n",
35180 atomic_read(&dev->ioctl_count));
35181 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
35182 index f731116..629842c 100644
35183 --- a/drivers/gpu/drm/drm_global.c
35184 +++ b/drivers/gpu/drm/drm_global.c
35185 @@ -36,7 +36,7 @@
35186 struct drm_global_item {
35187 struct mutex mutex;
35188 void *object;
35189 - int refcount;
35190 + atomic_t refcount;
35191 };
35192
35193 static struct drm_global_item glob[DRM_GLOBAL_NUM];
35194 @@ -49,7 +49,7 @@ void drm_global_init(void)
35195 struct drm_global_item *item = &glob[i];
35196 mutex_init(&item->mutex);
35197 item->object = NULL;
35198 - item->refcount = 0;
35199 + atomic_set(&item->refcount, 0);
35200 }
35201 }
35202
35203 @@ -59,7 +59,7 @@ void drm_global_release(void)
35204 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
35205 struct drm_global_item *item = &glob[i];
35206 BUG_ON(item->object != NULL);
35207 - BUG_ON(item->refcount != 0);
35208 + BUG_ON(atomic_read(&item->refcount) != 0);
35209 }
35210 }
35211
35212 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35213 void *object;
35214
35215 mutex_lock(&item->mutex);
35216 - if (item->refcount == 0) {
35217 + if (atomic_read(&item->refcount) == 0) {
35218 item->object = kzalloc(ref->size, GFP_KERNEL);
35219 if (unlikely(item->object == NULL)) {
35220 ret = -ENOMEM;
35221 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35222 goto out_err;
35223
35224 }
35225 - ++item->refcount;
35226 + atomic_inc(&item->refcount);
35227 ref->object = item->object;
35228 object = item->object;
35229 mutex_unlock(&item->mutex);
35230 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
35231 struct drm_global_item *item = &glob[ref->global_type];
35232
35233 mutex_lock(&item->mutex);
35234 - BUG_ON(item->refcount == 0);
35235 + BUG_ON(atomic_read(&item->refcount) == 0);
35236 BUG_ON(ref->object != item->object);
35237 - if (--item->refcount == 0) {
35238 + if (atomic_dec_and_test(&item->refcount)) {
35239 ref->release(ref);
35240 item->object = NULL;
35241 }
35242 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
35243 index d4b20ce..77a8d41 100644
35244 --- a/drivers/gpu/drm/drm_info.c
35245 +++ b/drivers/gpu/drm/drm_info.c
35246 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
35247 struct drm_local_map *map;
35248 struct drm_map_list *r_list;
35249
35250 - /* Hardcoded from _DRM_FRAME_BUFFER,
35251 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
35252 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
35253 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
35254 + static const char * const types[] = {
35255 + [_DRM_FRAME_BUFFER] = "FB",
35256 + [_DRM_REGISTERS] = "REG",
35257 + [_DRM_SHM] = "SHM",
35258 + [_DRM_AGP] = "AGP",
35259 + [_DRM_SCATTER_GATHER] = "SG",
35260 + [_DRM_CONSISTENT] = "PCI",
35261 + [_DRM_GEM] = "GEM" };
35262 const char *type;
35263 int i;
35264
35265 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
35266 map = r_list->map;
35267 if (!map)
35268 continue;
35269 - if (map->type < 0 || map->type > 5)
35270 + if (map->type >= ARRAY_SIZE(types))
35271 type = "??";
35272 else
35273 type = types[map->type];
35274 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
35275 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
35276 vma->vm_flags & VM_LOCKED ? 'l' : '-',
35277 vma->vm_flags & VM_IO ? 'i' : '-',
35278 +#ifdef CONFIG_GRKERNSEC_HIDESYM
35279 + 0);
35280 +#else
35281 vma->vm_pgoff);
35282 +#endif
35283
35284 #if defined(__i386__)
35285 pgprot = pgprot_val(vma->vm_page_prot);
35286 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
35287 index 2f4c434..dd12cd2 100644
35288 --- a/drivers/gpu/drm/drm_ioc32.c
35289 +++ b/drivers/gpu/drm/drm_ioc32.c
35290 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
35291 request = compat_alloc_user_space(nbytes);
35292 if (!access_ok(VERIFY_WRITE, request, nbytes))
35293 return -EFAULT;
35294 - list = (struct drm_buf_desc *) (request + 1);
35295 + list = (struct drm_buf_desc __user *) (request + 1);
35296
35297 if (__put_user(count, &request->count)
35298 || __put_user(list, &request->list))
35299 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
35300 request = compat_alloc_user_space(nbytes);
35301 if (!access_ok(VERIFY_WRITE, request, nbytes))
35302 return -EFAULT;
35303 - list = (struct drm_buf_pub *) (request + 1);
35304 + list = (struct drm_buf_pub __user *) (request + 1);
35305
35306 if (__put_user(count, &request->count)
35307 || __put_user(list, &request->list))
35308 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
35309 return 0;
35310 }
35311
35312 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
35313 +drm_ioctl_compat_t drm_compat_ioctls[] = {
35314 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
35315 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
35316 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
35317 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
35318 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35319 {
35320 unsigned int nr = DRM_IOCTL_NR(cmd);
35321 - drm_ioctl_compat_t *fn;
35322 int ret;
35323
35324 /* Assume that ioctls without an explicit compat routine will just
35325 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35326 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
35327 return drm_ioctl(filp, cmd, arg);
35328
35329 - fn = drm_compat_ioctls[nr];
35330 -
35331 - if (fn != NULL)
35332 - ret = (*fn) (filp, cmd, arg);
35333 + if (drm_compat_ioctls[nr] != NULL)
35334 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
35335 else
35336 ret = drm_ioctl(filp, cmd, arg);
35337
35338 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
35339 index e77bd8b..1571b85 100644
35340 --- a/drivers/gpu/drm/drm_ioctl.c
35341 +++ b/drivers/gpu/drm/drm_ioctl.c
35342 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
35343 stats->data[i].value =
35344 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
35345 else
35346 - stats->data[i].value = atomic_read(&dev->counts[i]);
35347 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
35348 stats->data[i].type = dev->types[i];
35349 }
35350
35351 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
35352 index d752c96..fe08455 100644
35353 --- a/drivers/gpu/drm/drm_lock.c
35354 +++ b/drivers/gpu/drm/drm_lock.c
35355 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35356 if (drm_lock_take(&master->lock, lock->context)) {
35357 master->lock.file_priv = file_priv;
35358 master->lock.lock_time = jiffies;
35359 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
35360 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
35361 break; /* Got lock */
35362 }
35363
35364 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35365 return -EINVAL;
35366 }
35367
35368 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
35369 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
35370
35371 if (drm_lock_free(&master->lock, lock->context)) {
35372 /* FIXME: Should really bail out here. */
35373 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
35374 index 200e104..59facda 100644
35375 --- a/drivers/gpu/drm/drm_stub.c
35376 +++ b/drivers/gpu/drm/drm_stub.c
35377 @@ -516,7 +516,7 @@ void drm_unplug_dev(struct drm_device *dev)
35378
35379 drm_device_set_unplugged(dev);
35380
35381 - if (dev->open_count == 0) {
35382 + if (local_read(&dev->open_count) == 0) {
35383 drm_put_dev(dev);
35384 }
35385 mutex_unlock(&drm_global_mutex);
35386 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
35387 index 004ecdf..db1f6e0 100644
35388 --- a/drivers/gpu/drm/i810/i810_dma.c
35389 +++ b/drivers/gpu/drm/i810/i810_dma.c
35390 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
35391 dma->buflist[vertex->idx],
35392 vertex->discard, vertex->used);
35393
35394 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35395 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35396 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35397 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35398 sarea_priv->last_enqueue = dev_priv->counter - 1;
35399 sarea_priv->last_dispatch = (int)hw_status[5];
35400
35401 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
35402 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
35403 mc->last_render);
35404
35405 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35406 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35407 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35408 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35409 sarea_priv->last_enqueue = dev_priv->counter - 1;
35410 sarea_priv->last_dispatch = (int)hw_status[5];
35411
35412 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
35413 index 6e0acad..93c8289 100644
35414 --- a/drivers/gpu/drm/i810/i810_drv.h
35415 +++ b/drivers/gpu/drm/i810/i810_drv.h
35416 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
35417 int page_flipping;
35418
35419 wait_queue_head_t irq_queue;
35420 - atomic_t irq_received;
35421 - atomic_t irq_emitted;
35422 + atomic_unchecked_t irq_received;
35423 + atomic_unchecked_t irq_emitted;
35424
35425 int front_offset;
35426 } drm_i810_private_t;
35427 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
35428 index 261efc8e..27af8a5 100644
35429 --- a/drivers/gpu/drm/i915/i915_debugfs.c
35430 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
35431 @@ -496,7 +496,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
35432 I915_READ(GTIMR));
35433 }
35434 seq_printf(m, "Interrupts received: %d\n",
35435 - atomic_read(&dev_priv->irq_received));
35436 + atomic_read_unchecked(&dev_priv->irq_received));
35437 for_each_ring(ring, dev_priv, i) {
35438 if (IS_GEN6(dev) || IS_GEN7(dev)) {
35439 seq_printf(m,
35440 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
35441 index 99daa89..84ebd44 100644
35442 --- a/drivers/gpu/drm/i915/i915_dma.c
35443 +++ b/drivers/gpu/drm/i915/i915_dma.c
35444 @@ -1253,7 +1253,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
35445 bool can_switch;
35446
35447 spin_lock(&dev->count_lock);
35448 - can_switch = (dev->open_count == 0);
35449 + can_switch = (local_read(&dev->open_count) == 0);
35450 spin_unlock(&dev->count_lock);
35451 return can_switch;
35452 }
35453 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
35454 index 7339a4b..445aaba 100644
35455 --- a/drivers/gpu/drm/i915/i915_drv.h
35456 +++ b/drivers/gpu/drm/i915/i915_drv.h
35457 @@ -656,7 +656,7 @@ typedef struct drm_i915_private {
35458 drm_dma_handle_t *status_page_dmah;
35459 struct resource mch_res;
35460
35461 - atomic_t irq_received;
35462 + atomic_unchecked_t irq_received;
35463
35464 /* protects the irq masks */
35465 spinlock_t irq_lock;
35466 @@ -1102,7 +1102,7 @@ struct drm_i915_gem_object {
35467 * will be page flipped away on the next vblank. When it
35468 * reaches 0, dev_priv->pending_flip_queue will be woken up.
35469 */
35470 - atomic_t pending_flip;
35471 + atomic_unchecked_t pending_flip;
35472 };
35473 #define to_gem_object(obj) (&((struct drm_i915_gem_object *)(obj))->base)
35474
35475 @@ -1633,7 +1633,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
35476 struct drm_i915_private *dev_priv, unsigned port);
35477 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
35478 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
35479 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35480 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35481 {
35482 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
35483 }
35484 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35485 index 7adf5a7..e24fb51 100644
35486 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35487 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35488 @@ -672,7 +672,7 @@ i915_gem_execbuffer_move_to_gpu(struct intel_ring_buffer *ring,
35489 i915_gem_clflush_object(obj);
35490
35491 if (obj->base.pending_write_domain)
35492 - flips |= atomic_read(&obj->pending_flip);
35493 + flips |= atomic_read_unchecked(&obj->pending_flip);
35494
35495 flush_domains |= obj->base.write_domain;
35496 }
35497 @@ -703,9 +703,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
35498
35499 static int
35500 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35501 - int count)
35502 + unsigned int count)
35503 {
35504 - int i;
35505 + unsigned int i;
35506 int relocs_total = 0;
35507 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
35508
35509 @@ -1202,7 +1202,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
35510 return -ENOMEM;
35511 }
35512 ret = copy_from_user(exec2_list,
35513 - (struct drm_i915_relocation_entry __user *)
35514 + (struct drm_i915_gem_exec_object2 __user *)
35515 (uintptr_t) args->buffers_ptr,
35516 sizeof(*exec2_list) * args->buffer_count);
35517 if (ret != 0) {
35518 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
35519 index 3c59584..500f2e9 100644
35520 --- a/drivers/gpu/drm/i915/i915_ioc32.c
35521 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
35522 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
35523 (unsigned long)request);
35524 }
35525
35526 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35527 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
35528 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
35529 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
35530 [DRM_I915_GETPARAM] = compat_i915_getparam,
35531 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35532 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35533 {
35534 unsigned int nr = DRM_IOCTL_NR(cmd);
35535 - drm_ioctl_compat_t *fn = NULL;
35536 int ret;
35537
35538 if (nr < DRM_COMMAND_BASE)
35539 return drm_compat_ioctl(filp, cmd, arg);
35540
35541 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
35542 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35543 -
35544 - if (fn != NULL)
35545 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
35546 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35547 ret = (*fn) (filp, cmd, arg);
35548 - else
35549 + } else
35550 ret = drm_ioctl(filp, cmd, arg);
35551
35552 return ret;
35553 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35554 index fe84338..a863190 100644
35555 --- a/drivers/gpu/drm/i915/i915_irq.c
35556 +++ b/drivers/gpu/drm/i915/i915_irq.c
35557 @@ -535,7 +535,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35558 u32 pipe_stats[I915_MAX_PIPES];
35559 bool blc_event;
35560
35561 - atomic_inc(&dev_priv->irq_received);
35562 + atomic_inc_unchecked(&dev_priv->irq_received);
35563
35564 while (true) {
35565 iir = I915_READ(VLV_IIR);
35566 @@ -688,7 +688,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35567 irqreturn_t ret = IRQ_NONE;
35568 int i;
35569
35570 - atomic_inc(&dev_priv->irq_received);
35571 + atomic_inc_unchecked(&dev_priv->irq_received);
35572
35573 /* disable master interrupt before clearing iir */
35574 de_ier = I915_READ(DEIER);
35575 @@ -760,7 +760,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35576 int ret = IRQ_NONE;
35577 u32 de_iir, gt_iir, de_ier, pch_iir, pm_iir;
35578
35579 - atomic_inc(&dev_priv->irq_received);
35580 + atomic_inc_unchecked(&dev_priv->irq_received);
35581
35582 /* disable master interrupt before clearing iir */
35583 de_ier = I915_READ(DEIER);
35584 @@ -1787,7 +1787,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35585 {
35586 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35587
35588 - atomic_set(&dev_priv->irq_received, 0);
35589 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35590
35591 I915_WRITE(HWSTAM, 0xeffe);
35592
35593 @@ -1813,7 +1813,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35594 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35595 int pipe;
35596
35597 - atomic_set(&dev_priv->irq_received, 0);
35598 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35599
35600 /* VLV magic */
35601 I915_WRITE(VLV_IMR, 0);
35602 @@ -2108,7 +2108,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35603 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35604 int pipe;
35605
35606 - atomic_set(&dev_priv->irq_received, 0);
35607 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35608
35609 for_each_pipe(pipe)
35610 I915_WRITE(PIPESTAT(pipe), 0);
35611 @@ -2159,7 +2159,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35612 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35613 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35614
35615 - atomic_inc(&dev_priv->irq_received);
35616 + atomic_inc_unchecked(&dev_priv->irq_received);
35617
35618 iir = I915_READ16(IIR);
35619 if (iir == 0)
35620 @@ -2244,7 +2244,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
35621 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35622 int pipe;
35623
35624 - atomic_set(&dev_priv->irq_received, 0);
35625 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35626
35627 if (I915_HAS_HOTPLUG(dev)) {
35628 I915_WRITE(PORT_HOTPLUG_EN, 0);
35629 @@ -2339,7 +2339,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35630 };
35631 int pipe, ret = IRQ_NONE;
35632
35633 - atomic_inc(&dev_priv->irq_received);
35634 + atomic_inc_unchecked(&dev_priv->irq_received);
35635
35636 iir = I915_READ(IIR);
35637 do {
35638 @@ -2465,7 +2465,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35639 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35640 int pipe;
35641
35642 - atomic_set(&dev_priv->irq_received, 0);
35643 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35644
35645 I915_WRITE(PORT_HOTPLUG_EN, 0);
35646 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35647 @@ -2572,7 +2572,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35648 int irq_received;
35649 int ret = IRQ_NONE, pipe;
35650
35651 - atomic_inc(&dev_priv->irq_received);
35652 + atomic_inc_unchecked(&dev_priv->irq_received);
35653
35654 iir = I915_READ(IIR);
35655
35656 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35657 index e6e4df7..6a9a1bd 100644
35658 --- a/drivers/gpu/drm/i915/intel_display.c
35659 +++ b/drivers/gpu/drm/i915/intel_display.c
35660 @@ -2255,7 +2255,7 @@ intel_finish_fb(struct drm_framebuffer *old_fb)
35661
35662 wait_event(dev_priv->pending_flip_queue,
35663 atomic_read(&dev_priv->mm.wedged) ||
35664 - atomic_read(&obj->pending_flip) == 0);
35665 + atomic_read_unchecked(&obj->pending_flip) == 0);
35666
35667 /* Big Hammer, we also need to ensure that any pending
35668 * MI_WAIT_FOR_EVENT inside a user batch buffer on the
35669 @@ -7122,8 +7122,7 @@ static void do_intel_finish_page_flip(struct drm_device *dev,
35670
35671 obj = work->old_fb_obj;
35672
35673 - atomic_clear_mask(1 << intel_crtc->plane,
35674 - &obj->pending_flip.counter);
35675 + atomic_clear_mask_unchecked(1 << intel_crtc->plane, &obj->pending_flip);
35676 wake_up(&dev_priv->pending_flip_queue);
35677
35678 queue_work(dev_priv->wq, &work->work);
35679 @@ -7486,7 +7485,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
35680 /* Block clients from rendering to the new back buffer until
35681 * the flip occurs and the object is no longer visible.
35682 */
35683 - atomic_add(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35684 + atomic_add_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35685 atomic_inc(&intel_crtc->unpin_work_count);
35686
35687 ret = dev_priv->display.queue_flip(dev, crtc, fb, obj);
35688 @@ -7504,7 +7503,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
35689 cleanup_pending:
35690 atomic_dec(&intel_crtc->unpin_work_count);
35691 crtc->fb = old_fb;
35692 - atomic_sub(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35693 + atomic_sub_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35694 drm_gem_object_unreference(&work->old_fb_obj->base);
35695 drm_gem_object_unreference(&obj->base);
35696 mutex_unlock(&dev->struct_mutex);
35697 @@ -8846,13 +8845,13 @@ struct intel_quirk {
35698 int subsystem_vendor;
35699 int subsystem_device;
35700 void (*hook)(struct drm_device *dev);
35701 -};
35702 +} __do_const;
35703
35704 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35705 struct intel_dmi_quirk {
35706 void (*hook)(struct drm_device *dev);
35707 const struct dmi_system_id (*dmi_id_list)[];
35708 -};
35709 +} __do_const;
35710
35711 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35712 {
35713 @@ -8860,18 +8859,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35714 return 1;
35715 }
35716
35717 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35718 + {
35719 + .callback = intel_dmi_reverse_brightness,
35720 + .ident = "NCR Corporation",
35721 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35722 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35723 + },
35724 + },
35725 + { } /* terminating entry */
35726 +};
35727 +
35728 static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35729 {
35730 - .dmi_id_list = &(const struct dmi_system_id[]) {
35731 - {
35732 - .callback = intel_dmi_reverse_brightness,
35733 - .ident = "NCR Corporation",
35734 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35735 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35736 - },
35737 - },
35738 - { } /* terminating entry */
35739 - },
35740 + .dmi_id_list = &intel_dmi_quirks_table,
35741 .hook = quirk_invert_brightness,
35742 },
35743 };
35744 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35745 index 54558a0..2d97005 100644
35746 --- a/drivers/gpu/drm/mga/mga_drv.h
35747 +++ b/drivers/gpu/drm/mga/mga_drv.h
35748 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35749 u32 clear_cmd;
35750 u32 maccess;
35751
35752 - atomic_t vbl_received; /**< Number of vblanks received. */
35753 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35754 wait_queue_head_t fence_queue;
35755 - atomic_t last_fence_retired;
35756 + atomic_unchecked_t last_fence_retired;
35757 u32 next_fence_to_post;
35758
35759 unsigned int fb_cpp;
35760 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35761 index 709e90d..89a1c0d 100644
35762 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35763 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35764 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35765 return 0;
35766 }
35767
35768 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35769 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35770 [DRM_MGA_INIT] = compat_mga_init,
35771 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35772 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35773 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35774 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35775 {
35776 unsigned int nr = DRM_IOCTL_NR(cmd);
35777 - drm_ioctl_compat_t *fn = NULL;
35778 int ret;
35779
35780 if (nr < DRM_COMMAND_BASE)
35781 return drm_compat_ioctl(filp, cmd, arg);
35782
35783 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35784 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35785 -
35786 - if (fn != NULL)
35787 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35788 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35789 ret = (*fn) (filp, cmd, arg);
35790 - else
35791 + } else
35792 ret = drm_ioctl(filp, cmd, arg);
35793
35794 return ret;
35795 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35796 index 598c281..60d590e 100644
35797 --- a/drivers/gpu/drm/mga/mga_irq.c
35798 +++ b/drivers/gpu/drm/mga/mga_irq.c
35799 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35800 if (crtc != 0)
35801 return 0;
35802
35803 - return atomic_read(&dev_priv->vbl_received);
35804 + return atomic_read_unchecked(&dev_priv->vbl_received);
35805 }
35806
35807
35808 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35809 /* VBLANK interrupt */
35810 if (status & MGA_VLINEPEN) {
35811 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35812 - atomic_inc(&dev_priv->vbl_received);
35813 + atomic_inc_unchecked(&dev_priv->vbl_received);
35814 drm_handle_vblank(dev, 0);
35815 handled = 1;
35816 }
35817 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35818 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35819 MGA_WRITE(MGA_PRIMEND, prim_end);
35820
35821 - atomic_inc(&dev_priv->last_fence_retired);
35822 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35823 DRM_WAKEUP(&dev_priv->fence_queue);
35824 handled = 1;
35825 }
35826 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35827 * using fences.
35828 */
35829 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35830 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35831 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35832 - *sequence) <= (1 << 23)));
35833
35834 *sequence = cur_fence;
35835 diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
35836 index 4f50c40..2e7c949 100644
35837 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c
35838 +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
35839 @@ -751,8 +751,6 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
35840 int i;
35841 unsigned char misc = 0;
35842 unsigned char ext_vga[6];
35843 - unsigned char ext_vga_index24;
35844 - unsigned char dac_index90 = 0;
35845 u8 bppshift;
35846
35847 static unsigned char dacvalue[] = {
35848 @@ -803,7 +801,6 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
35849 option2 = 0x0000b000;
35850 break;
35851 case G200_ER:
35852 - dac_index90 = 0;
35853 break;
35854 }
35855
35856 @@ -852,10 +849,8 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
35857 WREG_DAC(i, dacvalue[i]);
35858 }
35859
35860 - if (mdev->type == G200_ER) {
35861 - WREG_DAC(0x90, dac_index90);
35862 - }
35863 -
35864 + if (mdev->type == G200_ER)
35865 + WREG_DAC(0x90, 0);
35866
35867 if (option)
35868 pci_write_config_dword(dev->pdev, PCI_MGA_OPTION, option);
35869 @@ -952,8 +947,6 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
35870 if (mdev->type == G200_WB)
35871 ext_vga[1] |= 0x88;
35872
35873 - ext_vga_index24 = 0x05;
35874 -
35875 /* Set pixel clocks */
35876 misc = 0x2d;
35877 WREG8(MGA_MISC_OUT, misc);
35878 @@ -965,7 +958,7 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
35879 }
35880
35881 if (mdev->type == G200_ER)
35882 - WREG_ECRT(24, ext_vga_index24);
35883 + WREG_ECRT(0x24, 0x5);
35884
35885 if (mdev->type == G200_EV) {
35886 WREG_ECRT(6, 0);
35887 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35888 index 865eddf..62c4cc3 100644
35889 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35890 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35891 @@ -1015,7 +1015,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35892 struct bit_table {
35893 const char id;
35894 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35895 -};
35896 +} __no_const;
35897
35898 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35899
35900 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35901 index aa89eb9..d45d38b 100644
35902 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35903 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35904 @@ -80,7 +80,7 @@ struct nouveau_drm {
35905 struct drm_global_reference mem_global_ref;
35906 struct ttm_bo_global_ref bo_global_ref;
35907 struct ttm_bo_device bdev;
35908 - atomic_t validate_sequence;
35909 + atomic_unchecked_t validate_sequence;
35910 int (*move)(struct nouveau_channel *,
35911 struct ttm_buffer_object *,
35912 struct ttm_mem_reg *, struct ttm_mem_reg *);
35913 diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.h b/drivers/gpu/drm/nouveau/nouveau_fence.h
35914 index cdb83ac..27f0a16 100644
35915 --- a/drivers/gpu/drm/nouveau/nouveau_fence.h
35916 +++ b/drivers/gpu/drm/nouveau/nouveau_fence.h
35917 @@ -43,7 +43,7 @@ struct nouveau_fence_priv {
35918 int (*sync)(struct nouveau_fence *, struct nouveau_channel *,
35919 struct nouveau_channel *);
35920 u32 (*read)(struct nouveau_channel *);
35921 -};
35922 +} __no_const;
35923
35924 #define nouveau_fence(drm) ((struct nouveau_fence_priv *)(drm)->fence)
35925
35926 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
35927 index 8bf695c..9fbc90a 100644
35928 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
35929 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
35930 @@ -321,7 +321,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
35931 int trycnt = 0;
35932 int ret, i;
35933
35934 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35935 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35936 retry:
35937 if (++trycnt > 100000) {
35938 NV_ERROR(drm, "%s failed and gave up.\n", __func__);
35939 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35940 index 08214bc..9208577 100644
35941 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35942 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35943 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
35944 unsigned long arg)
35945 {
35946 unsigned int nr = DRM_IOCTL_NR(cmd);
35947 - drm_ioctl_compat_t *fn = NULL;
35948 + drm_ioctl_compat_t fn = NULL;
35949 int ret;
35950
35951 if (nr < DRM_COMMAND_BASE)
35952 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
35953 index 25d3495..d81aaf6 100644
35954 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
35955 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
35956 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
35957 bool can_switch;
35958
35959 spin_lock(&dev->count_lock);
35960 - can_switch = (dev->open_count == 0);
35961 + can_switch = (local_read(&dev->open_count) == 0);
35962 spin_unlock(&dev->count_lock);
35963 return can_switch;
35964 }
35965 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
35966 index d4660cf..70dbe65 100644
35967 --- a/drivers/gpu/drm/r128/r128_cce.c
35968 +++ b/drivers/gpu/drm/r128/r128_cce.c
35969 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
35970
35971 /* GH: Simple idle check.
35972 */
35973 - atomic_set(&dev_priv->idle_count, 0);
35974 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35975
35976 /* We don't support anything other than bus-mastering ring mode,
35977 * but the ring can be in either AGP or PCI space for the ring
35978 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
35979 index 930c71b..499aded 100644
35980 --- a/drivers/gpu/drm/r128/r128_drv.h
35981 +++ b/drivers/gpu/drm/r128/r128_drv.h
35982 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
35983 int is_pci;
35984 unsigned long cce_buffers_offset;
35985
35986 - atomic_t idle_count;
35987 + atomic_unchecked_t idle_count;
35988
35989 int page_flipping;
35990 int current_page;
35991 u32 crtc_offset;
35992 u32 crtc_offset_cntl;
35993
35994 - atomic_t vbl_received;
35995 + atomic_unchecked_t vbl_received;
35996
35997 u32 color_fmt;
35998 unsigned int front_offset;
35999 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
36000 index a954c54..9cc595c 100644
36001 --- a/drivers/gpu/drm/r128/r128_ioc32.c
36002 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
36003 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
36004 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
36005 }
36006
36007 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
36008 +drm_ioctl_compat_t r128_compat_ioctls[] = {
36009 [DRM_R128_INIT] = compat_r128_init,
36010 [DRM_R128_DEPTH] = compat_r128_depth,
36011 [DRM_R128_STIPPLE] = compat_r128_stipple,
36012 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
36013 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36014 {
36015 unsigned int nr = DRM_IOCTL_NR(cmd);
36016 - drm_ioctl_compat_t *fn = NULL;
36017 int ret;
36018
36019 if (nr < DRM_COMMAND_BASE)
36020 return drm_compat_ioctl(filp, cmd, arg);
36021
36022 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
36023 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36024 -
36025 - if (fn != NULL)
36026 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
36027 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36028 ret = (*fn) (filp, cmd, arg);
36029 - else
36030 + } else
36031 ret = drm_ioctl(filp, cmd, arg);
36032
36033 return ret;
36034 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
36035 index 2ea4f09..d391371 100644
36036 --- a/drivers/gpu/drm/r128/r128_irq.c
36037 +++ b/drivers/gpu/drm/r128/r128_irq.c
36038 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
36039 if (crtc != 0)
36040 return 0;
36041
36042 - return atomic_read(&dev_priv->vbl_received);
36043 + return atomic_read_unchecked(&dev_priv->vbl_received);
36044 }
36045
36046 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36047 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36048 /* VBLANK interrupt */
36049 if (status & R128_CRTC_VBLANK_INT) {
36050 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
36051 - atomic_inc(&dev_priv->vbl_received);
36052 + atomic_inc_unchecked(&dev_priv->vbl_received);
36053 drm_handle_vblank(dev, 0);
36054 return IRQ_HANDLED;
36055 }
36056 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
36057 index 19bb7e6..de7e2a2 100644
36058 --- a/drivers/gpu/drm/r128/r128_state.c
36059 +++ b/drivers/gpu/drm/r128/r128_state.c
36060 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
36061
36062 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
36063 {
36064 - if (atomic_read(&dev_priv->idle_count) == 0)
36065 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
36066 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
36067 else
36068 - atomic_set(&dev_priv->idle_count, 0);
36069 + atomic_set_unchecked(&dev_priv->idle_count, 0);
36070 }
36071
36072 #endif
36073 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
36074 index 5a82b6b..9e69c73 100644
36075 --- a/drivers/gpu/drm/radeon/mkregtable.c
36076 +++ b/drivers/gpu/drm/radeon/mkregtable.c
36077 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
36078 regex_t mask_rex;
36079 regmatch_t match[4];
36080 char buf[1024];
36081 - size_t end;
36082 + long end;
36083 int len;
36084 int done = 0;
36085 int r;
36086 unsigned o;
36087 struct offset *offset;
36088 char last_reg_s[10];
36089 - int last_reg;
36090 + unsigned long last_reg;
36091
36092 if (regcomp
36093 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
36094 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
36095 index 0d6562b..a154330 100644
36096 --- a/drivers/gpu/drm/radeon/radeon_device.c
36097 +++ b/drivers/gpu/drm/radeon/radeon_device.c
36098 @@ -969,7 +969,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
36099 bool can_switch;
36100
36101 spin_lock(&dev->count_lock);
36102 - can_switch = (dev->open_count == 0);
36103 + can_switch = (local_read(&dev->open_count) == 0);
36104 spin_unlock(&dev->count_lock);
36105 return can_switch;
36106 }
36107 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
36108 index e7fdf16..f4f6490 100644
36109 --- a/drivers/gpu/drm/radeon/radeon_drv.h
36110 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
36111 @@ -255,7 +255,7 @@ typedef struct drm_radeon_private {
36112
36113 /* SW interrupt */
36114 wait_queue_head_t swi_queue;
36115 - atomic_t swi_emitted;
36116 + atomic_unchecked_t swi_emitted;
36117 int vblank_crtc;
36118 uint32_t irq_enable_reg;
36119 uint32_t r500_disp_irq_reg;
36120 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
36121 index c180df8..5fd8186 100644
36122 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
36123 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
36124 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36125 request = compat_alloc_user_space(sizeof(*request));
36126 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
36127 || __put_user(req32.param, &request->param)
36128 - || __put_user((void __user *)(unsigned long)req32.value,
36129 + || __put_user((unsigned long)req32.value,
36130 &request->value))
36131 return -EFAULT;
36132
36133 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36134 #define compat_radeon_cp_setparam NULL
36135 #endif /* X86_64 || IA64 */
36136
36137 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36138 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
36139 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
36140 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
36141 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
36142 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36143 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36144 {
36145 unsigned int nr = DRM_IOCTL_NR(cmd);
36146 - drm_ioctl_compat_t *fn = NULL;
36147 int ret;
36148
36149 if (nr < DRM_COMMAND_BASE)
36150 return drm_compat_ioctl(filp, cmd, arg);
36151
36152 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
36153 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36154 -
36155 - if (fn != NULL)
36156 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
36157 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36158 ret = (*fn) (filp, cmd, arg);
36159 - else
36160 + } else
36161 ret = drm_ioctl(filp, cmd, arg);
36162
36163 return ret;
36164 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
36165 index e771033..a0bc6b3 100644
36166 --- a/drivers/gpu/drm/radeon/radeon_irq.c
36167 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
36168 @@ -224,8 +224,8 @@ static int radeon_emit_irq(struct drm_device * dev)
36169 unsigned int ret;
36170 RING_LOCALS;
36171
36172 - atomic_inc(&dev_priv->swi_emitted);
36173 - ret = atomic_read(&dev_priv->swi_emitted);
36174 + atomic_inc_unchecked(&dev_priv->swi_emitted);
36175 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
36176
36177 BEGIN_RING(4);
36178 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
36179 @@ -351,7 +351,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
36180 drm_radeon_private_t *dev_priv =
36181 (drm_radeon_private_t *) dev->dev_private;
36182
36183 - atomic_set(&dev_priv->swi_emitted, 0);
36184 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
36185 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
36186
36187 dev->max_vblank_count = 0x001fffff;
36188 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
36189 index 8e9057b..af6dacb 100644
36190 --- a/drivers/gpu/drm/radeon/radeon_state.c
36191 +++ b/drivers/gpu/drm/radeon/radeon_state.c
36192 @@ -2166,7 +2166,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
36193 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
36194 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
36195
36196 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36197 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36198 sarea_priv->nbox * sizeof(depth_boxes[0])))
36199 return -EFAULT;
36200
36201 @@ -3029,7 +3029,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
36202 {
36203 drm_radeon_private_t *dev_priv = dev->dev_private;
36204 drm_radeon_getparam_t *param = data;
36205 - int value;
36206 + int value = 0;
36207
36208 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
36209
36210 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
36211 index 93f760e..8088227 100644
36212 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
36213 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
36214 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
36215 man->size = size >> PAGE_SHIFT;
36216 }
36217
36218 -static struct vm_operations_struct radeon_ttm_vm_ops;
36219 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
36220 static const struct vm_operations_struct *ttm_vm_ops = NULL;
36221
36222 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
36223 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
36224 }
36225 if (unlikely(ttm_vm_ops == NULL)) {
36226 ttm_vm_ops = vma->vm_ops;
36227 + pax_open_kernel();
36228 radeon_ttm_vm_ops = *ttm_vm_ops;
36229 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
36230 + pax_close_kernel();
36231 }
36232 vma->vm_ops = &radeon_ttm_vm_ops;
36233 return 0;
36234 @@ -862,28 +864,33 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
36235 sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
36236 else
36237 sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
36238 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36239 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36240 - radeon_mem_types_list[i].driver_features = 0;
36241 + pax_open_kernel();
36242 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36243 + *(void **)&radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36244 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36245 if (i == 0)
36246 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36247 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36248 else
36249 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36250 -
36251 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36252 + pax_close_kernel();
36253 }
36254 /* Add ttm page pool to debugfs */
36255 sprintf(radeon_mem_types_names[i], "ttm_page_pool");
36256 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36257 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36258 - radeon_mem_types_list[i].driver_features = 0;
36259 - radeon_mem_types_list[i++].data = NULL;
36260 + pax_open_kernel();
36261 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36262 + *(void **)&radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36263 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36264 + *(void **)&radeon_mem_types_list[i++].data = NULL;
36265 + pax_close_kernel();
36266 #ifdef CONFIG_SWIOTLB
36267 if (swiotlb_nr_tbl()) {
36268 sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
36269 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36270 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36271 - radeon_mem_types_list[i].driver_features = 0;
36272 - radeon_mem_types_list[i++].data = NULL;
36273 + pax_open_kernel();
36274 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36275 + *(void **)&radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36276 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36277 + *(void **)&radeon_mem_types_list[i++].data = NULL;
36278 + pax_close_kernel();
36279 }
36280 #endif
36281 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
36282 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
36283 index 5706d2a..17aedaa 100644
36284 --- a/drivers/gpu/drm/radeon/rs690.c
36285 +++ b/drivers/gpu/drm/radeon/rs690.c
36286 @@ -304,9 +304,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
36287 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
36288 rdev->pm.sideport_bandwidth.full)
36289 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
36290 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
36291 + read_delay_latency.full = dfixed_const(800 * 1000);
36292 read_delay_latency.full = dfixed_div(read_delay_latency,
36293 rdev->pm.igp_sideport_mclk);
36294 + a.full = dfixed_const(370);
36295 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
36296 } else {
36297 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
36298 rdev->pm.k8_bandwidth.full)
36299 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36300 index bd2a3b4..122d9ad 100644
36301 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
36302 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36303 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
36304 static int ttm_pool_mm_shrink(struct shrinker *shrink,
36305 struct shrink_control *sc)
36306 {
36307 - static atomic_t start_pool = ATOMIC_INIT(0);
36308 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
36309 unsigned i;
36310 - unsigned pool_offset = atomic_add_return(1, &start_pool);
36311 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
36312 struct ttm_page_pool *pool;
36313 int shrink_pages = sc->nr_to_scan;
36314
36315 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
36316 index 1eb060c..188b1fc 100644
36317 --- a/drivers/gpu/drm/udl/udl_fb.c
36318 +++ b/drivers/gpu/drm/udl/udl_fb.c
36319 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
36320 fb_deferred_io_cleanup(info);
36321 kfree(info->fbdefio);
36322 info->fbdefio = NULL;
36323 - info->fbops->fb_mmap = udl_fb_mmap;
36324 }
36325
36326 pr_warn("released /dev/fb%d user=%d count=%d\n",
36327 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
36328 index 893a650..6190d3b 100644
36329 --- a/drivers/gpu/drm/via/via_drv.h
36330 +++ b/drivers/gpu/drm/via/via_drv.h
36331 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
36332 typedef uint32_t maskarray_t[5];
36333
36334 typedef struct drm_via_irq {
36335 - atomic_t irq_received;
36336 + atomic_unchecked_t irq_received;
36337 uint32_t pending_mask;
36338 uint32_t enable_mask;
36339 wait_queue_head_t irq_queue;
36340 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
36341 struct timeval last_vblank;
36342 int last_vblank_valid;
36343 unsigned usec_per_vblank;
36344 - atomic_t vbl_received;
36345 + atomic_unchecked_t vbl_received;
36346 drm_via_state_t hc_state;
36347 char pci_buf[VIA_PCI_BUF_SIZE];
36348 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
36349 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
36350 index ac98964..5dbf512 100644
36351 --- a/drivers/gpu/drm/via/via_irq.c
36352 +++ b/drivers/gpu/drm/via/via_irq.c
36353 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
36354 if (crtc != 0)
36355 return 0;
36356
36357 - return atomic_read(&dev_priv->vbl_received);
36358 + return atomic_read_unchecked(&dev_priv->vbl_received);
36359 }
36360
36361 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36362 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36363
36364 status = VIA_READ(VIA_REG_INTERRUPT);
36365 if (status & VIA_IRQ_VBLANK_PENDING) {
36366 - atomic_inc(&dev_priv->vbl_received);
36367 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
36368 + atomic_inc_unchecked(&dev_priv->vbl_received);
36369 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
36370 do_gettimeofday(&cur_vblank);
36371 if (dev_priv->last_vblank_valid) {
36372 dev_priv->usec_per_vblank =
36373 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36374 dev_priv->last_vblank = cur_vblank;
36375 dev_priv->last_vblank_valid = 1;
36376 }
36377 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
36378 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
36379 DRM_DEBUG("US per vblank is: %u\n",
36380 dev_priv->usec_per_vblank);
36381 }
36382 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36383
36384 for (i = 0; i < dev_priv->num_irqs; ++i) {
36385 if (status & cur_irq->pending_mask) {
36386 - atomic_inc(&cur_irq->irq_received);
36387 + atomic_inc_unchecked(&cur_irq->irq_received);
36388 DRM_WAKEUP(&cur_irq->irq_queue);
36389 handled = 1;
36390 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
36391 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
36392 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36393 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
36394 masks[irq][4]));
36395 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
36396 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
36397 } else {
36398 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36399 (((cur_irq_sequence =
36400 - atomic_read(&cur_irq->irq_received)) -
36401 + atomic_read_unchecked(&cur_irq->irq_received)) -
36402 *sequence) <= (1 << 23)));
36403 }
36404 *sequence = cur_irq_sequence;
36405 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
36406 }
36407
36408 for (i = 0; i < dev_priv->num_irqs; ++i) {
36409 - atomic_set(&cur_irq->irq_received, 0);
36410 + atomic_set_unchecked(&cur_irq->irq_received, 0);
36411 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
36412 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
36413 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
36414 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
36415 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
36416 case VIA_IRQ_RELATIVE:
36417 irqwait->request.sequence +=
36418 - atomic_read(&cur_irq->irq_received);
36419 + atomic_read_unchecked(&cur_irq->irq_received);
36420 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
36421 case VIA_IRQ_ABSOLUTE:
36422 break;
36423 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36424 index 13aeda7..4a952d1 100644
36425 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36426 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36427 @@ -290,7 +290,7 @@ struct vmw_private {
36428 * Fencing and IRQs.
36429 */
36430
36431 - atomic_t marker_seq;
36432 + atomic_unchecked_t marker_seq;
36433 wait_queue_head_t fence_queue;
36434 wait_queue_head_t fifo_queue;
36435 int fence_queue_waiters; /* Protected by hw_mutex */
36436 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36437 index 3eb1486..0a47ee9 100644
36438 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36439 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36440 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
36441 (unsigned int) min,
36442 (unsigned int) fifo->capabilities);
36443
36444 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36445 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36446 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
36447 vmw_marker_queue_init(&fifo->marker_queue);
36448 return vmw_fifo_send_fence(dev_priv, &dummy);
36449 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
36450 if (reserveable)
36451 iowrite32(bytes, fifo_mem +
36452 SVGA_FIFO_RESERVED);
36453 - return fifo_mem + (next_cmd >> 2);
36454 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
36455 } else {
36456 need_bounce = true;
36457 }
36458 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36459
36460 fm = vmw_fifo_reserve(dev_priv, bytes);
36461 if (unlikely(fm == NULL)) {
36462 - *seqno = atomic_read(&dev_priv->marker_seq);
36463 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36464 ret = -ENOMEM;
36465 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
36466 false, 3*HZ);
36467 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36468 }
36469
36470 do {
36471 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
36472 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
36473 } while (*seqno == 0);
36474
36475 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
36476 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36477 index 4640adb..e1384ed 100644
36478 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36479 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36480 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
36481 * emitted. Then the fence is stale and signaled.
36482 */
36483
36484 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
36485 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
36486 > VMW_FENCE_WRAP);
36487
36488 return ret;
36489 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
36490
36491 if (fifo_idle)
36492 down_read(&fifo_state->rwsem);
36493 - signal_seq = atomic_read(&dev_priv->marker_seq);
36494 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
36495 ret = 0;
36496
36497 for (;;) {
36498 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36499 index 8a8725c..afed796 100644
36500 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36501 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36502 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
36503 while (!vmw_lag_lt(queue, us)) {
36504 spin_lock(&queue->lock);
36505 if (list_empty(&queue->head))
36506 - seqno = atomic_read(&dev_priv->marker_seq);
36507 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36508 else {
36509 marker = list_first_entry(&queue->head,
36510 struct vmw_marker, head);
36511 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
36512 index ceb3040..6160c5c 100644
36513 --- a/drivers/hid/hid-core.c
36514 +++ b/drivers/hid/hid-core.c
36515 @@ -2242,7 +2242,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
36516
36517 int hid_add_device(struct hid_device *hdev)
36518 {
36519 - static atomic_t id = ATOMIC_INIT(0);
36520 + static atomic_unchecked_t id = ATOMIC_INIT(0);
36521 int ret;
36522
36523 if (WARN_ON(hdev->status & HID_STAT_ADDED))
36524 @@ -2276,7 +2276,7 @@ int hid_add_device(struct hid_device *hdev)
36525 /* XXX hack, any other cleaner solution after the driver core
36526 * is converted to allow more than 20 bytes as the device name? */
36527 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
36528 - hdev->vendor, hdev->product, atomic_inc_return(&id));
36529 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
36530
36531 hid_debug_register(hdev, dev_name(&hdev->dev));
36532 ret = device_add(&hdev->dev);
36533 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
36534 index eec3291..8ed706b 100644
36535 --- a/drivers/hid/hid-wiimote-debug.c
36536 +++ b/drivers/hid/hid-wiimote-debug.c
36537 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
36538 else if (size == 0)
36539 return -EIO;
36540
36541 - if (copy_to_user(u, buf, size))
36542 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
36543 return -EFAULT;
36544
36545 *off += size;
36546 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
36547 index 773a2f2..7ce08bc 100644
36548 --- a/drivers/hv/channel.c
36549 +++ b/drivers/hv/channel.c
36550 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
36551 int ret = 0;
36552 int t;
36553
36554 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
36555 - atomic_inc(&vmbus_connection.next_gpadl_handle);
36556 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
36557 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
36558
36559 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
36560 if (ret)
36561 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
36562 index 3648f8f..30ef30d 100644
36563 --- a/drivers/hv/hv.c
36564 +++ b/drivers/hv/hv.c
36565 @@ -111,7 +111,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
36566 u64 output_address = (output) ? virt_to_phys(output) : 0;
36567 u32 output_address_hi = output_address >> 32;
36568 u32 output_address_lo = output_address & 0xFFFFFFFF;
36569 - void *hypercall_page = hv_context.hypercall_page;
36570 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
36571
36572 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
36573 "=a"(hv_status_lo) : "d" (control_hi),
36574 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
36575 index d8d1fad..b91caf7 100644
36576 --- a/drivers/hv/hyperv_vmbus.h
36577 +++ b/drivers/hv/hyperv_vmbus.h
36578 @@ -594,7 +594,7 @@ enum vmbus_connect_state {
36579 struct vmbus_connection {
36580 enum vmbus_connect_state conn_state;
36581
36582 - atomic_t next_gpadl_handle;
36583 + atomic_unchecked_t next_gpadl_handle;
36584
36585 /*
36586 * Represents channel interrupts. Each bit position represents a
36587 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
36588 index 8e1a9ec..4687821 100644
36589 --- a/drivers/hv/vmbus_drv.c
36590 +++ b/drivers/hv/vmbus_drv.c
36591 @@ -629,10 +629,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
36592 {
36593 int ret = 0;
36594
36595 - static atomic_t device_num = ATOMIC_INIT(0);
36596 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
36597
36598 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
36599 - atomic_inc_return(&device_num));
36600 + atomic_inc_return_unchecked(&device_num));
36601
36602 child_device_obj->device.bus = &hv_bus;
36603 child_device_obj->device.parent = &hv_acpi_dev->dev;
36604 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
36605 index 1672e2a..4a6297c 100644
36606 --- a/drivers/hwmon/acpi_power_meter.c
36607 +++ b/drivers/hwmon/acpi_power_meter.c
36608 @@ -117,7 +117,7 @@ struct sensor_template {
36609 struct device_attribute *devattr,
36610 const char *buf, size_t count);
36611 int index;
36612 -};
36613 +} __do_const;
36614
36615 /* Averaging interval */
36616 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36617 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36618 struct sensor_template *attrs)
36619 {
36620 struct device *dev = &resource->acpi_dev->dev;
36621 - struct sensor_device_attribute *sensors =
36622 + sensor_device_attribute_no_const *sensors =
36623 &resource->sensors[resource->num_sensors];
36624 int res = 0;
36625
36626 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36627 index b41baff..4953e4d 100644
36628 --- a/drivers/hwmon/applesmc.c
36629 +++ b/drivers/hwmon/applesmc.c
36630 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36631 {
36632 struct applesmc_node_group *grp;
36633 struct applesmc_dev_attr *node;
36634 - struct attribute *attr;
36635 + attribute_no_const *attr;
36636 int ret, i;
36637
36638 for (grp = groups; grp->format; grp++) {
36639 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36640 index 56dbcfb..9874bf1 100644
36641 --- a/drivers/hwmon/asus_atk0110.c
36642 +++ b/drivers/hwmon/asus_atk0110.c
36643 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36644 struct atk_sensor_data {
36645 struct list_head list;
36646 struct atk_data *data;
36647 - struct device_attribute label_attr;
36648 - struct device_attribute input_attr;
36649 - struct device_attribute limit1_attr;
36650 - struct device_attribute limit2_attr;
36651 + device_attribute_no_const label_attr;
36652 + device_attribute_no_const input_attr;
36653 + device_attribute_no_const limit1_attr;
36654 + device_attribute_no_const limit2_attr;
36655 char label_attr_name[ATTR_NAME_SIZE];
36656 char input_attr_name[ATTR_NAME_SIZE];
36657 char limit1_attr_name[ATTR_NAME_SIZE];
36658 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36659 static struct device_attribute atk_name_attr =
36660 __ATTR(name, 0444, atk_name_show, NULL);
36661
36662 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36663 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36664 sysfs_show_func show)
36665 {
36666 sysfs_attr_init(&attr->attr);
36667 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36668 index d64923d..72591e8 100644
36669 --- a/drivers/hwmon/coretemp.c
36670 +++ b/drivers/hwmon/coretemp.c
36671 @@ -790,7 +790,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36672 return NOTIFY_OK;
36673 }
36674
36675 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36676 +static struct notifier_block coretemp_cpu_notifier = {
36677 .notifier_call = coretemp_cpu_callback,
36678 };
36679
36680 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36681 index a14f634..2916ee2 100644
36682 --- a/drivers/hwmon/ibmaem.c
36683 +++ b/drivers/hwmon/ibmaem.c
36684 @@ -925,7 +925,7 @@ static int aem_register_sensors(struct aem_data *data,
36685 struct aem_rw_sensor_template *rw)
36686 {
36687 struct device *dev = &data->pdev->dev;
36688 - struct sensor_device_attribute *sensors = data->sensors;
36689 + sensor_device_attribute_no_const *sensors = data->sensors;
36690 int err;
36691
36692 /* Set up read-only sensors */
36693 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
36694 index 7d19b1b..8fdaaac 100644
36695 --- a/drivers/hwmon/pmbus/pmbus_core.c
36696 +++ b/drivers/hwmon/pmbus/pmbus_core.c
36697 @@ -811,7 +811,7 @@ static ssize_t pmbus_show_label(struct device *dev,
36698
36699 #define PMBUS_ADD_ATTR(data, _name, _idx, _mode, _type, _show, _set) \
36700 do { \
36701 - struct sensor_device_attribute *a \
36702 + sensor_device_attribute_no_const *a \
36703 = &data->_type##s[data->num_##_type##s].attribute; \
36704 BUG_ON(data->num_attributes >= data->max_attributes); \
36705 sysfs_attr_init(&a->dev_attr.attr); \
36706 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36707 index 8047fed..1e956f0 100644
36708 --- a/drivers/hwmon/sht15.c
36709 +++ b/drivers/hwmon/sht15.c
36710 @@ -169,7 +169,7 @@ struct sht15_data {
36711 int supply_uV;
36712 bool supply_uV_valid;
36713 struct work_struct update_supply_work;
36714 - atomic_t interrupt_handled;
36715 + atomic_unchecked_t interrupt_handled;
36716 };
36717
36718 /**
36719 @@ -512,13 +512,13 @@ static int sht15_measurement(struct sht15_data *data,
36720 return ret;
36721
36722 gpio_direction_input(data->pdata->gpio_data);
36723 - atomic_set(&data->interrupt_handled, 0);
36724 + atomic_set_unchecked(&data->interrupt_handled, 0);
36725
36726 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36727 if (gpio_get_value(data->pdata->gpio_data) == 0) {
36728 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
36729 /* Only relevant if the interrupt hasn't occurred. */
36730 - if (!atomic_read(&data->interrupt_handled))
36731 + if (!atomic_read_unchecked(&data->interrupt_handled))
36732 schedule_work(&data->read_work);
36733 }
36734 ret = wait_event_timeout(data->wait_queue,
36735 @@ -785,7 +785,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
36736
36737 /* First disable the interrupt */
36738 disable_irq_nosync(irq);
36739 - atomic_inc(&data->interrupt_handled);
36740 + atomic_inc_unchecked(&data->interrupt_handled);
36741 /* Then schedule a reading work struct */
36742 if (data->state != SHT15_READING_NOTHING)
36743 schedule_work(&data->read_work);
36744 @@ -807,11 +807,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
36745 * If not, then start the interrupt again - care here as could
36746 * have gone low in meantime so verify it hasn't!
36747 */
36748 - atomic_set(&data->interrupt_handled, 0);
36749 + atomic_set_unchecked(&data->interrupt_handled, 0);
36750 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36751 /* If still not occurred or another handler was scheduled */
36752 if (gpio_get_value(data->pdata->gpio_data)
36753 - || atomic_read(&data->interrupt_handled))
36754 + || atomic_read_unchecked(&data->interrupt_handled))
36755 return;
36756 }
36757
36758 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
36759 index 76f157b..9c0db1b 100644
36760 --- a/drivers/hwmon/via-cputemp.c
36761 +++ b/drivers/hwmon/via-cputemp.c
36762 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
36763 return NOTIFY_OK;
36764 }
36765
36766 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
36767 +static struct notifier_block via_cputemp_cpu_notifier = {
36768 .notifier_call = via_cputemp_cpu_callback,
36769 };
36770
36771 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
36772 index 378fcb5..5e91fa8 100644
36773 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
36774 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
36775 @@ -43,7 +43,7 @@
36776 extern struct i2c_adapter amd756_smbus;
36777
36778 static struct i2c_adapter *s4882_adapter;
36779 -static struct i2c_algorithm *s4882_algo;
36780 +static i2c_algorithm_no_const *s4882_algo;
36781
36782 /* Wrapper access functions for multiplexed SMBus */
36783 static DEFINE_MUTEX(amd756_lock);
36784 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
36785 index 29015eb..af2d8e9 100644
36786 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
36787 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
36788 @@ -41,7 +41,7 @@
36789 extern struct i2c_adapter *nforce2_smbus;
36790
36791 static struct i2c_adapter *s4985_adapter;
36792 -static struct i2c_algorithm *s4985_algo;
36793 +static i2c_algorithm_no_const *s4985_algo;
36794
36795 /* Wrapper access functions for multiplexed SMBus */
36796 static DEFINE_MUTEX(nforce2_lock);
36797 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
36798 index 8126824..55a2798 100644
36799 --- a/drivers/ide/ide-cd.c
36800 +++ b/drivers/ide/ide-cd.c
36801 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
36802 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
36803 if ((unsigned long)buf & alignment
36804 || blk_rq_bytes(rq) & q->dma_pad_mask
36805 - || object_is_on_stack(buf))
36806 + || object_starts_on_stack(buf))
36807 drive->dma = 0;
36808 }
36809 }
36810 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
36811 index 8848f16..f8e6dd8 100644
36812 --- a/drivers/iio/industrialio-core.c
36813 +++ b/drivers/iio/industrialio-core.c
36814 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
36815 }
36816
36817 static
36818 -int __iio_device_attr_init(struct device_attribute *dev_attr,
36819 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
36820 const char *postfix,
36821 struct iio_chan_spec const *chan,
36822 ssize_t (*readfunc)(struct device *dev,
36823 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
36824 index 394fea2..c833880 100644
36825 --- a/drivers/infiniband/core/cm.c
36826 +++ b/drivers/infiniband/core/cm.c
36827 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
36828
36829 struct cm_counter_group {
36830 struct kobject obj;
36831 - atomic_long_t counter[CM_ATTR_COUNT];
36832 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
36833 };
36834
36835 struct cm_counter_attribute {
36836 @@ -1394,7 +1394,7 @@ static void cm_dup_req_handler(struct cm_work *work,
36837 struct ib_mad_send_buf *msg = NULL;
36838 int ret;
36839
36840 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36841 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36842 counter[CM_REQ_COUNTER]);
36843
36844 /* Quick state check to discard duplicate REQs. */
36845 @@ -1778,7 +1778,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
36846 if (!cm_id_priv)
36847 return;
36848
36849 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36850 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36851 counter[CM_REP_COUNTER]);
36852 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
36853 if (ret)
36854 @@ -1945,7 +1945,7 @@ static int cm_rtu_handler(struct cm_work *work)
36855 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
36856 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
36857 spin_unlock_irq(&cm_id_priv->lock);
36858 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36859 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36860 counter[CM_RTU_COUNTER]);
36861 goto out;
36862 }
36863 @@ -2128,7 +2128,7 @@ static int cm_dreq_handler(struct cm_work *work)
36864 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
36865 dreq_msg->local_comm_id);
36866 if (!cm_id_priv) {
36867 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36868 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36869 counter[CM_DREQ_COUNTER]);
36870 cm_issue_drep(work->port, work->mad_recv_wc);
36871 return -EINVAL;
36872 @@ -2153,7 +2153,7 @@ static int cm_dreq_handler(struct cm_work *work)
36873 case IB_CM_MRA_REP_RCVD:
36874 break;
36875 case IB_CM_TIMEWAIT:
36876 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36877 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36878 counter[CM_DREQ_COUNTER]);
36879 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36880 goto unlock;
36881 @@ -2167,7 +2167,7 @@ static int cm_dreq_handler(struct cm_work *work)
36882 cm_free_msg(msg);
36883 goto deref;
36884 case IB_CM_DREQ_RCVD:
36885 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36886 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36887 counter[CM_DREQ_COUNTER]);
36888 goto unlock;
36889 default:
36890 @@ -2534,7 +2534,7 @@ static int cm_mra_handler(struct cm_work *work)
36891 ib_modify_mad(cm_id_priv->av.port->mad_agent,
36892 cm_id_priv->msg, timeout)) {
36893 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
36894 - atomic_long_inc(&work->port->
36895 + atomic_long_inc_unchecked(&work->port->
36896 counter_group[CM_RECV_DUPLICATES].
36897 counter[CM_MRA_COUNTER]);
36898 goto out;
36899 @@ -2543,7 +2543,7 @@ static int cm_mra_handler(struct cm_work *work)
36900 break;
36901 case IB_CM_MRA_REQ_RCVD:
36902 case IB_CM_MRA_REP_RCVD:
36903 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36904 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36905 counter[CM_MRA_COUNTER]);
36906 /* fall through */
36907 default:
36908 @@ -2705,7 +2705,7 @@ static int cm_lap_handler(struct cm_work *work)
36909 case IB_CM_LAP_IDLE:
36910 break;
36911 case IB_CM_MRA_LAP_SENT:
36912 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36913 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36914 counter[CM_LAP_COUNTER]);
36915 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36916 goto unlock;
36917 @@ -2721,7 +2721,7 @@ static int cm_lap_handler(struct cm_work *work)
36918 cm_free_msg(msg);
36919 goto deref;
36920 case IB_CM_LAP_RCVD:
36921 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36922 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36923 counter[CM_LAP_COUNTER]);
36924 goto unlock;
36925 default:
36926 @@ -3005,7 +3005,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
36927 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
36928 if (cur_cm_id_priv) {
36929 spin_unlock_irq(&cm.lock);
36930 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36931 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36932 counter[CM_SIDR_REQ_COUNTER]);
36933 goto out; /* Duplicate message. */
36934 }
36935 @@ -3217,10 +3217,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
36936 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
36937 msg->retries = 1;
36938
36939 - atomic_long_add(1 + msg->retries,
36940 + atomic_long_add_unchecked(1 + msg->retries,
36941 &port->counter_group[CM_XMIT].counter[attr_index]);
36942 if (msg->retries)
36943 - atomic_long_add(msg->retries,
36944 + atomic_long_add_unchecked(msg->retries,
36945 &port->counter_group[CM_XMIT_RETRIES].
36946 counter[attr_index]);
36947
36948 @@ -3430,7 +3430,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
36949 }
36950
36951 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
36952 - atomic_long_inc(&port->counter_group[CM_RECV].
36953 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
36954 counter[attr_id - CM_ATTR_ID_OFFSET]);
36955
36956 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
36957 @@ -3635,7 +3635,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
36958 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
36959
36960 return sprintf(buf, "%ld\n",
36961 - atomic_long_read(&group->counter[cm_attr->index]));
36962 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
36963 }
36964
36965 static const struct sysfs_ops cm_counter_ops = {
36966 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
36967 index 176c8f9..2627b62 100644
36968 --- a/drivers/infiniband/core/fmr_pool.c
36969 +++ b/drivers/infiniband/core/fmr_pool.c
36970 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
36971
36972 struct task_struct *thread;
36973
36974 - atomic_t req_ser;
36975 - atomic_t flush_ser;
36976 + atomic_unchecked_t req_ser;
36977 + atomic_unchecked_t flush_ser;
36978
36979 wait_queue_head_t force_wait;
36980 };
36981 @@ -180,10 +180,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36982 struct ib_fmr_pool *pool = pool_ptr;
36983
36984 do {
36985 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
36986 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
36987 ib_fmr_batch_release(pool);
36988
36989 - atomic_inc(&pool->flush_ser);
36990 + atomic_inc_unchecked(&pool->flush_ser);
36991 wake_up_interruptible(&pool->force_wait);
36992
36993 if (pool->flush_function)
36994 @@ -191,7 +191,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36995 }
36996
36997 set_current_state(TASK_INTERRUPTIBLE);
36998 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
36999 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
37000 !kthread_should_stop())
37001 schedule();
37002 __set_current_state(TASK_RUNNING);
37003 @@ -283,8 +283,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
37004 pool->dirty_watermark = params->dirty_watermark;
37005 pool->dirty_len = 0;
37006 spin_lock_init(&pool->pool_lock);
37007 - atomic_set(&pool->req_ser, 0);
37008 - atomic_set(&pool->flush_ser, 0);
37009 + atomic_set_unchecked(&pool->req_ser, 0);
37010 + atomic_set_unchecked(&pool->flush_ser, 0);
37011 init_waitqueue_head(&pool->force_wait);
37012
37013 pool->thread = kthread_run(ib_fmr_cleanup_thread,
37014 @@ -412,11 +412,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
37015 }
37016 spin_unlock_irq(&pool->pool_lock);
37017
37018 - serial = atomic_inc_return(&pool->req_ser);
37019 + serial = atomic_inc_return_unchecked(&pool->req_ser);
37020 wake_up_process(pool->thread);
37021
37022 if (wait_event_interruptible(pool->force_wait,
37023 - atomic_read(&pool->flush_ser) - serial >= 0))
37024 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
37025 return -EINTR;
37026
37027 return 0;
37028 @@ -526,7 +526,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
37029 } else {
37030 list_add_tail(&fmr->list, &pool->dirty_list);
37031 if (++pool->dirty_len >= pool->dirty_watermark) {
37032 - atomic_inc(&pool->req_ser);
37033 + atomic_inc_unchecked(&pool->req_ser);
37034 wake_up_process(pool->thread);
37035 }
37036 }
37037 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
37038 index afd8179..598063f 100644
37039 --- a/drivers/infiniband/hw/cxgb4/mem.c
37040 +++ b/drivers/infiniband/hw/cxgb4/mem.c
37041 @@ -122,7 +122,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37042 int err;
37043 struct fw_ri_tpte tpt;
37044 u32 stag_idx;
37045 - static atomic_t key;
37046 + static atomic_unchecked_t key;
37047
37048 if (c4iw_fatal_error(rdev))
37049 return -EIO;
37050 @@ -139,7 +139,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37051 if (rdev->stats.stag.cur > rdev->stats.stag.max)
37052 rdev->stats.stag.max = rdev->stats.stag.cur;
37053 mutex_unlock(&rdev->stats.lock);
37054 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
37055 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
37056 }
37057 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
37058 __func__, stag_state, type, pdid, stag_idx);
37059 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
37060 index 79b3dbc..96e5fcc 100644
37061 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
37062 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
37063 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37064 struct ib_atomic_eth *ateth;
37065 struct ipath_ack_entry *e;
37066 u64 vaddr;
37067 - atomic64_t *maddr;
37068 + atomic64_unchecked_t *maddr;
37069 u64 sdata;
37070 u32 rkey;
37071 u8 next;
37072 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37073 IB_ACCESS_REMOTE_ATOMIC)))
37074 goto nack_acc_unlck;
37075 /* Perform atomic OP and save result. */
37076 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37077 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37078 sdata = be64_to_cpu(ateth->swap_data);
37079 e = &qp->s_ack_queue[qp->r_head_ack_queue];
37080 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
37081 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37082 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37083 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37084 be64_to_cpu(ateth->compare_data),
37085 sdata);
37086 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
37087 index 1f95bba..9530f87 100644
37088 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
37089 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
37090 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
37091 unsigned long flags;
37092 struct ib_wc wc;
37093 u64 sdata;
37094 - atomic64_t *maddr;
37095 + atomic64_unchecked_t *maddr;
37096 enum ib_wc_status send_status;
37097
37098 /*
37099 @@ -382,11 +382,11 @@ again:
37100 IB_ACCESS_REMOTE_ATOMIC)))
37101 goto acc_err;
37102 /* Perform atomic OP and save result. */
37103 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37104 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37105 sdata = wqe->wr.wr.atomic.compare_add;
37106 *(u64 *) sqp->s_sge.sge.vaddr =
37107 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
37108 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37109 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37110 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37111 sdata, wqe->wr.wr.atomic.swap);
37112 goto send_comp;
37113 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
37114 index 9d3e5c1..d9afe4a 100644
37115 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
37116 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
37117 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
37118 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
37119 }
37120
37121 -int mthca_QUERY_FW(struct mthca_dev *dev)
37122 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
37123 {
37124 struct mthca_mailbox *mailbox;
37125 u32 *outbox;
37126 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
37127 index ed9a989..e0c5871 100644
37128 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
37129 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
37130 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
37131 return key;
37132 }
37133
37134 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37135 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37136 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
37137 {
37138 struct mthca_mailbox *mailbox;
37139 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
37140 index 5b152a3..c1f3e83 100644
37141 --- a/drivers/infiniband/hw/nes/nes.c
37142 +++ b/drivers/infiniband/hw/nes/nes.c
37143 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
37144 LIST_HEAD(nes_adapter_list);
37145 static LIST_HEAD(nes_dev_list);
37146
37147 -atomic_t qps_destroyed;
37148 +atomic_unchecked_t qps_destroyed;
37149
37150 static unsigned int ee_flsh_adapter;
37151 static unsigned int sysfs_nonidx_addr;
37152 @@ -267,7 +267,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
37153 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
37154 struct nes_adapter *nesadapter = nesdev->nesadapter;
37155
37156 - atomic_inc(&qps_destroyed);
37157 + atomic_inc_unchecked(&qps_destroyed);
37158
37159 /* Free the control structures */
37160
37161 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
37162 index 33cc589..3bd6538 100644
37163 --- a/drivers/infiniband/hw/nes/nes.h
37164 +++ b/drivers/infiniband/hw/nes/nes.h
37165 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
37166 extern unsigned int wqm_quanta;
37167 extern struct list_head nes_adapter_list;
37168
37169 -extern atomic_t cm_connects;
37170 -extern atomic_t cm_accepts;
37171 -extern atomic_t cm_disconnects;
37172 -extern atomic_t cm_closes;
37173 -extern atomic_t cm_connecteds;
37174 -extern atomic_t cm_connect_reqs;
37175 -extern atomic_t cm_rejects;
37176 -extern atomic_t mod_qp_timouts;
37177 -extern atomic_t qps_created;
37178 -extern atomic_t qps_destroyed;
37179 -extern atomic_t sw_qps_destroyed;
37180 +extern atomic_unchecked_t cm_connects;
37181 +extern atomic_unchecked_t cm_accepts;
37182 +extern atomic_unchecked_t cm_disconnects;
37183 +extern atomic_unchecked_t cm_closes;
37184 +extern atomic_unchecked_t cm_connecteds;
37185 +extern atomic_unchecked_t cm_connect_reqs;
37186 +extern atomic_unchecked_t cm_rejects;
37187 +extern atomic_unchecked_t mod_qp_timouts;
37188 +extern atomic_unchecked_t qps_created;
37189 +extern atomic_unchecked_t qps_destroyed;
37190 +extern atomic_unchecked_t sw_qps_destroyed;
37191 extern u32 mh_detected;
37192 extern u32 mh_pauses_sent;
37193 extern u32 cm_packets_sent;
37194 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
37195 extern u32 cm_packets_received;
37196 extern u32 cm_packets_dropped;
37197 extern u32 cm_packets_retrans;
37198 -extern atomic_t cm_listens_created;
37199 -extern atomic_t cm_listens_destroyed;
37200 +extern atomic_unchecked_t cm_listens_created;
37201 +extern atomic_unchecked_t cm_listens_destroyed;
37202 extern u32 cm_backlog_drops;
37203 -extern atomic_t cm_loopbacks;
37204 -extern atomic_t cm_nodes_created;
37205 -extern atomic_t cm_nodes_destroyed;
37206 -extern atomic_t cm_accel_dropped_pkts;
37207 -extern atomic_t cm_resets_recvd;
37208 -extern atomic_t pau_qps_created;
37209 -extern atomic_t pau_qps_destroyed;
37210 +extern atomic_unchecked_t cm_loopbacks;
37211 +extern atomic_unchecked_t cm_nodes_created;
37212 +extern atomic_unchecked_t cm_nodes_destroyed;
37213 +extern atomic_unchecked_t cm_accel_dropped_pkts;
37214 +extern atomic_unchecked_t cm_resets_recvd;
37215 +extern atomic_unchecked_t pau_qps_created;
37216 +extern atomic_unchecked_t pau_qps_destroyed;
37217
37218 extern u32 int_mod_timer_init;
37219 extern u32 int_mod_cq_depth_256;
37220 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
37221 index 22ea67e..dcbe3bc 100644
37222 --- a/drivers/infiniband/hw/nes/nes_cm.c
37223 +++ b/drivers/infiniband/hw/nes/nes_cm.c
37224 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
37225 u32 cm_packets_retrans;
37226 u32 cm_packets_created;
37227 u32 cm_packets_received;
37228 -atomic_t cm_listens_created;
37229 -atomic_t cm_listens_destroyed;
37230 +atomic_unchecked_t cm_listens_created;
37231 +atomic_unchecked_t cm_listens_destroyed;
37232 u32 cm_backlog_drops;
37233 -atomic_t cm_loopbacks;
37234 -atomic_t cm_nodes_created;
37235 -atomic_t cm_nodes_destroyed;
37236 -atomic_t cm_accel_dropped_pkts;
37237 -atomic_t cm_resets_recvd;
37238 +atomic_unchecked_t cm_loopbacks;
37239 +atomic_unchecked_t cm_nodes_created;
37240 +atomic_unchecked_t cm_nodes_destroyed;
37241 +atomic_unchecked_t cm_accel_dropped_pkts;
37242 +atomic_unchecked_t cm_resets_recvd;
37243
37244 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
37245 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
37246 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
37247
37248 static struct nes_cm_core *g_cm_core;
37249
37250 -atomic_t cm_connects;
37251 -atomic_t cm_accepts;
37252 -atomic_t cm_disconnects;
37253 -atomic_t cm_closes;
37254 -atomic_t cm_connecteds;
37255 -atomic_t cm_connect_reqs;
37256 -atomic_t cm_rejects;
37257 +atomic_unchecked_t cm_connects;
37258 +atomic_unchecked_t cm_accepts;
37259 +atomic_unchecked_t cm_disconnects;
37260 +atomic_unchecked_t cm_closes;
37261 +atomic_unchecked_t cm_connecteds;
37262 +atomic_unchecked_t cm_connect_reqs;
37263 +atomic_unchecked_t cm_rejects;
37264
37265 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
37266 {
37267 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
37268 kfree(listener);
37269 listener = NULL;
37270 ret = 0;
37271 - atomic_inc(&cm_listens_destroyed);
37272 + atomic_inc_unchecked(&cm_listens_destroyed);
37273 } else {
37274 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
37275 }
37276 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
37277 cm_node->rem_mac);
37278
37279 add_hte_node(cm_core, cm_node);
37280 - atomic_inc(&cm_nodes_created);
37281 + atomic_inc_unchecked(&cm_nodes_created);
37282
37283 return cm_node;
37284 }
37285 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
37286 }
37287
37288 atomic_dec(&cm_core->node_cnt);
37289 - atomic_inc(&cm_nodes_destroyed);
37290 + atomic_inc_unchecked(&cm_nodes_destroyed);
37291 nesqp = cm_node->nesqp;
37292 if (nesqp) {
37293 nesqp->cm_node = NULL;
37294 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
37295
37296 static void drop_packet(struct sk_buff *skb)
37297 {
37298 - atomic_inc(&cm_accel_dropped_pkts);
37299 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37300 dev_kfree_skb_any(skb);
37301 }
37302
37303 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
37304 {
37305
37306 int reset = 0; /* whether to send reset in case of err.. */
37307 - atomic_inc(&cm_resets_recvd);
37308 + atomic_inc_unchecked(&cm_resets_recvd);
37309 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
37310 " refcnt=%d\n", cm_node, cm_node->state,
37311 atomic_read(&cm_node->ref_count));
37312 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
37313 rem_ref_cm_node(cm_node->cm_core, cm_node);
37314 return NULL;
37315 }
37316 - atomic_inc(&cm_loopbacks);
37317 + atomic_inc_unchecked(&cm_loopbacks);
37318 loopbackremotenode->loopbackpartner = cm_node;
37319 loopbackremotenode->tcp_cntxt.rcv_wscale =
37320 NES_CM_DEFAULT_RCV_WND_SCALE;
37321 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
37322 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
37323 else {
37324 rem_ref_cm_node(cm_core, cm_node);
37325 - atomic_inc(&cm_accel_dropped_pkts);
37326 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37327 dev_kfree_skb_any(skb);
37328 }
37329 break;
37330 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37331
37332 if ((cm_id) && (cm_id->event_handler)) {
37333 if (issue_disconn) {
37334 - atomic_inc(&cm_disconnects);
37335 + atomic_inc_unchecked(&cm_disconnects);
37336 cm_event.event = IW_CM_EVENT_DISCONNECT;
37337 cm_event.status = disconn_status;
37338 cm_event.local_addr = cm_id->local_addr;
37339 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37340 }
37341
37342 if (issue_close) {
37343 - atomic_inc(&cm_closes);
37344 + atomic_inc_unchecked(&cm_closes);
37345 nes_disconnect(nesqp, 1);
37346
37347 cm_id->provider_data = nesqp;
37348 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37349
37350 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
37351 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
37352 - atomic_inc(&cm_accepts);
37353 + atomic_inc_unchecked(&cm_accepts);
37354
37355 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
37356 netdev_refcnt_read(nesvnic->netdev));
37357 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
37358 struct nes_cm_core *cm_core;
37359 u8 *start_buff;
37360
37361 - atomic_inc(&cm_rejects);
37362 + atomic_inc_unchecked(&cm_rejects);
37363 cm_node = (struct nes_cm_node *)cm_id->provider_data;
37364 loopback = cm_node->loopbackpartner;
37365 cm_core = cm_node->cm_core;
37366 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37367 ntohl(cm_id->local_addr.sin_addr.s_addr),
37368 ntohs(cm_id->local_addr.sin_port));
37369
37370 - atomic_inc(&cm_connects);
37371 + atomic_inc_unchecked(&cm_connects);
37372 nesqp->active_conn = 1;
37373
37374 /* cache the cm_id in the qp */
37375 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
37376 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
37377 return err;
37378 }
37379 - atomic_inc(&cm_listens_created);
37380 + atomic_inc_unchecked(&cm_listens_created);
37381 }
37382
37383 cm_id->add_ref(cm_id);
37384 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
37385
37386 if (nesqp->destroyed)
37387 return;
37388 - atomic_inc(&cm_connecteds);
37389 + atomic_inc_unchecked(&cm_connecteds);
37390 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
37391 " local port 0x%04X. jiffies = %lu.\n",
37392 nesqp->hwqp.qp_id,
37393 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
37394
37395 cm_id->add_ref(cm_id);
37396 ret = cm_id->event_handler(cm_id, &cm_event);
37397 - atomic_inc(&cm_closes);
37398 + atomic_inc_unchecked(&cm_closes);
37399 cm_event.event = IW_CM_EVENT_CLOSE;
37400 cm_event.status = 0;
37401 cm_event.provider_data = cm_id->provider_data;
37402 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
37403 return;
37404 cm_id = cm_node->cm_id;
37405
37406 - atomic_inc(&cm_connect_reqs);
37407 + atomic_inc_unchecked(&cm_connect_reqs);
37408 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37409 cm_node, cm_id, jiffies);
37410
37411 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
37412 return;
37413 cm_id = cm_node->cm_id;
37414
37415 - atomic_inc(&cm_connect_reqs);
37416 + atomic_inc_unchecked(&cm_connect_reqs);
37417 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37418 cm_node, cm_id, jiffies);
37419
37420 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
37421 index 4166452..fc952c3 100644
37422 --- a/drivers/infiniband/hw/nes/nes_mgt.c
37423 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
37424 @@ -40,8 +40,8 @@
37425 #include "nes.h"
37426 #include "nes_mgt.h"
37427
37428 -atomic_t pau_qps_created;
37429 -atomic_t pau_qps_destroyed;
37430 +atomic_unchecked_t pau_qps_created;
37431 +atomic_unchecked_t pau_qps_destroyed;
37432
37433 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
37434 {
37435 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
37436 {
37437 struct sk_buff *skb;
37438 unsigned long flags;
37439 - atomic_inc(&pau_qps_destroyed);
37440 + atomic_inc_unchecked(&pau_qps_destroyed);
37441
37442 /* Free packets that have not yet been forwarded */
37443 /* Lock is acquired by skb_dequeue when removing the skb */
37444 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
37445 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
37446 skb_queue_head_init(&nesqp->pau_list);
37447 spin_lock_init(&nesqp->pau_lock);
37448 - atomic_inc(&pau_qps_created);
37449 + atomic_inc_unchecked(&pau_qps_created);
37450 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
37451 }
37452
37453 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
37454 index 9542e16..a008c40 100644
37455 --- a/drivers/infiniband/hw/nes/nes_nic.c
37456 +++ b/drivers/infiniband/hw/nes/nes_nic.c
37457 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
37458 target_stat_values[++index] = mh_detected;
37459 target_stat_values[++index] = mh_pauses_sent;
37460 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
37461 - target_stat_values[++index] = atomic_read(&cm_connects);
37462 - target_stat_values[++index] = atomic_read(&cm_accepts);
37463 - target_stat_values[++index] = atomic_read(&cm_disconnects);
37464 - target_stat_values[++index] = atomic_read(&cm_connecteds);
37465 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
37466 - target_stat_values[++index] = atomic_read(&cm_rejects);
37467 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
37468 - target_stat_values[++index] = atomic_read(&qps_created);
37469 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
37470 - target_stat_values[++index] = atomic_read(&qps_destroyed);
37471 - target_stat_values[++index] = atomic_read(&cm_closes);
37472 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
37473 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
37474 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
37475 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
37476 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
37477 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
37478 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
37479 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
37480 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
37481 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
37482 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
37483 target_stat_values[++index] = cm_packets_sent;
37484 target_stat_values[++index] = cm_packets_bounced;
37485 target_stat_values[++index] = cm_packets_created;
37486 target_stat_values[++index] = cm_packets_received;
37487 target_stat_values[++index] = cm_packets_dropped;
37488 target_stat_values[++index] = cm_packets_retrans;
37489 - target_stat_values[++index] = atomic_read(&cm_listens_created);
37490 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
37491 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
37492 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
37493 target_stat_values[++index] = cm_backlog_drops;
37494 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
37495 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
37496 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
37497 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
37498 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
37499 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
37500 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
37501 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
37502 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
37503 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
37504 target_stat_values[++index] = nesadapter->free_4kpbl;
37505 target_stat_values[++index] = nesadapter->free_256pbl;
37506 target_stat_values[++index] = int_mod_timer_init;
37507 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
37508 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
37509 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
37510 - target_stat_values[++index] = atomic_read(&pau_qps_created);
37511 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
37512 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
37513 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
37514 }
37515
37516 /**
37517 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
37518 index 07e4fba..685f041 100644
37519 --- a/drivers/infiniband/hw/nes/nes_verbs.c
37520 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
37521 @@ -46,9 +46,9 @@
37522
37523 #include <rdma/ib_umem.h>
37524
37525 -atomic_t mod_qp_timouts;
37526 -atomic_t qps_created;
37527 -atomic_t sw_qps_destroyed;
37528 +atomic_unchecked_t mod_qp_timouts;
37529 +atomic_unchecked_t qps_created;
37530 +atomic_unchecked_t sw_qps_destroyed;
37531
37532 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
37533
37534 @@ -1131,7 +1131,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
37535 if (init_attr->create_flags)
37536 return ERR_PTR(-EINVAL);
37537
37538 - atomic_inc(&qps_created);
37539 + atomic_inc_unchecked(&qps_created);
37540 switch (init_attr->qp_type) {
37541 case IB_QPT_RC:
37542 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
37543 @@ -1462,7 +1462,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
37544 struct iw_cm_event cm_event;
37545 int ret = 0;
37546
37547 - atomic_inc(&sw_qps_destroyed);
37548 + atomic_inc_unchecked(&sw_qps_destroyed);
37549 nesqp->destroyed = 1;
37550
37551 /* Blow away the connection if it exists. */
37552 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
37553 index 4d11575..3e890e5 100644
37554 --- a/drivers/infiniband/hw/qib/qib.h
37555 +++ b/drivers/infiniband/hw/qib/qib.h
37556 @@ -51,6 +51,7 @@
37557 #include <linux/completion.h>
37558 #include <linux/kref.h>
37559 #include <linux/sched.h>
37560 +#include <linux/slab.h>
37561
37562 #include "qib_common.h"
37563 #include "qib_verbs.h"
37564 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
37565 index da739d9..da1c7f4 100644
37566 --- a/drivers/input/gameport/gameport.c
37567 +++ b/drivers/input/gameport/gameport.c
37568 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
37569 */
37570 static void gameport_init_port(struct gameport *gameport)
37571 {
37572 - static atomic_t gameport_no = ATOMIC_INIT(0);
37573 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
37574
37575 __module_get(THIS_MODULE);
37576
37577 mutex_init(&gameport->drv_mutex);
37578 device_initialize(&gameport->dev);
37579 dev_set_name(&gameport->dev, "gameport%lu",
37580 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
37581 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
37582 gameport->dev.bus = &gameport_bus;
37583 gameport->dev.release = gameport_release_port;
37584 if (gameport->parent)
37585 diff --git a/drivers/input/input.c b/drivers/input/input.c
37586 index c044699..174d71a 100644
37587 --- a/drivers/input/input.c
37588 +++ b/drivers/input/input.c
37589 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
37590 */
37591 int input_register_device(struct input_dev *dev)
37592 {
37593 - static atomic_t input_no = ATOMIC_INIT(0);
37594 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
37595 struct input_devres *devres = NULL;
37596 struct input_handler *handler;
37597 unsigned int packet_size;
37598 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
37599 dev->setkeycode = input_default_setkeycode;
37600
37601 dev_set_name(&dev->dev, "input%ld",
37602 - (unsigned long) atomic_inc_return(&input_no) - 1);
37603 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
37604
37605 error = device_add(&dev->dev);
37606 if (error)
37607 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37608 index 04c69af..5f92d00 100644
37609 --- a/drivers/input/joystick/sidewinder.c
37610 +++ b/drivers/input/joystick/sidewinder.c
37611 @@ -30,6 +30,7 @@
37612 #include <linux/kernel.h>
37613 #include <linux/module.h>
37614 #include <linux/slab.h>
37615 +#include <linux/sched.h>
37616 #include <linux/init.h>
37617 #include <linux/input.h>
37618 #include <linux/gameport.h>
37619 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37620 index d6cbfe9..6225402 100644
37621 --- a/drivers/input/joystick/xpad.c
37622 +++ b/drivers/input/joystick/xpad.c
37623 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37624
37625 static int xpad_led_probe(struct usb_xpad *xpad)
37626 {
37627 - static atomic_t led_seq = ATOMIC_INIT(0);
37628 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37629 long led_no;
37630 struct xpad_led *led;
37631 struct led_classdev *led_cdev;
37632 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37633 if (!led)
37634 return -ENOMEM;
37635
37636 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37637 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37638
37639 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37640 led->xpad = xpad;
37641 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37642 index fe1df23..5b710f3 100644
37643 --- a/drivers/input/mouse/psmouse.h
37644 +++ b/drivers/input/mouse/psmouse.h
37645 @@ -115,7 +115,7 @@ struct psmouse_attribute {
37646 ssize_t (*set)(struct psmouse *psmouse, void *data,
37647 const char *buf, size_t count);
37648 bool protect;
37649 -};
37650 +} __do_const;
37651 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37652
37653 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37654 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37655 index 4c842c3..590b0bf 100644
37656 --- a/drivers/input/mousedev.c
37657 +++ b/drivers/input/mousedev.c
37658 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37659
37660 spin_unlock_irq(&client->packet_lock);
37661
37662 - if (copy_to_user(buffer, data, count))
37663 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37664 return -EFAULT;
37665
37666 return count;
37667 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37668 index 25fc597..558bf3b 100644
37669 --- a/drivers/input/serio/serio.c
37670 +++ b/drivers/input/serio/serio.c
37671 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37672 */
37673 static void serio_init_port(struct serio *serio)
37674 {
37675 - static atomic_t serio_no = ATOMIC_INIT(0);
37676 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37677
37678 __module_get(THIS_MODULE);
37679
37680 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37681 mutex_init(&serio->drv_mutex);
37682 device_initialize(&serio->dev);
37683 dev_set_name(&serio->dev, "serio%ld",
37684 - (long)atomic_inc_return(&serio_no) - 1);
37685 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37686 serio->dev.bus = &serio_bus;
37687 serio->dev.release = serio_release_port;
37688 serio->dev.groups = serio_device_attr_groups;
37689 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37690 index ddbdaca..be18a78 100644
37691 --- a/drivers/iommu/iommu.c
37692 +++ b/drivers/iommu/iommu.c
37693 @@ -554,7 +554,7 @@ static struct notifier_block iommu_bus_nb = {
37694 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37695 {
37696 bus_register_notifier(bus, &iommu_bus_nb);
37697 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37698 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37699 }
37700
37701 /**
37702 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
37703 index 89562a8..218999b 100644
37704 --- a/drivers/isdn/capi/capi.c
37705 +++ b/drivers/isdn/capi/capi.c
37706 @@ -81,8 +81,8 @@ struct capiminor {
37707
37708 struct capi20_appl *ap;
37709 u32 ncci;
37710 - atomic_t datahandle;
37711 - atomic_t msgid;
37712 + atomic_unchecked_t datahandle;
37713 + atomic_unchecked_t msgid;
37714
37715 struct tty_port port;
37716 int ttyinstop;
37717 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
37718 capimsg_setu16(s, 2, mp->ap->applid);
37719 capimsg_setu8 (s, 4, CAPI_DATA_B3);
37720 capimsg_setu8 (s, 5, CAPI_RESP);
37721 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
37722 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
37723 capimsg_setu32(s, 8, mp->ncci);
37724 capimsg_setu16(s, 12, datahandle);
37725 }
37726 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
37727 mp->outbytes -= len;
37728 spin_unlock_bh(&mp->outlock);
37729
37730 - datahandle = atomic_inc_return(&mp->datahandle);
37731 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
37732 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
37733 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37734 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37735 capimsg_setu16(skb->data, 2, mp->ap->applid);
37736 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
37737 capimsg_setu8 (skb->data, 5, CAPI_REQ);
37738 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
37739 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
37740 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
37741 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
37742 capimsg_setu16(skb->data, 16, len); /* Data length */
37743 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
37744 index 67abf3f..076b3a6 100644
37745 --- a/drivers/isdn/gigaset/interface.c
37746 +++ b/drivers/isdn/gigaset/interface.c
37747 @@ -160,9 +160,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
37748 }
37749 tty->driver_data = cs;
37750
37751 - ++cs->port.count;
37752 + atomic_inc(&cs->port.count);
37753
37754 - if (cs->port.count == 1) {
37755 + if (atomic_read(&cs->port.count) == 1) {
37756 tty_port_tty_set(&cs->port, tty);
37757 tty->low_latency = 1;
37758 }
37759 @@ -186,9 +186,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
37760
37761 if (!cs->connected)
37762 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
37763 - else if (!cs->port.count)
37764 + else if (!atomic_read(&cs->port.count))
37765 dev_warn(cs->dev, "%s: device not opened\n", __func__);
37766 - else if (!--cs->port.count)
37767 + else if (!atomic_dec_return(&cs->port.count))
37768 tty_port_tty_set(&cs->port, NULL);
37769
37770 mutex_unlock(&cs->mutex);
37771 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
37772 index 821f7ac..28d4030 100644
37773 --- a/drivers/isdn/hardware/avm/b1.c
37774 +++ b/drivers/isdn/hardware/avm/b1.c
37775 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
37776 }
37777 if (left) {
37778 if (t4file->user) {
37779 - if (copy_from_user(buf, dp, left))
37780 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37781 return -EFAULT;
37782 } else {
37783 memcpy(buf, dp, left);
37784 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
37785 }
37786 if (left) {
37787 if (config->user) {
37788 - if (copy_from_user(buf, dp, left))
37789 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37790 return -EFAULT;
37791 } else {
37792 memcpy(buf, dp, left);
37793 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
37794 index e09dc8a..15e2efb 100644
37795 --- a/drivers/isdn/i4l/isdn_tty.c
37796 +++ b/drivers/isdn/i4l/isdn_tty.c
37797 @@ -1513,9 +1513,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
37798
37799 #ifdef ISDN_DEBUG_MODEM_OPEN
37800 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
37801 - port->count);
37802 + atomic_read(&port->count));
37803 #endif
37804 - port->count++;
37805 + atomic_inc(&port->count);
37806 port->tty = tty;
37807 /*
37808 * Start up serial port
37809 @@ -1559,7 +1559,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37810 #endif
37811 return;
37812 }
37813 - if ((tty->count == 1) && (port->count != 1)) {
37814 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
37815 /*
37816 * Uh, oh. tty->count is 1, which means that the tty
37817 * structure will be freed. Info->count should always
37818 @@ -1568,15 +1568,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37819 * serial port won't be shutdown.
37820 */
37821 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
37822 - "info->count is %d\n", port->count);
37823 - port->count = 1;
37824 + "info->count is %d\n", atomic_read(&port->count));
37825 + atomic_set(&port->count, 1);
37826 }
37827 - if (--port->count < 0) {
37828 + if (atomic_dec_return(&port->count) < 0) {
37829 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
37830 - info->line, port->count);
37831 - port->count = 0;
37832 + info->line, atomic_read(&port->count));
37833 + atomic_set(&port->count, 0);
37834 }
37835 - if (port->count) {
37836 + if (atomic_read(&port->count)) {
37837 #ifdef ISDN_DEBUG_MODEM_OPEN
37838 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
37839 #endif
37840 @@ -1630,7 +1630,7 @@ isdn_tty_hangup(struct tty_struct *tty)
37841 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
37842 return;
37843 isdn_tty_shutdown(info);
37844 - port->count = 0;
37845 + atomic_set(&port->count, 0);
37846 port->flags &= ~ASYNC_NORMAL_ACTIVE;
37847 port->tty = NULL;
37848 wake_up_interruptible(&port->open_wait);
37849 @@ -1975,7 +1975,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
37850 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
37851 modem_info *info = &dev->mdm.info[i];
37852
37853 - if (info->port.count == 0)
37854 + if (atomic_read(&info->port.count) == 0)
37855 continue;
37856 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
37857 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
37858 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
37859 index e74df7c..03a03ba 100644
37860 --- a/drivers/isdn/icn/icn.c
37861 +++ b/drivers/isdn/icn/icn.c
37862 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
37863 if (count > len)
37864 count = len;
37865 if (user) {
37866 - if (copy_from_user(msg, buf, count))
37867 + if (count > sizeof msg || copy_from_user(msg, buf, count))
37868 return -EFAULT;
37869 } else
37870 memcpy(msg, buf, count);
37871 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
37872 index 6a8405d..0bd1c7e 100644
37873 --- a/drivers/leds/leds-clevo-mail.c
37874 +++ b/drivers/leds/leds-clevo-mail.c
37875 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
37876 * detected as working, but in reality it is not) as low as
37877 * possible.
37878 */
37879 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
37880 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
37881 {
37882 .callback = clevo_mail_led_dmi_callback,
37883 .ident = "Clevo D410J",
37884 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
37885 index ec9b287..65c9bf4 100644
37886 --- a/drivers/leds/leds-ss4200.c
37887 +++ b/drivers/leds/leds-ss4200.c
37888 @@ -92,7 +92,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
37889 * detected as working, but in reality it is not) as low as
37890 * possible.
37891 */
37892 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
37893 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
37894 {
37895 .callback = ss4200_led_dmi_callback,
37896 .ident = "Intel SS4200-E",
37897 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
37898 index a5ebc00..982886f 100644
37899 --- a/drivers/lguest/core.c
37900 +++ b/drivers/lguest/core.c
37901 @@ -92,9 +92,17 @@ static __init int map_switcher(void)
37902 * it's worked so far. The end address needs +1 because __get_vm_area
37903 * allocates an extra guard page, so we need space for that.
37904 */
37905 +
37906 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
37907 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37908 + VM_ALLOC | VM_KERNEXEC, SWITCHER_ADDR, SWITCHER_ADDR
37909 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37910 +#else
37911 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37912 VM_ALLOC, SWITCHER_ADDR, SWITCHER_ADDR
37913 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37914 +#endif
37915 +
37916 if (!switcher_vma) {
37917 err = -ENOMEM;
37918 printk("lguest: could not map switcher pages high\n");
37919 @@ -119,7 +127,7 @@ static __init int map_switcher(void)
37920 * Now the Switcher is mapped at the right address, we can't fail!
37921 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
37922 */
37923 - memcpy(switcher_vma->addr, start_switcher_text,
37924 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
37925 end_switcher_text - start_switcher_text);
37926
37927 printk(KERN_INFO "lguest: mapped switcher at %p\n",
37928 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
37929 index 3b62be16..e33134a 100644
37930 --- a/drivers/lguest/page_tables.c
37931 +++ b/drivers/lguest/page_tables.c
37932 @@ -532,7 +532,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
37933 /*:*/
37934
37935 #ifdef CONFIG_X86_PAE
37936 -static void release_pmd(pmd_t *spmd)
37937 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
37938 {
37939 /* If the entry's not present, there's nothing to release. */
37940 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
37941 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
37942 index 4af12e1..0e89afe 100644
37943 --- a/drivers/lguest/x86/core.c
37944 +++ b/drivers/lguest/x86/core.c
37945 @@ -59,7 +59,7 @@ static struct {
37946 /* Offset from where switcher.S was compiled to where we've copied it */
37947 static unsigned long switcher_offset(void)
37948 {
37949 - return SWITCHER_ADDR - (unsigned long)start_switcher_text;
37950 + return SWITCHER_ADDR - (unsigned long)ktla_ktva(start_switcher_text);
37951 }
37952
37953 /* This cpu's struct lguest_pages. */
37954 @@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
37955 * These copies are pretty cheap, so we do them unconditionally: */
37956 /* Save the current Host top-level page directory.
37957 */
37958 +
37959 +#ifdef CONFIG_PAX_PER_CPU_PGD
37960 + pages->state.host_cr3 = read_cr3();
37961 +#else
37962 pages->state.host_cr3 = __pa(current->mm->pgd);
37963 +#endif
37964 +
37965 /*
37966 * Set up the Guest's page tables to see this CPU's pages (and no
37967 * other CPU's pages).
37968 @@ -476,7 +482,7 @@ void __init lguest_arch_host_init(void)
37969 * compiled-in switcher code and the high-mapped copy we just made.
37970 */
37971 for (i = 0; i < IDT_ENTRIES; i++)
37972 - default_idt_entries[i] += switcher_offset();
37973 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
37974
37975 /*
37976 * Set up the Switcher's per-cpu areas.
37977 @@ -559,7 +565,7 @@ void __init lguest_arch_host_init(void)
37978 * it will be undisturbed when we switch. To change %cs and jump we
37979 * need this structure to feed to Intel's "lcall" instruction.
37980 */
37981 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
37982 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
37983 lguest_entry.segment = LGUEST_CS;
37984
37985 /*
37986 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
37987 index 40634b0..4f5855e 100644
37988 --- a/drivers/lguest/x86/switcher_32.S
37989 +++ b/drivers/lguest/x86/switcher_32.S
37990 @@ -87,6 +87,7 @@
37991 #include <asm/page.h>
37992 #include <asm/segment.h>
37993 #include <asm/lguest.h>
37994 +#include <asm/processor-flags.h>
37995
37996 // We mark the start of the code to copy
37997 // It's placed in .text tho it's never run here
37998 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
37999 // Changes type when we load it: damn Intel!
38000 // For after we switch over our page tables
38001 // That entry will be read-only: we'd crash.
38002 +
38003 +#ifdef CONFIG_PAX_KERNEXEC
38004 + mov %cr0, %edx
38005 + xor $X86_CR0_WP, %edx
38006 + mov %edx, %cr0
38007 +#endif
38008 +
38009 movl $(GDT_ENTRY_TSS*8), %edx
38010 ltr %dx
38011
38012 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
38013 // Let's clear it again for our return.
38014 // The GDT descriptor of the Host
38015 // Points to the table after two "size" bytes
38016 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
38017 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
38018 // Clear "used" from type field (byte 5, bit 2)
38019 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
38020 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
38021 +
38022 +#ifdef CONFIG_PAX_KERNEXEC
38023 + mov %cr0, %eax
38024 + xor $X86_CR0_WP, %eax
38025 + mov %eax, %cr0
38026 +#endif
38027
38028 // Once our page table's switched, the Guest is live!
38029 // The Host fades as we run this final step.
38030 @@ -295,13 +309,12 @@ deliver_to_host:
38031 // I consulted gcc, and it gave
38032 // These instructions, which I gladly credit:
38033 leal (%edx,%ebx,8), %eax
38034 - movzwl (%eax),%edx
38035 - movl 4(%eax), %eax
38036 - xorw %ax, %ax
38037 - orl %eax, %edx
38038 + movl 4(%eax), %edx
38039 + movw (%eax), %dx
38040 // Now the address of the handler's in %edx
38041 // We call it now: its "iret" drops us home.
38042 - jmp *%edx
38043 + ljmp $__KERNEL_CS, $1f
38044 +1: jmp *%edx
38045
38046 // Every interrupt can come to us here
38047 // But we must truly tell each apart.
38048 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
38049 index 7155945..4bcc562 100644
38050 --- a/drivers/md/bitmap.c
38051 +++ b/drivers/md/bitmap.c
38052 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
38053 chunk_kb ? "KB" : "B");
38054 if (bitmap->storage.file) {
38055 seq_printf(seq, ", file: ");
38056 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
38057 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
38058 }
38059
38060 seq_printf(seq, "\n");
38061 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
38062 index eee353d..74504c4 100644
38063 --- a/drivers/md/dm-ioctl.c
38064 +++ b/drivers/md/dm-ioctl.c
38065 @@ -1632,7 +1632,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
38066 cmd == DM_LIST_VERSIONS_CMD)
38067 return 0;
38068
38069 - if ((cmd == DM_DEV_CREATE_CMD)) {
38070 + if (cmd == DM_DEV_CREATE_CMD) {
38071 if (!*param->name) {
38072 DMWARN("name not supplied when creating device");
38073 return -EINVAL;
38074 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
38075 index 7f24190..0e18099 100644
38076 --- a/drivers/md/dm-raid1.c
38077 +++ b/drivers/md/dm-raid1.c
38078 @@ -40,7 +40,7 @@ enum dm_raid1_error {
38079
38080 struct mirror {
38081 struct mirror_set *ms;
38082 - atomic_t error_count;
38083 + atomic_unchecked_t error_count;
38084 unsigned long error_type;
38085 struct dm_dev *dev;
38086 sector_t offset;
38087 @@ -183,7 +183,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
38088 struct mirror *m;
38089
38090 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
38091 - if (!atomic_read(&m->error_count))
38092 + if (!atomic_read_unchecked(&m->error_count))
38093 return m;
38094
38095 return NULL;
38096 @@ -215,7 +215,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
38097 * simple way to tell if a device has encountered
38098 * errors.
38099 */
38100 - atomic_inc(&m->error_count);
38101 + atomic_inc_unchecked(&m->error_count);
38102
38103 if (test_and_set_bit(error_type, &m->error_type))
38104 return;
38105 @@ -406,7 +406,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
38106 struct mirror *m = get_default_mirror(ms);
38107
38108 do {
38109 - if (likely(!atomic_read(&m->error_count)))
38110 + if (likely(!atomic_read_unchecked(&m->error_count)))
38111 return m;
38112
38113 if (m-- == ms->mirror)
38114 @@ -420,7 +420,7 @@ static int default_ok(struct mirror *m)
38115 {
38116 struct mirror *default_mirror = get_default_mirror(m->ms);
38117
38118 - return !atomic_read(&default_mirror->error_count);
38119 + return !atomic_read_unchecked(&default_mirror->error_count);
38120 }
38121
38122 static int mirror_available(struct mirror_set *ms, struct bio *bio)
38123 @@ -557,7 +557,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
38124 */
38125 if (likely(region_in_sync(ms, region, 1)))
38126 m = choose_mirror(ms, bio->bi_sector);
38127 - else if (m && atomic_read(&m->error_count))
38128 + else if (m && atomic_read_unchecked(&m->error_count))
38129 m = NULL;
38130
38131 if (likely(m))
38132 @@ -924,7 +924,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
38133 }
38134
38135 ms->mirror[mirror].ms = ms;
38136 - atomic_set(&(ms->mirror[mirror].error_count), 0);
38137 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
38138 ms->mirror[mirror].error_type = 0;
38139 ms->mirror[mirror].offset = offset;
38140
38141 @@ -1337,7 +1337,7 @@ static void mirror_resume(struct dm_target *ti)
38142 */
38143 static char device_status_char(struct mirror *m)
38144 {
38145 - if (!atomic_read(&(m->error_count)))
38146 + if (!atomic_read_unchecked(&(m->error_count)))
38147 return 'A';
38148
38149 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
38150 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
38151 index aaecefa..23b3026 100644
38152 --- a/drivers/md/dm-stripe.c
38153 +++ b/drivers/md/dm-stripe.c
38154 @@ -20,7 +20,7 @@ struct stripe {
38155 struct dm_dev *dev;
38156 sector_t physical_start;
38157
38158 - atomic_t error_count;
38159 + atomic_unchecked_t error_count;
38160 };
38161
38162 struct stripe_c {
38163 @@ -184,7 +184,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
38164 kfree(sc);
38165 return r;
38166 }
38167 - atomic_set(&(sc->stripe[i].error_count), 0);
38168 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
38169 }
38170
38171 ti->private = sc;
38172 @@ -325,7 +325,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
38173 DMEMIT("%d ", sc->stripes);
38174 for (i = 0; i < sc->stripes; i++) {
38175 DMEMIT("%s ", sc->stripe[i].dev->name);
38176 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
38177 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
38178 'D' : 'A';
38179 }
38180 buffer[i] = '\0';
38181 @@ -370,8 +370,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
38182 */
38183 for (i = 0; i < sc->stripes; i++)
38184 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
38185 - atomic_inc(&(sc->stripe[i].error_count));
38186 - if (atomic_read(&(sc->stripe[i].error_count)) <
38187 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
38188 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
38189 DM_IO_ERROR_THRESHOLD)
38190 schedule_work(&sc->trigger_event);
38191 }
38192 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
38193 index daf25d0..d74f49f 100644
38194 --- a/drivers/md/dm-table.c
38195 +++ b/drivers/md/dm-table.c
38196 @@ -390,7 +390,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
38197 if (!dev_size)
38198 return 0;
38199
38200 - if ((start >= dev_size) || (start + len > dev_size)) {
38201 + if ((start >= dev_size) || (len > dev_size - start)) {
38202 DMWARN("%s: %s too small for target: "
38203 "start=%llu, len=%llu, dev_size=%llu",
38204 dm_device_name(ti->table->md), bdevname(bdev, b),
38205 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
38206 index 4d6e853..a234157 100644
38207 --- a/drivers/md/dm-thin-metadata.c
38208 +++ b/drivers/md/dm-thin-metadata.c
38209 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38210 {
38211 pmd->info.tm = pmd->tm;
38212 pmd->info.levels = 2;
38213 - pmd->info.value_type.context = pmd->data_sm;
38214 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38215 pmd->info.value_type.size = sizeof(__le64);
38216 pmd->info.value_type.inc = data_block_inc;
38217 pmd->info.value_type.dec = data_block_dec;
38218 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38219
38220 pmd->bl_info.tm = pmd->tm;
38221 pmd->bl_info.levels = 1;
38222 - pmd->bl_info.value_type.context = pmd->data_sm;
38223 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38224 pmd->bl_info.value_type.size = sizeof(__le64);
38225 pmd->bl_info.value_type.inc = data_block_inc;
38226 pmd->bl_info.value_type.dec = data_block_dec;
38227 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
38228 index 0d8f086..f5a91d5 100644
38229 --- a/drivers/md/dm.c
38230 +++ b/drivers/md/dm.c
38231 @@ -170,9 +170,9 @@ struct mapped_device {
38232 /*
38233 * Event handling.
38234 */
38235 - atomic_t event_nr;
38236 + atomic_unchecked_t event_nr;
38237 wait_queue_head_t eventq;
38238 - atomic_t uevent_seq;
38239 + atomic_unchecked_t uevent_seq;
38240 struct list_head uevent_list;
38241 spinlock_t uevent_lock; /* Protect access to uevent_list */
38242
38243 @@ -1872,8 +1872,8 @@ static struct mapped_device *alloc_dev(int minor)
38244 rwlock_init(&md->map_lock);
38245 atomic_set(&md->holders, 1);
38246 atomic_set(&md->open_count, 0);
38247 - atomic_set(&md->event_nr, 0);
38248 - atomic_set(&md->uevent_seq, 0);
38249 + atomic_set_unchecked(&md->event_nr, 0);
38250 + atomic_set_unchecked(&md->uevent_seq, 0);
38251 INIT_LIST_HEAD(&md->uevent_list);
38252 spin_lock_init(&md->uevent_lock);
38253
38254 @@ -2026,7 +2026,7 @@ static void event_callback(void *context)
38255
38256 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
38257
38258 - atomic_inc(&md->event_nr);
38259 + atomic_inc_unchecked(&md->event_nr);
38260 wake_up(&md->eventq);
38261 }
38262
38263 @@ -2683,18 +2683,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
38264
38265 uint32_t dm_next_uevent_seq(struct mapped_device *md)
38266 {
38267 - return atomic_add_return(1, &md->uevent_seq);
38268 + return atomic_add_return_unchecked(1, &md->uevent_seq);
38269 }
38270
38271 uint32_t dm_get_event_nr(struct mapped_device *md)
38272 {
38273 - return atomic_read(&md->event_nr);
38274 + return atomic_read_unchecked(&md->event_nr);
38275 }
38276
38277 int dm_wait_event(struct mapped_device *md, int event_nr)
38278 {
38279 return wait_event_interruptible(md->eventq,
38280 - (event_nr != atomic_read(&md->event_nr)));
38281 + (event_nr != atomic_read_unchecked(&md->event_nr)));
38282 }
38283
38284 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
38285 diff --git a/drivers/md/md.c b/drivers/md/md.c
38286 index f363135..9b38815 100644
38287 --- a/drivers/md/md.c
38288 +++ b/drivers/md/md.c
38289 @@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
38290 * start build, activate spare
38291 */
38292 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
38293 -static atomic_t md_event_count;
38294 +static atomic_unchecked_t md_event_count;
38295 void md_new_event(struct mddev *mddev)
38296 {
38297 - atomic_inc(&md_event_count);
38298 + atomic_inc_unchecked(&md_event_count);
38299 wake_up(&md_event_waiters);
38300 }
38301 EXPORT_SYMBOL_GPL(md_new_event);
38302 @@ -253,7 +253,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
38303 */
38304 static void md_new_event_inintr(struct mddev *mddev)
38305 {
38306 - atomic_inc(&md_event_count);
38307 + atomic_inc_unchecked(&md_event_count);
38308 wake_up(&md_event_waiters);
38309 }
38310
38311 @@ -1507,7 +1507,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
38312 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
38313 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
38314 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
38315 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38316 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38317
38318 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
38319 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
38320 @@ -1751,7 +1751,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
38321 else
38322 sb->resync_offset = cpu_to_le64(0);
38323
38324 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
38325 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
38326
38327 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
38328 sb->size = cpu_to_le64(mddev->dev_sectors);
38329 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
38330 static ssize_t
38331 errors_show(struct md_rdev *rdev, char *page)
38332 {
38333 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
38334 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
38335 }
38336
38337 static ssize_t
38338 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
38339 char *e;
38340 unsigned long n = simple_strtoul(buf, &e, 10);
38341 if (*buf && (*e == 0 || *e == '\n')) {
38342 - atomic_set(&rdev->corrected_errors, n);
38343 + atomic_set_unchecked(&rdev->corrected_errors, n);
38344 return len;
38345 }
38346 return -EINVAL;
38347 @@ -3210,8 +3210,8 @@ int md_rdev_init(struct md_rdev *rdev)
38348 rdev->sb_loaded = 0;
38349 rdev->bb_page = NULL;
38350 atomic_set(&rdev->nr_pending, 0);
38351 - atomic_set(&rdev->read_errors, 0);
38352 - atomic_set(&rdev->corrected_errors, 0);
38353 + atomic_set_unchecked(&rdev->read_errors, 0);
38354 + atomic_set_unchecked(&rdev->corrected_errors, 0);
38355
38356 INIT_LIST_HEAD(&rdev->same_set);
38357 init_waitqueue_head(&rdev->blocked_wait);
38358 @@ -6987,7 +6987,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
38359
38360 spin_unlock(&pers_lock);
38361 seq_printf(seq, "\n");
38362 - seq->poll_event = atomic_read(&md_event_count);
38363 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38364 return 0;
38365 }
38366 if (v == (void*)2) {
38367 @@ -7090,7 +7090,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
38368 return error;
38369
38370 seq = file->private_data;
38371 - seq->poll_event = atomic_read(&md_event_count);
38372 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38373 return error;
38374 }
38375
38376 @@ -7104,7 +7104,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
38377 /* always allow read */
38378 mask = POLLIN | POLLRDNORM;
38379
38380 - if (seq->poll_event != atomic_read(&md_event_count))
38381 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
38382 mask |= POLLERR | POLLPRI;
38383 return mask;
38384 }
38385 @@ -7148,7 +7148,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
38386 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
38387 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
38388 (int)part_stat_read(&disk->part0, sectors[1]) -
38389 - atomic_read(&disk->sync_io);
38390 + atomic_read_unchecked(&disk->sync_io);
38391 /* sync IO will cause sync_io to increase before the disk_stats
38392 * as sync_io is counted when a request starts, and
38393 * disk_stats is counted when it completes.
38394 diff --git a/drivers/md/md.h b/drivers/md/md.h
38395 index eca59c3..7c42285 100644
38396 --- a/drivers/md/md.h
38397 +++ b/drivers/md/md.h
38398 @@ -94,13 +94,13 @@ struct md_rdev {
38399 * only maintained for arrays that
38400 * support hot removal
38401 */
38402 - atomic_t read_errors; /* number of consecutive read errors that
38403 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
38404 * we have tried to ignore.
38405 */
38406 struct timespec last_read_error; /* monotonic time since our
38407 * last read error
38408 */
38409 - atomic_t corrected_errors; /* number of corrected read errors,
38410 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
38411 * for reporting to userspace and storing
38412 * in superblock.
38413 */
38414 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
38415
38416 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
38417 {
38418 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38419 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38420 }
38421
38422 struct md_personality
38423 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
38424 index 1cbfc6b..56e1dbb 100644
38425 --- a/drivers/md/persistent-data/dm-space-map.h
38426 +++ b/drivers/md/persistent-data/dm-space-map.h
38427 @@ -60,6 +60,7 @@ struct dm_space_map {
38428 int (*root_size)(struct dm_space_map *sm, size_t *result);
38429 int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);
38430 };
38431 +typedef struct dm_space_map __no_const dm_space_map_no_const;
38432
38433 /*----------------------------------------------------------------*/
38434
38435 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
38436 index 75b1f89..00ba344 100644
38437 --- a/drivers/md/raid1.c
38438 +++ b/drivers/md/raid1.c
38439 @@ -1819,7 +1819,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
38440 if (r1_sync_page_io(rdev, sect, s,
38441 bio->bi_io_vec[idx].bv_page,
38442 READ) != 0)
38443 - atomic_add(s, &rdev->corrected_errors);
38444 + atomic_add_unchecked(s, &rdev->corrected_errors);
38445 }
38446 sectors -= s;
38447 sect += s;
38448 @@ -2041,7 +2041,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
38449 test_bit(In_sync, &rdev->flags)) {
38450 if (r1_sync_page_io(rdev, sect, s,
38451 conf->tmppage, READ)) {
38452 - atomic_add(s, &rdev->corrected_errors);
38453 + atomic_add_unchecked(s, &rdev->corrected_errors);
38454 printk(KERN_INFO
38455 "md/raid1:%s: read error corrected "
38456 "(%d sectors at %llu on %s)\n",
38457 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
38458 index 8d925dc..11d674f 100644
38459 --- a/drivers/md/raid10.c
38460 +++ b/drivers/md/raid10.c
38461 @@ -1878,7 +1878,7 @@ static void end_sync_read(struct bio *bio, int error)
38462 /* The write handler will notice the lack of
38463 * R10BIO_Uptodate and record any errors etc
38464 */
38465 - atomic_add(r10_bio->sectors,
38466 + atomic_add_unchecked(r10_bio->sectors,
38467 &conf->mirrors[d].rdev->corrected_errors);
38468
38469 /* for reconstruct, we always reschedule after a read.
38470 @@ -2227,7 +2227,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38471 {
38472 struct timespec cur_time_mon;
38473 unsigned long hours_since_last;
38474 - unsigned int read_errors = atomic_read(&rdev->read_errors);
38475 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
38476
38477 ktime_get_ts(&cur_time_mon);
38478
38479 @@ -2249,9 +2249,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38480 * overflowing the shift of read_errors by hours_since_last.
38481 */
38482 if (hours_since_last >= 8 * sizeof(read_errors))
38483 - atomic_set(&rdev->read_errors, 0);
38484 + atomic_set_unchecked(&rdev->read_errors, 0);
38485 else
38486 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
38487 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
38488 }
38489
38490 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
38491 @@ -2305,8 +2305,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38492 return;
38493
38494 check_decay_read_errors(mddev, rdev);
38495 - atomic_inc(&rdev->read_errors);
38496 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
38497 + atomic_inc_unchecked(&rdev->read_errors);
38498 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
38499 char b[BDEVNAME_SIZE];
38500 bdevname(rdev->bdev, b);
38501
38502 @@ -2314,7 +2314,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38503 "md/raid10:%s: %s: Raid device exceeded "
38504 "read_error threshold [cur %d:max %d]\n",
38505 mdname(mddev), b,
38506 - atomic_read(&rdev->read_errors), max_read_errors);
38507 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
38508 printk(KERN_NOTICE
38509 "md/raid10:%s: %s: Failing raid device\n",
38510 mdname(mddev), b);
38511 @@ -2469,7 +2469,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38512 sect +
38513 choose_data_offset(r10_bio, rdev)),
38514 bdevname(rdev->bdev, b));
38515 - atomic_add(s, &rdev->corrected_errors);
38516 + atomic_add_unchecked(s, &rdev->corrected_errors);
38517 }
38518
38519 rdev_dec_pending(rdev, mddev);
38520 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
38521 index 94ce78e..df99e24 100644
38522 --- a/drivers/md/raid5.c
38523 +++ b/drivers/md/raid5.c
38524 @@ -1800,21 +1800,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
38525 mdname(conf->mddev), STRIPE_SECTORS,
38526 (unsigned long long)s,
38527 bdevname(rdev->bdev, b));
38528 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
38529 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
38530 clear_bit(R5_ReadError, &sh->dev[i].flags);
38531 clear_bit(R5_ReWrite, &sh->dev[i].flags);
38532 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
38533 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
38534
38535 - if (atomic_read(&rdev->read_errors))
38536 - atomic_set(&rdev->read_errors, 0);
38537 + if (atomic_read_unchecked(&rdev->read_errors))
38538 + atomic_set_unchecked(&rdev->read_errors, 0);
38539 } else {
38540 const char *bdn = bdevname(rdev->bdev, b);
38541 int retry = 0;
38542 int set_bad = 0;
38543
38544 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
38545 - atomic_inc(&rdev->read_errors);
38546 + atomic_inc_unchecked(&rdev->read_errors);
38547 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
38548 printk_ratelimited(
38549 KERN_WARNING
38550 @@ -1842,7 +1842,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
38551 mdname(conf->mddev),
38552 (unsigned long long)s,
38553 bdn);
38554 - } else if (atomic_read(&rdev->read_errors)
38555 + } else if (atomic_read_unchecked(&rdev->read_errors)
38556 > conf->max_nr_stripes)
38557 printk(KERN_WARNING
38558 "md/raid:%s: Too many read errors, failing device %s.\n",
38559 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
38560 index d33101a..6b13069 100644
38561 --- a/drivers/media/dvb-core/dvbdev.c
38562 +++ b/drivers/media/dvb-core/dvbdev.c
38563 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
38564 const struct dvb_device *template, void *priv, int type)
38565 {
38566 struct dvb_device *dvbdev;
38567 - struct file_operations *dvbdevfops;
38568 + file_operations_no_const *dvbdevfops;
38569 struct device *clsdev;
38570 int minor;
38571 int id;
38572 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
38573 index 404f63a..4796533 100644
38574 --- a/drivers/media/dvb-frontends/dib3000.h
38575 +++ b/drivers/media/dvb-frontends/dib3000.h
38576 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
38577 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
38578 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
38579 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
38580 -};
38581 +} __no_const;
38582
38583 #if defined(CONFIG_DVB_DIB3000MB) || (defined(CONFIG_DVB_DIB3000MB_MODULE) && defined(MODULE))
38584 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
38585 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
38586 index bc78354..42c9459 100644
38587 --- a/drivers/media/pci/cx88/cx88-video.c
38588 +++ b/drivers/media/pci/cx88/cx88-video.c
38589 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
38590
38591 /* ------------------------------------------------------------------ */
38592
38593 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38594 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38595 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38596 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38597 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38598 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38599
38600 module_param_array(video_nr, int, NULL, 0444);
38601 module_param_array(vbi_nr, int, NULL, 0444);
38602 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
38603 index 8e9a668..78d6310 100644
38604 --- a/drivers/media/platform/omap/omap_vout.c
38605 +++ b/drivers/media/platform/omap/omap_vout.c
38606 @@ -63,7 +63,6 @@ enum omap_vout_channels {
38607 OMAP_VIDEO2,
38608 };
38609
38610 -static struct videobuf_queue_ops video_vbq_ops;
38611 /* Variables configurable through module params*/
38612 static u32 video1_numbuffers = 3;
38613 static u32 video2_numbuffers = 3;
38614 @@ -1012,6 +1011,12 @@ static int omap_vout_open(struct file *file)
38615 {
38616 struct videobuf_queue *q;
38617 struct omap_vout_device *vout = NULL;
38618 + static struct videobuf_queue_ops video_vbq_ops = {
38619 + .buf_setup = omap_vout_buffer_setup,
38620 + .buf_prepare = omap_vout_buffer_prepare,
38621 + .buf_release = omap_vout_buffer_release,
38622 + .buf_queue = omap_vout_buffer_queue,
38623 + };
38624
38625 vout = video_drvdata(file);
38626 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38627 @@ -1029,10 +1034,6 @@ static int omap_vout_open(struct file *file)
38628 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38629
38630 q = &vout->vbq;
38631 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38632 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38633 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38634 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38635 spin_lock_init(&vout->vbq_lock);
38636
38637 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38638 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38639 index b671e20..34088b7 100644
38640 --- a/drivers/media/platform/s5p-tv/mixer.h
38641 +++ b/drivers/media/platform/s5p-tv/mixer.h
38642 @@ -155,7 +155,7 @@ struct mxr_layer {
38643 /** layer index (unique identifier) */
38644 int idx;
38645 /** callbacks for layer methods */
38646 - struct mxr_layer_ops ops;
38647 + struct mxr_layer_ops *ops;
38648 /** format array */
38649 const struct mxr_format **fmt_array;
38650 /** size of format array */
38651 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38652 index b93a21f..2535195 100644
38653 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38654 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38655 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
38656 {
38657 struct mxr_layer *layer;
38658 int ret;
38659 - struct mxr_layer_ops ops = {
38660 + static struct mxr_layer_ops ops = {
38661 .release = mxr_graph_layer_release,
38662 .buffer_set = mxr_graph_buffer_set,
38663 .stream_set = mxr_graph_stream_set,
38664 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
38665 index 3b1670a..595c939 100644
38666 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
38667 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
38668 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
38669 layer->update_buf = next;
38670 }
38671
38672 - layer->ops.buffer_set(layer, layer->update_buf);
38673 + layer->ops->buffer_set(layer, layer->update_buf);
38674
38675 if (done && done != layer->shadow_buf)
38676 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
38677 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
38678 index 1f3b743..e839271 100644
38679 --- a/drivers/media/platform/s5p-tv/mixer_video.c
38680 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
38681 @@ -208,7 +208,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
38682 layer->geo.src.height = layer->geo.src.full_height;
38683
38684 mxr_geometry_dump(mdev, &layer->geo);
38685 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38686 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38687 mxr_geometry_dump(mdev, &layer->geo);
38688 }
38689
38690 @@ -226,7 +226,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
38691 layer->geo.dst.full_width = mbus_fmt.width;
38692 layer->geo.dst.full_height = mbus_fmt.height;
38693 layer->geo.dst.field = mbus_fmt.field;
38694 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38695 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38696
38697 mxr_geometry_dump(mdev, &layer->geo);
38698 }
38699 @@ -332,7 +332,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
38700 /* set source size to highest accepted value */
38701 geo->src.full_width = max(geo->dst.full_width, pix->width);
38702 geo->src.full_height = max(geo->dst.full_height, pix->height);
38703 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38704 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38705 mxr_geometry_dump(mdev, &layer->geo);
38706 /* set cropping to total visible screen */
38707 geo->src.width = pix->width;
38708 @@ -340,12 +340,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
38709 geo->src.x_offset = 0;
38710 geo->src.y_offset = 0;
38711 /* assure consistency of geometry */
38712 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38713 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38714 mxr_geometry_dump(mdev, &layer->geo);
38715 /* set full size to lowest possible value */
38716 geo->src.full_width = 0;
38717 geo->src.full_height = 0;
38718 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38719 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38720 mxr_geometry_dump(mdev, &layer->geo);
38721
38722 /* returning results */
38723 @@ -472,7 +472,7 @@ static int mxr_s_selection(struct file *file, void *fh,
38724 target->width = s->r.width;
38725 target->height = s->r.height;
38726
38727 - layer->ops.fix_geometry(layer, stage, s->flags);
38728 + layer->ops->fix_geometry(layer, stage, s->flags);
38729
38730 /* retrieve update selection rectangle */
38731 res.left = target->x_offset;
38732 @@ -937,13 +937,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
38733 mxr_output_get(mdev);
38734
38735 mxr_layer_update_output(layer);
38736 - layer->ops.format_set(layer);
38737 + layer->ops->format_set(layer);
38738 /* enabling layer in hardware */
38739 spin_lock_irqsave(&layer->enq_slock, flags);
38740 layer->state = MXR_LAYER_STREAMING;
38741 spin_unlock_irqrestore(&layer->enq_slock, flags);
38742
38743 - layer->ops.stream_set(layer, MXR_ENABLE);
38744 + layer->ops->stream_set(layer, MXR_ENABLE);
38745 mxr_streamer_get(mdev);
38746
38747 return 0;
38748 @@ -1013,7 +1013,7 @@ static int stop_streaming(struct vb2_queue *vq)
38749 spin_unlock_irqrestore(&layer->enq_slock, flags);
38750
38751 /* disabling layer in hardware */
38752 - layer->ops.stream_set(layer, MXR_DISABLE);
38753 + layer->ops->stream_set(layer, MXR_DISABLE);
38754 /* remove one streamer */
38755 mxr_streamer_put(mdev);
38756 /* allow changes in output configuration */
38757 @@ -1052,8 +1052,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
38758
38759 void mxr_layer_release(struct mxr_layer *layer)
38760 {
38761 - if (layer->ops.release)
38762 - layer->ops.release(layer);
38763 + if (layer->ops->release)
38764 + layer->ops->release(layer);
38765 }
38766
38767 void mxr_base_layer_release(struct mxr_layer *layer)
38768 @@ -1079,7 +1079,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
38769
38770 layer->mdev = mdev;
38771 layer->idx = idx;
38772 - layer->ops = *ops;
38773 + layer->ops = ops;
38774
38775 spin_lock_init(&layer->enq_slock);
38776 INIT_LIST_HEAD(&layer->enq_list);
38777 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38778 index 3d13a63..da31bf1 100644
38779 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38780 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38781 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
38782 {
38783 struct mxr_layer *layer;
38784 int ret;
38785 - struct mxr_layer_ops ops = {
38786 + static struct mxr_layer_ops ops = {
38787 .release = mxr_vp_layer_release,
38788 .buffer_set = mxr_vp_buffer_set,
38789 .stream_set = mxr_vp_stream_set,
38790 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
38791 index 643d80a..56bb96b 100644
38792 --- a/drivers/media/radio/radio-cadet.c
38793 +++ b/drivers/media/radio/radio-cadet.c
38794 @@ -302,6 +302,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38795 unsigned char readbuf[RDS_BUFFER];
38796 int i = 0;
38797
38798 + if (count > RDS_BUFFER)
38799 + return -EFAULT;
38800 mutex_lock(&dev->lock);
38801 if (dev->rdsstat == 0)
38802 cadet_start_rds(dev);
38803 @@ -317,7 +319,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38804 while (i < count && dev->rdsin != dev->rdsout)
38805 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
38806
38807 - if (i && copy_to_user(data, readbuf, i))
38808 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
38809 i = -EFAULT;
38810 unlock:
38811 mutex_unlock(&dev->lock);
38812 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
38813 index 3940bb0..fb3952a 100644
38814 --- a/drivers/media/usb/dvb-usb/cxusb.c
38815 +++ b/drivers/media/usb/dvb-usb/cxusb.c
38816 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
38817
38818 struct dib0700_adapter_state {
38819 int (*set_param_save) (struct dvb_frontend *);
38820 -};
38821 +} __no_const;
38822
38823 static int dib7070_set_param_override(struct dvb_frontend *fe)
38824 {
38825 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
38826 index 9382895..ac8093c 100644
38827 --- a/drivers/media/usb/dvb-usb/dw2102.c
38828 +++ b/drivers/media/usb/dvb-usb/dw2102.c
38829 @@ -95,7 +95,7 @@ struct su3000_state {
38830
38831 struct s6x0_state {
38832 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
38833 -};
38834 +} __no_const;
38835
38836 /* debug */
38837 static int dvb_usb_dw2102_debug;
38838 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
38839 index aa6e7c7..4cd8061 100644
38840 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
38841 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
38842 @@ -1923,7 +1923,8 @@ struct v4l2_ioctl_info {
38843 struct file *file, void *fh, void *p);
38844 } u;
38845 void (*debug)(const void *arg, bool write_only);
38846 -};
38847 +} __do_const;
38848 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
38849
38850 /* This control needs a priority check */
38851 #define INFO_FL_PRIO (1 << 0)
38852 @@ -2108,7 +2109,7 @@ static long __video_do_ioctl(struct file *file,
38853 struct video_device *vfd = video_devdata(file);
38854 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
38855 bool write_only = false;
38856 - struct v4l2_ioctl_info default_info;
38857 + v4l2_ioctl_info_no_const default_info;
38858 const struct v4l2_ioctl_info *info;
38859 void *fh = file->private_data;
38860 struct v4l2_fh *vfh = NULL;
38861 diff --git a/drivers/memstick/host/r592.c b/drivers/memstick/host/r592.c
38862 index 29b2172..a7c5b31 100644
38863 --- a/drivers/memstick/host/r592.c
38864 +++ b/drivers/memstick/host/r592.c
38865 @@ -454,7 +454,7 @@ static int r592_transfer_fifo_pio(struct r592_device *dev)
38866 /* Executes one TPC (data is read/written from small or large fifo) */
38867 static void r592_execute_tpc(struct r592_device *dev)
38868 {
38869 - bool is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
38870 + bool is_write;
38871 int len, error;
38872 u32 status, reg;
38873
38874 @@ -463,6 +463,7 @@ static void r592_execute_tpc(struct r592_device *dev)
38875 return;
38876 }
38877
38878 + is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
38879 len = dev->req->long_data ?
38880 dev->req->sg.length : dev->req->data_len;
38881
38882 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
38883 index fb69baa..3aeea2e 100644
38884 --- a/drivers/message/fusion/mptbase.c
38885 +++ b/drivers/message/fusion/mptbase.c
38886 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38887 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
38888 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
38889
38890 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38891 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
38892 +#else
38893 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
38894 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
38895 +#endif
38896 +
38897 /*
38898 * Rounding UP to nearest 4-kB boundary here...
38899 */
38900 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38901 ioc->facts.GlobalCredits);
38902
38903 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
38904 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38905 + NULL, NULL);
38906 +#else
38907 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
38908 +#endif
38909 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
38910 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
38911 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
38912 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
38913 index fa43c39..daeb158 100644
38914 --- a/drivers/message/fusion/mptsas.c
38915 +++ b/drivers/message/fusion/mptsas.c
38916 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
38917 return 0;
38918 }
38919
38920 +static inline void
38921 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38922 +{
38923 + if (phy_info->port_details) {
38924 + phy_info->port_details->rphy = rphy;
38925 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38926 + ioc->name, rphy));
38927 + }
38928 +
38929 + if (rphy) {
38930 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38931 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38932 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38933 + ioc->name, rphy, rphy->dev.release));
38934 + }
38935 +}
38936 +
38937 /* no mutex */
38938 static void
38939 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
38940 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
38941 return NULL;
38942 }
38943
38944 -static inline void
38945 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38946 -{
38947 - if (phy_info->port_details) {
38948 - phy_info->port_details->rphy = rphy;
38949 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38950 - ioc->name, rphy));
38951 - }
38952 -
38953 - if (rphy) {
38954 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38955 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38956 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38957 - ioc->name, rphy, rphy->dev.release));
38958 - }
38959 -}
38960 -
38961 static inline struct sas_port *
38962 mptsas_get_port(struct mptsas_phyinfo *phy_info)
38963 {
38964 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
38965 index 164afa7..b6b2e74 100644
38966 --- a/drivers/message/fusion/mptscsih.c
38967 +++ b/drivers/message/fusion/mptscsih.c
38968 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
38969
38970 h = shost_priv(SChost);
38971
38972 - if (h) {
38973 - if (h->info_kbuf == NULL)
38974 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38975 - return h->info_kbuf;
38976 - h->info_kbuf[0] = '\0';
38977 + if (!h)
38978 + return NULL;
38979
38980 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38981 - h->info_kbuf[size-1] = '\0';
38982 - }
38983 + if (h->info_kbuf == NULL)
38984 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38985 + return h->info_kbuf;
38986 + h->info_kbuf[0] = '\0';
38987 +
38988 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38989 + h->info_kbuf[size-1] = '\0';
38990
38991 return h->info_kbuf;
38992 }
38993 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
38994 index 8001aa6..b137580 100644
38995 --- a/drivers/message/i2o/i2o_proc.c
38996 +++ b/drivers/message/i2o/i2o_proc.c
38997 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
38998 "Array Controller Device"
38999 };
39000
39001 -static char *chtostr(char *tmp, u8 *chars, int n)
39002 -{
39003 - tmp[0] = 0;
39004 - return strncat(tmp, (char *)chars, n);
39005 -}
39006 -
39007 static int i2o_report_query_status(struct seq_file *seq, int block_status,
39008 char *group)
39009 {
39010 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39011 } *result;
39012
39013 i2o_exec_execute_ddm_table ddm_table;
39014 - char tmp[28 + 1];
39015
39016 result = kmalloc(sizeof(*result), GFP_KERNEL);
39017 if (!result)
39018 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39019
39020 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
39021 seq_printf(seq, "%-#8x", ddm_table.module_id);
39022 - seq_printf(seq, "%-29s",
39023 - chtostr(tmp, ddm_table.module_name_version, 28));
39024 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
39025 seq_printf(seq, "%9d ", ddm_table.data_size);
39026 seq_printf(seq, "%8d", ddm_table.code_size);
39027
39028 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39029
39030 i2o_driver_result_table *result;
39031 i2o_driver_store_table *dst;
39032 - char tmp[28 + 1];
39033
39034 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
39035 if (result == NULL)
39036 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39037
39038 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
39039 seq_printf(seq, "%-#8x", dst->module_id);
39040 - seq_printf(seq, "%-29s",
39041 - chtostr(tmp, dst->module_name_version, 28));
39042 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
39043 + seq_printf(seq, "%-.28s", dst->module_name_version);
39044 + seq_printf(seq, "%-.8s", dst->date);
39045 seq_printf(seq, "%8d ", dst->module_size);
39046 seq_printf(seq, "%8d ", dst->mpb_size);
39047 seq_printf(seq, "0x%04x", dst->module_flags);
39048 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39049 // == (allow) 512d bytes (max)
39050 static u16 *work16 = (u16 *) work32;
39051 int token;
39052 - char tmp[16 + 1];
39053
39054 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
39055
39056 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39057 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
39058 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
39059 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
39060 - seq_printf(seq, "Vendor info : %s\n",
39061 - chtostr(tmp, (u8 *) (work32 + 2), 16));
39062 - seq_printf(seq, "Product info : %s\n",
39063 - chtostr(tmp, (u8 *) (work32 + 6), 16));
39064 - seq_printf(seq, "Description : %s\n",
39065 - chtostr(tmp, (u8 *) (work32 + 10), 16));
39066 - seq_printf(seq, "Product rev. : %s\n",
39067 - chtostr(tmp, (u8 *) (work32 + 14), 8));
39068 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
39069 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
39070 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
39071 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
39072
39073 seq_printf(seq, "Serial number : ");
39074 print_serial_number(seq, (u8 *) (work32 + 16),
39075 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39076 u8 pad[256]; // allow up to 256 byte (max) serial number
39077 } result;
39078
39079 - char tmp[24 + 1];
39080 -
39081 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
39082
39083 if (token < 0) {
39084 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39085 }
39086
39087 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
39088 - seq_printf(seq, "Module name : %s\n",
39089 - chtostr(tmp, result.module_name, 24));
39090 - seq_printf(seq, "Module revision : %s\n",
39091 - chtostr(tmp, result.module_rev, 8));
39092 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
39093 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
39094
39095 seq_printf(seq, "Serial number : ");
39096 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
39097 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39098 u8 instance_number[4];
39099 } result;
39100
39101 - char tmp[64 + 1];
39102 -
39103 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
39104
39105 if (token < 0) {
39106 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39107 return 0;
39108 }
39109
39110 - seq_printf(seq, "Device name : %s\n",
39111 - chtostr(tmp, result.device_name, 64));
39112 - seq_printf(seq, "Service name : %s\n",
39113 - chtostr(tmp, result.service_name, 64));
39114 - seq_printf(seq, "Physical name : %s\n",
39115 - chtostr(tmp, result.physical_location, 64));
39116 - seq_printf(seq, "Instance number : %s\n",
39117 - chtostr(tmp, result.instance_number, 4));
39118 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
39119 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
39120 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
39121 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
39122
39123 return 0;
39124 }
39125 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
39126 index a8c08f3..155fe3d 100644
39127 --- a/drivers/message/i2o/iop.c
39128 +++ b/drivers/message/i2o/iop.c
39129 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
39130
39131 spin_lock_irqsave(&c->context_list_lock, flags);
39132
39133 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
39134 - atomic_inc(&c->context_list_counter);
39135 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
39136 + atomic_inc_unchecked(&c->context_list_counter);
39137
39138 - entry->context = atomic_read(&c->context_list_counter);
39139 + entry->context = atomic_read_unchecked(&c->context_list_counter);
39140
39141 list_add(&entry->list, &c->context_list);
39142
39143 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
39144
39145 #if BITS_PER_LONG == 64
39146 spin_lock_init(&c->context_list_lock);
39147 - atomic_set(&c->context_list_counter, 0);
39148 + atomic_set_unchecked(&c->context_list_counter, 0);
39149 INIT_LIST_HEAD(&c->context_list);
39150 #endif
39151
39152 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
39153 index 45ece11..8efa218 100644
39154 --- a/drivers/mfd/janz-cmodio.c
39155 +++ b/drivers/mfd/janz-cmodio.c
39156 @@ -13,6 +13,7 @@
39157
39158 #include <linux/kernel.h>
39159 #include <linux/module.h>
39160 +#include <linux/slab.h>
39161 #include <linux/init.h>
39162 #include <linux/pci.h>
39163 #include <linux/interrupt.h>
39164 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
39165 index a5f9888..1c0ed56 100644
39166 --- a/drivers/mfd/twl4030-irq.c
39167 +++ b/drivers/mfd/twl4030-irq.c
39168 @@ -35,6 +35,7 @@
39169 #include <linux/of.h>
39170 #include <linux/irqdomain.h>
39171 #include <linux/i2c/twl.h>
39172 +#include <asm/pgtable.h>
39173
39174 #include "twl-core.h"
39175
39176 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
39177 * Install an irq handler for each of the SIH modules;
39178 * clone dummy irq_chip since PIH can't *do* anything
39179 */
39180 - twl4030_irq_chip = dummy_irq_chip;
39181 - twl4030_irq_chip.name = "twl4030";
39182 + pax_open_kernel();
39183 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
39184 + *(const char **)&twl4030_irq_chip.name = "twl4030";
39185
39186 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39187 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39188 + pax_close_kernel();
39189
39190 for (i = irq_base; i < irq_end; i++) {
39191 irq_set_chip_and_handler(i, &twl4030_irq_chip,
39192 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
39193 index 277a8db..0e0b754 100644
39194 --- a/drivers/mfd/twl6030-irq.c
39195 +++ b/drivers/mfd/twl6030-irq.c
39196 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
39197 * install an irq handler for each of the modules;
39198 * clone dummy irq_chip since PIH can't *do* anything
39199 */
39200 - twl6030_irq_chip = dummy_irq_chip;
39201 - twl6030_irq_chip.name = "twl6030";
39202 - twl6030_irq_chip.irq_set_type = NULL;
39203 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39204 + pax_open_kernel();
39205 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
39206 + *(const char **)&twl6030_irq_chip.name = "twl6030";
39207 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
39208 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39209 + pax_close_kernel();
39210
39211 for (i = irq_base; i < irq_end; i++) {
39212 irq_set_chip_and_handler(i, &twl6030_irq_chip,
39213 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
39214 index f428d86..274c368 100644
39215 --- a/drivers/misc/c2port/core.c
39216 +++ b/drivers/misc/c2port/core.c
39217 @@ -924,7 +924,9 @@ struct c2port_device *c2port_device_register(char *name,
39218 mutex_init(&c2dev->mutex);
39219
39220 /* Create binary file */
39221 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39222 + pax_open_kernel();
39223 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39224 + pax_close_kernel();
39225 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
39226 if (unlikely(ret))
39227 goto error_device_create_bin_file;
39228 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
39229 index 3aa9a96..59cf685 100644
39230 --- a/drivers/misc/kgdbts.c
39231 +++ b/drivers/misc/kgdbts.c
39232 @@ -832,7 +832,7 @@ static void run_plant_and_detach_test(int is_early)
39233 char before[BREAK_INSTR_SIZE];
39234 char after[BREAK_INSTR_SIZE];
39235
39236 - probe_kernel_read(before, (char *)kgdbts_break_test,
39237 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
39238 BREAK_INSTR_SIZE);
39239 init_simple_test();
39240 ts.tst = plant_and_detach_test;
39241 @@ -840,7 +840,7 @@ static void run_plant_and_detach_test(int is_early)
39242 /* Activate test with initial breakpoint */
39243 if (!is_early)
39244 kgdb_breakpoint();
39245 - probe_kernel_read(after, (char *)kgdbts_break_test,
39246 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
39247 BREAK_INSTR_SIZE);
39248 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
39249 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
39250 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
39251 index 4a87e5c..76bdf5c 100644
39252 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
39253 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
39254 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
39255 * the lid is closed. This leads to interrupts as soon as a little move
39256 * is done.
39257 */
39258 - atomic_inc(&lis3->count);
39259 + atomic_inc_unchecked(&lis3->count);
39260
39261 wake_up_interruptible(&lis3->misc_wait);
39262 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
39263 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
39264 if (lis3->pm_dev)
39265 pm_runtime_get_sync(lis3->pm_dev);
39266
39267 - atomic_set(&lis3->count, 0);
39268 + atomic_set_unchecked(&lis3->count, 0);
39269 return 0;
39270 }
39271
39272 @@ -617,7 +617,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
39273 add_wait_queue(&lis3->misc_wait, &wait);
39274 while (true) {
39275 set_current_state(TASK_INTERRUPTIBLE);
39276 - data = atomic_xchg(&lis3->count, 0);
39277 + data = atomic_xchg_unchecked(&lis3->count, 0);
39278 if (data)
39279 break;
39280
39281 @@ -658,7 +658,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
39282 struct lis3lv02d, miscdev);
39283
39284 poll_wait(file, &lis3->misc_wait, wait);
39285 - if (atomic_read(&lis3->count))
39286 + if (atomic_read_unchecked(&lis3->count))
39287 return POLLIN | POLLRDNORM;
39288 return 0;
39289 }
39290 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
39291 index c439c82..1f20f57 100644
39292 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
39293 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
39294 @@ -297,7 +297,7 @@ struct lis3lv02d {
39295 struct input_polled_dev *idev; /* input device */
39296 struct platform_device *pdev; /* platform device */
39297 struct regulator_bulk_data regulators[2];
39298 - atomic_t count; /* interrupt count after last read */
39299 + atomic_unchecked_t count; /* interrupt count after last read */
39300 union axis_conversion ac; /* hw -> logical axis */
39301 int mapped_btns[3];
39302
39303 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
39304 index 2f30bad..c4c13d0 100644
39305 --- a/drivers/misc/sgi-gru/gruhandles.c
39306 +++ b/drivers/misc/sgi-gru/gruhandles.c
39307 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
39308 unsigned long nsec;
39309
39310 nsec = CLKS2NSEC(clks);
39311 - atomic_long_inc(&mcs_op_statistics[op].count);
39312 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
39313 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
39314 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
39315 if (mcs_op_statistics[op].max < nsec)
39316 mcs_op_statistics[op].max = nsec;
39317 }
39318 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
39319 index 950dbe9..eeef0f8 100644
39320 --- a/drivers/misc/sgi-gru/gruprocfs.c
39321 +++ b/drivers/misc/sgi-gru/gruprocfs.c
39322 @@ -32,9 +32,9 @@
39323
39324 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
39325
39326 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
39327 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
39328 {
39329 - unsigned long val = atomic_long_read(v);
39330 + unsigned long val = atomic_long_read_unchecked(v);
39331
39332 seq_printf(s, "%16lu %s\n", val, id);
39333 }
39334 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
39335
39336 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
39337 for (op = 0; op < mcsop_last; op++) {
39338 - count = atomic_long_read(&mcs_op_statistics[op].count);
39339 - total = atomic_long_read(&mcs_op_statistics[op].total);
39340 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
39341 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
39342 max = mcs_op_statistics[op].max;
39343 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
39344 count ? total / count : 0, max);
39345 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
39346 index 5c3ce24..4915ccb 100644
39347 --- a/drivers/misc/sgi-gru/grutables.h
39348 +++ b/drivers/misc/sgi-gru/grutables.h
39349 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
39350 * GRU statistics.
39351 */
39352 struct gru_stats_s {
39353 - atomic_long_t vdata_alloc;
39354 - atomic_long_t vdata_free;
39355 - atomic_long_t gts_alloc;
39356 - atomic_long_t gts_free;
39357 - atomic_long_t gms_alloc;
39358 - atomic_long_t gms_free;
39359 - atomic_long_t gts_double_allocate;
39360 - atomic_long_t assign_context;
39361 - atomic_long_t assign_context_failed;
39362 - atomic_long_t free_context;
39363 - atomic_long_t load_user_context;
39364 - atomic_long_t load_kernel_context;
39365 - atomic_long_t lock_kernel_context;
39366 - atomic_long_t unlock_kernel_context;
39367 - atomic_long_t steal_user_context;
39368 - atomic_long_t steal_kernel_context;
39369 - atomic_long_t steal_context_failed;
39370 - atomic_long_t nopfn;
39371 - atomic_long_t asid_new;
39372 - atomic_long_t asid_next;
39373 - atomic_long_t asid_wrap;
39374 - atomic_long_t asid_reuse;
39375 - atomic_long_t intr;
39376 - atomic_long_t intr_cbr;
39377 - atomic_long_t intr_tfh;
39378 - atomic_long_t intr_spurious;
39379 - atomic_long_t intr_mm_lock_failed;
39380 - atomic_long_t call_os;
39381 - atomic_long_t call_os_wait_queue;
39382 - atomic_long_t user_flush_tlb;
39383 - atomic_long_t user_unload_context;
39384 - atomic_long_t user_exception;
39385 - atomic_long_t set_context_option;
39386 - atomic_long_t check_context_retarget_intr;
39387 - atomic_long_t check_context_unload;
39388 - atomic_long_t tlb_dropin;
39389 - atomic_long_t tlb_preload_page;
39390 - atomic_long_t tlb_dropin_fail_no_asid;
39391 - atomic_long_t tlb_dropin_fail_upm;
39392 - atomic_long_t tlb_dropin_fail_invalid;
39393 - atomic_long_t tlb_dropin_fail_range_active;
39394 - atomic_long_t tlb_dropin_fail_idle;
39395 - atomic_long_t tlb_dropin_fail_fmm;
39396 - atomic_long_t tlb_dropin_fail_no_exception;
39397 - atomic_long_t tfh_stale_on_fault;
39398 - atomic_long_t mmu_invalidate_range;
39399 - atomic_long_t mmu_invalidate_page;
39400 - atomic_long_t flush_tlb;
39401 - atomic_long_t flush_tlb_gru;
39402 - atomic_long_t flush_tlb_gru_tgh;
39403 - atomic_long_t flush_tlb_gru_zero_asid;
39404 + atomic_long_unchecked_t vdata_alloc;
39405 + atomic_long_unchecked_t vdata_free;
39406 + atomic_long_unchecked_t gts_alloc;
39407 + atomic_long_unchecked_t gts_free;
39408 + atomic_long_unchecked_t gms_alloc;
39409 + atomic_long_unchecked_t gms_free;
39410 + atomic_long_unchecked_t gts_double_allocate;
39411 + atomic_long_unchecked_t assign_context;
39412 + atomic_long_unchecked_t assign_context_failed;
39413 + atomic_long_unchecked_t free_context;
39414 + atomic_long_unchecked_t load_user_context;
39415 + atomic_long_unchecked_t load_kernel_context;
39416 + atomic_long_unchecked_t lock_kernel_context;
39417 + atomic_long_unchecked_t unlock_kernel_context;
39418 + atomic_long_unchecked_t steal_user_context;
39419 + atomic_long_unchecked_t steal_kernel_context;
39420 + atomic_long_unchecked_t steal_context_failed;
39421 + atomic_long_unchecked_t nopfn;
39422 + atomic_long_unchecked_t asid_new;
39423 + atomic_long_unchecked_t asid_next;
39424 + atomic_long_unchecked_t asid_wrap;
39425 + atomic_long_unchecked_t asid_reuse;
39426 + atomic_long_unchecked_t intr;
39427 + atomic_long_unchecked_t intr_cbr;
39428 + atomic_long_unchecked_t intr_tfh;
39429 + atomic_long_unchecked_t intr_spurious;
39430 + atomic_long_unchecked_t intr_mm_lock_failed;
39431 + atomic_long_unchecked_t call_os;
39432 + atomic_long_unchecked_t call_os_wait_queue;
39433 + atomic_long_unchecked_t user_flush_tlb;
39434 + atomic_long_unchecked_t user_unload_context;
39435 + atomic_long_unchecked_t user_exception;
39436 + atomic_long_unchecked_t set_context_option;
39437 + atomic_long_unchecked_t check_context_retarget_intr;
39438 + atomic_long_unchecked_t check_context_unload;
39439 + atomic_long_unchecked_t tlb_dropin;
39440 + atomic_long_unchecked_t tlb_preload_page;
39441 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
39442 + atomic_long_unchecked_t tlb_dropin_fail_upm;
39443 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
39444 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
39445 + atomic_long_unchecked_t tlb_dropin_fail_idle;
39446 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
39447 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
39448 + atomic_long_unchecked_t tfh_stale_on_fault;
39449 + atomic_long_unchecked_t mmu_invalidate_range;
39450 + atomic_long_unchecked_t mmu_invalidate_page;
39451 + atomic_long_unchecked_t flush_tlb;
39452 + atomic_long_unchecked_t flush_tlb_gru;
39453 + atomic_long_unchecked_t flush_tlb_gru_tgh;
39454 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
39455
39456 - atomic_long_t copy_gpa;
39457 - atomic_long_t read_gpa;
39458 + atomic_long_unchecked_t copy_gpa;
39459 + atomic_long_unchecked_t read_gpa;
39460
39461 - atomic_long_t mesq_receive;
39462 - atomic_long_t mesq_receive_none;
39463 - atomic_long_t mesq_send;
39464 - atomic_long_t mesq_send_failed;
39465 - atomic_long_t mesq_noop;
39466 - atomic_long_t mesq_send_unexpected_error;
39467 - atomic_long_t mesq_send_lb_overflow;
39468 - atomic_long_t mesq_send_qlimit_reached;
39469 - atomic_long_t mesq_send_amo_nacked;
39470 - atomic_long_t mesq_send_put_nacked;
39471 - atomic_long_t mesq_page_overflow;
39472 - atomic_long_t mesq_qf_locked;
39473 - atomic_long_t mesq_qf_noop_not_full;
39474 - atomic_long_t mesq_qf_switch_head_failed;
39475 - atomic_long_t mesq_qf_unexpected_error;
39476 - atomic_long_t mesq_noop_unexpected_error;
39477 - atomic_long_t mesq_noop_lb_overflow;
39478 - atomic_long_t mesq_noop_qlimit_reached;
39479 - atomic_long_t mesq_noop_amo_nacked;
39480 - atomic_long_t mesq_noop_put_nacked;
39481 - atomic_long_t mesq_noop_page_overflow;
39482 + atomic_long_unchecked_t mesq_receive;
39483 + atomic_long_unchecked_t mesq_receive_none;
39484 + atomic_long_unchecked_t mesq_send;
39485 + atomic_long_unchecked_t mesq_send_failed;
39486 + atomic_long_unchecked_t mesq_noop;
39487 + atomic_long_unchecked_t mesq_send_unexpected_error;
39488 + atomic_long_unchecked_t mesq_send_lb_overflow;
39489 + atomic_long_unchecked_t mesq_send_qlimit_reached;
39490 + atomic_long_unchecked_t mesq_send_amo_nacked;
39491 + atomic_long_unchecked_t mesq_send_put_nacked;
39492 + atomic_long_unchecked_t mesq_page_overflow;
39493 + atomic_long_unchecked_t mesq_qf_locked;
39494 + atomic_long_unchecked_t mesq_qf_noop_not_full;
39495 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
39496 + atomic_long_unchecked_t mesq_qf_unexpected_error;
39497 + atomic_long_unchecked_t mesq_noop_unexpected_error;
39498 + atomic_long_unchecked_t mesq_noop_lb_overflow;
39499 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
39500 + atomic_long_unchecked_t mesq_noop_amo_nacked;
39501 + atomic_long_unchecked_t mesq_noop_put_nacked;
39502 + atomic_long_unchecked_t mesq_noop_page_overflow;
39503
39504 };
39505
39506 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
39507 tghop_invalidate, mcsop_last};
39508
39509 struct mcs_op_statistic {
39510 - atomic_long_t count;
39511 - atomic_long_t total;
39512 + atomic_long_unchecked_t count;
39513 + atomic_long_unchecked_t total;
39514 unsigned long max;
39515 };
39516
39517 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
39518
39519 #define STAT(id) do { \
39520 if (gru_options & OPT_STATS) \
39521 - atomic_long_inc(&gru_stats.id); \
39522 + atomic_long_inc_unchecked(&gru_stats.id); \
39523 } while (0)
39524
39525 #ifdef CONFIG_SGI_GRU_DEBUG
39526 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
39527 index c862cd4..0d176fe 100644
39528 --- a/drivers/misc/sgi-xp/xp.h
39529 +++ b/drivers/misc/sgi-xp/xp.h
39530 @@ -288,7 +288,7 @@ struct xpc_interface {
39531 xpc_notify_func, void *);
39532 void (*received) (short, int, void *);
39533 enum xp_retval (*partid_to_nasids) (short, void *);
39534 -};
39535 +} __no_const;
39536
39537 extern struct xpc_interface xpc_interface;
39538
39539 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
39540 index b94d5f7..7f494c5 100644
39541 --- a/drivers/misc/sgi-xp/xpc.h
39542 +++ b/drivers/misc/sgi-xp/xpc.h
39543 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
39544 void (*received_payload) (struct xpc_channel *, void *);
39545 void (*notify_senders_of_disconnect) (struct xpc_channel *);
39546 };
39547 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
39548
39549 /* struct xpc_partition act_state values (for XPC HB) */
39550
39551 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
39552 /* found in xpc_main.c */
39553 extern struct device *xpc_part;
39554 extern struct device *xpc_chan;
39555 -extern struct xpc_arch_operations xpc_arch_ops;
39556 +extern xpc_arch_operations_no_const xpc_arch_ops;
39557 extern int xpc_disengage_timelimit;
39558 extern int xpc_disengage_timedout;
39559 extern int xpc_activate_IRQ_rcvd;
39560 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
39561 index d971817..33bdca5 100644
39562 --- a/drivers/misc/sgi-xp/xpc_main.c
39563 +++ b/drivers/misc/sgi-xp/xpc_main.c
39564 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
39565 .notifier_call = xpc_system_die,
39566 };
39567
39568 -struct xpc_arch_operations xpc_arch_ops;
39569 +xpc_arch_operations_no_const xpc_arch_ops;
39570
39571 /*
39572 * Timer function to enforce the timelimit on the partition disengage.
39573 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
39574
39575 if (((die_args->trapnr == X86_TRAP_MF) ||
39576 (die_args->trapnr == X86_TRAP_XF)) &&
39577 - !user_mode_vm(die_args->regs))
39578 + !user_mode(die_args->regs))
39579 xpc_die_deactivate();
39580
39581 break;
39582 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
39583 index 6d8f701..35b6369 100644
39584 --- a/drivers/mmc/core/mmc_ops.c
39585 +++ b/drivers/mmc/core/mmc_ops.c
39586 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
39587 void *data_buf;
39588 int is_on_stack;
39589
39590 - is_on_stack = object_is_on_stack(buf);
39591 + is_on_stack = object_starts_on_stack(buf);
39592 if (is_on_stack) {
39593 /*
39594 * dma onto stack is unsafe/nonportable, but callers to this
39595 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
39596 index 53b8fd9..615b462 100644
39597 --- a/drivers/mmc/host/dw_mmc.h
39598 +++ b/drivers/mmc/host/dw_mmc.h
39599 @@ -205,5 +205,5 @@ struct dw_mci_drv_data {
39600 int (*parse_dt)(struct dw_mci *host);
39601 int (*setup_bus)(struct dw_mci *host,
39602 struct device_node *slot_np, u8 bus_width);
39603 -};
39604 +} __do_const;
39605 #endif /* _DW_MMC_H_ */
39606 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
39607 index 82a8de1..3c56ccb 100644
39608 --- a/drivers/mmc/host/sdhci-s3c.c
39609 +++ b/drivers/mmc/host/sdhci-s3c.c
39610 @@ -721,9 +721,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
39611 * we can use overriding functions instead of default.
39612 */
39613 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
39614 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39615 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39616 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39617 + pax_open_kernel();
39618 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39619 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39620 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39621 + pax_close_kernel();
39622 }
39623
39624 /* It supports additional host capabilities if needed */
39625 diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
39626 index a4eb8b5..8c0628f 100644
39627 --- a/drivers/mtd/devices/doc2000.c
39628 +++ b/drivers/mtd/devices/doc2000.c
39629 @@ -753,7 +753,7 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
39630
39631 /* The ECC will not be calculated correctly if less than 512 is written */
39632 /* DBB-
39633 - if (len != 0x200 && eccbuf)
39634 + if (len != 0x200)
39635 printk(KERN_WARNING
39636 "ECC needs a full sector write (adr: %lx size %lx)\n",
39637 (long) to, (long) len);
39638 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
39639 index 0c8bb6b..6f35deb 100644
39640 --- a/drivers/mtd/nand/denali.c
39641 +++ b/drivers/mtd/nand/denali.c
39642 @@ -24,6 +24,7 @@
39643 #include <linux/slab.h>
39644 #include <linux/mtd/mtd.h>
39645 #include <linux/module.h>
39646 +#include <linux/slab.h>
39647
39648 #include "denali.h"
39649
39650 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
39651 index 51b9d6a..52af9a7 100644
39652 --- a/drivers/mtd/nftlmount.c
39653 +++ b/drivers/mtd/nftlmount.c
39654 @@ -24,6 +24,7 @@
39655 #include <asm/errno.h>
39656 #include <linux/delay.h>
39657 #include <linux/slab.h>
39658 +#include <linux/sched.h>
39659 #include <linux/mtd/mtd.h>
39660 #include <linux/mtd/nand.h>
39661 #include <linux/mtd/nftl.h>
39662 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
39663 index 8dd6ba5..419cc1d 100644
39664 --- a/drivers/mtd/sm_ftl.c
39665 +++ b/drivers/mtd/sm_ftl.c
39666 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
39667 #define SM_CIS_VENDOR_OFFSET 0x59
39668 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
39669 {
39670 - struct attribute_group *attr_group;
39671 + attribute_group_no_const *attr_group;
39672 struct attribute **attributes;
39673 struct sm_sysfs_attribute *vendor_attribute;
39674
39675 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
39676 index 27cdf1f..8c37357 100644
39677 --- a/drivers/net/bonding/bond_main.c
39678 +++ b/drivers/net/bonding/bond_main.c
39679 @@ -4859,7 +4859,7 @@ static unsigned int bond_get_num_tx_queues(void)
39680 return tx_queues;
39681 }
39682
39683 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
39684 +static struct rtnl_link_ops bond_link_ops = {
39685 .kind = "bond",
39686 .priv_size = sizeof(struct bonding),
39687 .setup = bond_setup,
39688 @@ -4975,8 +4975,8 @@ static void __exit bonding_exit(void)
39689
39690 bond_destroy_debugfs();
39691
39692 - rtnl_link_unregister(&bond_link_ops);
39693 unregister_pernet_subsys(&bond_net_ops);
39694 + rtnl_link_unregister(&bond_link_ops);
39695
39696 #ifdef CONFIG_NET_POLL_CONTROLLER
39697 /*
39698 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
39699 index 70dba5d..11a0919 100644
39700 --- a/drivers/net/ethernet/8390/ax88796.c
39701 +++ b/drivers/net/ethernet/8390/ax88796.c
39702 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
39703 if (ax->plat->reg_offsets)
39704 ei_local->reg_offset = ax->plat->reg_offsets;
39705 else {
39706 + resource_size_t _mem_size = mem_size;
39707 + do_div(_mem_size, 0x18);
39708 ei_local->reg_offset = ax->reg_offsets;
39709 for (ret = 0; ret < 0x18; ret++)
39710 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
39711 + ax->reg_offsets[ret] = _mem_size * ret;
39712 }
39713
39714 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
39715 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39716 index 0991534..8098e92 100644
39717 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39718 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39719 @@ -1094,7 +1094,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
39720 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
39721 {
39722 /* RX_MODE controlling object */
39723 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
39724 + bnx2x_init_rx_mode_obj(bp);
39725
39726 /* multicast configuration controlling object */
39727 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
39728 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39729 index 10bc093..a2fb42a 100644
39730 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39731 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39732 @@ -2136,12 +2136,12 @@ static u8 bnx2x_dcbnl_get_cap(struct net_device *netdev, int capid, u8 *cap)
39733 break;
39734 default:
39735 BNX2X_ERR("Non valid capability ID\n");
39736 - rval = -EINVAL;
39737 + rval = 1;
39738 break;
39739 }
39740 } else {
39741 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39742 - rval = -EINVAL;
39743 + rval = 1;
39744 }
39745
39746 DP(BNX2X_MSG_DCB, "capid %d:%x\n", capid, *cap);
39747 @@ -2167,12 +2167,12 @@ static int bnx2x_dcbnl_get_numtcs(struct net_device *netdev, int tcid, u8 *num)
39748 break;
39749 default:
39750 BNX2X_ERR("Non valid TC-ID\n");
39751 - rval = -EINVAL;
39752 + rval = 1;
39753 break;
39754 }
39755 } else {
39756 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39757 - rval = -EINVAL;
39758 + rval = 1;
39759 }
39760
39761 return rval;
39762 @@ -2185,7 +2185,7 @@ static int bnx2x_dcbnl_set_numtcs(struct net_device *netdev, int tcid, u8 num)
39763 return -EINVAL;
39764 }
39765
39766 -static u8 bnx2x_dcbnl_get_pfc_state(struct net_device *netdev)
39767 +static u8 bnx2x_dcbnl_get_pfc_state(struct net_device *netdev)
39768 {
39769 struct bnx2x *bp = netdev_priv(netdev);
39770 DP(BNX2X_MSG_DCB, "state = %d\n", bp->dcbx_local_feat.pfc.enabled);
39771 @@ -2387,12 +2387,12 @@ static u8 bnx2x_dcbnl_get_featcfg(struct net_device *netdev, int featid,
39772 break;
39773 default:
39774 BNX2X_ERR("Non valid featrue-ID\n");
39775 - rval = -EINVAL;
39776 + rval = 1;
39777 break;
39778 }
39779 } else {
39780 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39781 - rval = -EINVAL;
39782 + rval = 1;
39783 }
39784
39785 return rval;
39786 @@ -2428,12 +2428,12 @@ static u8 bnx2x_dcbnl_set_featcfg(struct net_device *netdev, int featid,
39787 break;
39788 default:
39789 BNX2X_ERR("Non valid featrue-ID\n");
39790 - rval = -EINVAL;
39791 + rval = 1;
39792 break;
39793 }
39794 } else {
39795 DP(BNX2X_MSG_DCB, "dcbnl call not valid\n");
39796 - rval = -EINVAL;
39797 + rval = 1;
39798 }
39799
39800 return rval;
39801 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
39802 index 5523da3..4fcf274 100644
39803 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
39804 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
39805 @@ -4767,7 +4767,7 @@ static void bnx2x_after_function_update(struct bnx2x *bp)
39806 q);
39807 }
39808
39809 - if (!NO_FCOE(bp)) {
39810 + if (!NO_FCOE(bp) && CNIC_ENABLED(bp)) {
39811 fp = &bp->fp[FCOE_IDX(bp)];
39812 queue_params.q_obj = &bnx2x_sp_obj(bp, fp).q_obj;
39813
39814 @@ -13047,6 +13047,7 @@ static int bnx2x_unregister_cnic(struct net_device *dev)
39815 RCU_INIT_POINTER(bp->cnic_ops, NULL);
39816 mutex_unlock(&bp->cnic_mutex);
39817 synchronize_rcu();
39818 + bp->cnic_enabled = false;
39819 kfree(bp->cnic_kwq);
39820 bp->cnic_kwq = NULL;
39821
39822 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39823 index 09b625e..15b16fe 100644
39824 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39825 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39826 @@ -2375,15 +2375,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
39827 return rc;
39828 }
39829
39830 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39831 - struct bnx2x_rx_mode_obj *o)
39832 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
39833 {
39834 if (CHIP_IS_E1x(bp)) {
39835 - o->wait_comp = bnx2x_empty_rx_mode_wait;
39836 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
39837 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
39838 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
39839 } else {
39840 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
39841 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
39842 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
39843 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
39844 }
39845 }
39846
39847 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39848 index adbd91b..58ec94a 100644
39849 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39850 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39851 @@ -1293,8 +1293,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
39852
39853 /********************* RX MODE ****************/
39854
39855 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39856 - struct bnx2x_rx_mode_obj *o);
39857 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
39858
39859 /**
39860 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
39861 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
39862 index d330e81..ce1fb9a 100644
39863 --- a/drivers/net/ethernet/broadcom/tg3.h
39864 +++ b/drivers/net/ethernet/broadcom/tg3.h
39865 @@ -146,6 +146,7 @@
39866 #define CHIPREV_ID_5750_A0 0x4000
39867 #define CHIPREV_ID_5750_A1 0x4001
39868 #define CHIPREV_ID_5750_A3 0x4003
39869 +#define CHIPREV_ID_5750_C1 0x4201
39870 #define CHIPREV_ID_5750_C2 0x4202
39871 #define CHIPREV_ID_5752_A0_HW 0x5000
39872 #define CHIPREV_ID_5752_A0 0x6000
39873 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39874 index 8cffcdf..aadf043 100644
39875 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39876 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39877 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
39878 */
39879 struct l2t_skb_cb {
39880 arp_failure_handler_func arp_failure_handler;
39881 -};
39882 +} __no_const;
39883
39884 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
39885
39886 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
39887 index 4c83003..2a2a5b9 100644
39888 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
39889 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
39890 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39891 for (i=0; i<ETH_ALEN; i++) {
39892 tmp.addr[i] = dev->dev_addr[i];
39893 }
39894 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39895 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39896 break;
39897
39898 case DE4X5_SET_HWADDR: /* Set the hardware address */
39899 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39900 spin_lock_irqsave(&lp->lock, flags);
39901 memcpy(&statbuf, &lp->pktStats, ioc->len);
39902 spin_unlock_irqrestore(&lp->lock, flags);
39903 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
39904 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
39905 return -EFAULT;
39906 break;
39907 }
39908 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
39909 index 4d6f3c5..6169e60 100644
39910 --- a/drivers/net/ethernet/emulex/benet/be_main.c
39911 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
39912 @@ -455,7 +455,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
39913
39914 if (wrapped)
39915 newacc += 65536;
39916 - ACCESS_ONCE(*acc) = newacc;
39917 + ACCESS_ONCE_RW(*acc) = newacc;
39918 }
39919
39920 void be_parse_stats(struct be_adapter *adapter)
39921 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
39922 index 74d749e..eefb1bd 100644
39923 --- a/drivers/net/ethernet/faraday/ftgmac100.c
39924 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
39925 @@ -31,6 +31,8 @@
39926 #include <linux/netdevice.h>
39927 #include <linux/phy.h>
39928 #include <linux/platform_device.h>
39929 +#include <linux/interrupt.h>
39930 +#include <linux/irqreturn.h>
39931 #include <net/ip.h>
39932
39933 #include "ftgmac100.h"
39934 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
39935 index b901a01..1ff32ee 100644
39936 --- a/drivers/net/ethernet/faraday/ftmac100.c
39937 +++ b/drivers/net/ethernet/faraday/ftmac100.c
39938 @@ -31,6 +31,8 @@
39939 #include <linux/module.h>
39940 #include <linux/netdevice.h>
39941 #include <linux/platform_device.h>
39942 +#include <linux/interrupt.h>
39943 +#include <linux/irqreturn.h>
39944
39945 #include "ftmac100.h"
39946
39947 diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
39948 index a59f077..7925d77 100644
39949 --- a/drivers/net/ethernet/intel/e100.c
39950 +++ b/drivers/net/ethernet/intel/e100.c
39951 @@ -870,7 +870,7 @@ err_unlock:
39952 }
39953
39954 static int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
39955 - void (*cb_prepare)(struct nic *, struct cb *, struct sk_buff *))
39956 + int (*cb_prepare)(struct nic *, struct cb *, struct sk_buff *))
39957 {
39958 struct cb *cb;
39959 unsigned long flags;
39960 @@ -888,10 +888,13 @@ static int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
39961 nic->cbs_avail--;
39962 cb->skb = skb;
39963
39964 + err = cb_prepare(nic, cb, skb);
39965 + if (err)
39966 + goto err_unlock;
39967 +
39968 if (unlikely(!nic->cbs_avail))
39969 err = -ENOSPC;
39970
39971 - cb_prepare(nic, cb, skb);
39972
39973 /* Order is important otherwise we'll be in a race with h/w:
39974 * set S-bit in current first, then clear S-bit in previous. */
39975 @@ -1091,7 +1094,7 @@ static void e100_get_defaults(struct nic *nic)
39976 nic->mii.mdio_write = mdio_write;
39977 }
39978
39979 -static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
39980 +static int e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
39981 {
39982 struct config *config = &cb->u.config;
39983 u8 *c = (u8 *)config;
39984 @@ -1181,6 +1184,7 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
39985 netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
39986 "[16-23]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
39987 c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23]);
39988 + return 0;
39989 }
39990
39991 /*************************************************************************
39992 @@ -1331,7 +1335,7 @@ static const struct firmware *e100_request_firmware(struct nic *nic)
39993 return fw;
39994 }
39995
39996 -static void e100_setup_ucode(struct nic *nic, struct cb *cb,
39997 +static int e100_setup_ucode(struct nic *nic, struct cb *cb,
39998 struct sk_buff *skb)
39999 {
40000 const struct firmware *fw = (void *)skb;
40001 @@ -1358,6 +1362,7 @@ static void e100_setup_ucode(struct nic *nic, struct cb *cb,
40002 cb->u.ucode[min_size] |= cpu_to_le32((BUNDLESMALL) ? 0xFFFF : 0xFF80);
40003
40004 cb->command = cpu_to_le16(cb_ucode | cb_el);
40005 + return 0;
40006 }
40007
40008 static inline int e100_load_ucode_wait(struct nic *nic)
40009 @@ -1400,18 +1405,20 @@ static inline int e100_load_ucode_wait(struct nic *nic)
40010 return err;
40011 }
40012
40013 -static void e100_setup_iaaddr(struct nic *nic, struct cb *cb,
40014 +static int e100_setup_iaaddr(struct nic *nic, struct cb *cb,
40015 struct sk_buff *skb)
40016 {
40017 cb->command = cpu_to_le16(cb_iaaddr);
40018 memcpy(cb->u.iaaddr, nic->netdev->dev_addr, ETH_ALEN);
40019 + return 0;
40020 }
40021
40022 -static void e100_dump(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40023 +static int e100_dump(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40024 {
40025 cb->command = cpu_to_le16(cb_dump);
40026 cb->u.dump_buffer_addr = cpu_to_le32(nic->dma_addr +
40027 offsetof(struct mem, dump_buf));
40028 + return 0;
40029 }
40030
40031 static int e100_phy_check_without_mii(struct nic *nic)
40032 @@ -1581,7 +1588,7 @@ static int e100_hw_init(struct nic *nic)
40033 return 0;
40034 }
40035
40036 -static void e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40037 +static int e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40038 {
40039 struct net_device *netdev = nic->netdev;
40040 struct netdev_hw_addr *ha;
40041 @@ -1596,6 +1603,7 @@ static void e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40042 memcpy(&cb->u.multi.addr[i++ * ETH_ALEN], &ha->addr,
40043 ETH_ALEN);
40044 }
40045 + return 0;
40046 }
40047
40048 static void e100_set_multicast_list(struct net_device *netdev)
40049 @@ -1756,11 +1764,18 @@ static void e100_watchdog(unsigned long data)
40050 round_jiffies(jiffies + E100_WATCHDOG_PERIOD));
40051 }
40052
40053 -static void e100_xmit_prepare(struct nic *nic, struct cb *cb,
40054 +static int e100_xmit_prepare(struct nic *nic, struct cb *cb,
40055 struct sk_buff *skb)
40056 {
40057 + dma_addr_t dma_addr;
40058 cb->command = nic->tx_command;
40059
40060 + dma_addr = pci_map_single(nic->pdev,
40061 + skb->data, skb->len, PCI_DMA_TODEVICE);
40062 + /* If we can't map the skb, have the upper layer try later */
40063 + if (pci_dma_mapping_error(nic->pdev, dma_addr))
40064 + return -ENOMEM;
40065 +
40066 /*
40067 * Use the last 4 bytes of the SKB payload packet as the CRC, used for
40068 * testing, ie sending frames with bad CRC.
40069 @@ -1777,11 +1792,10 @@ static void e100_xmit_prepare(struct nic *nic, struct cb *cb,
40070 cb->u.tcb.tcb_byte_count = 0;
40071 cb->u.tcb.threshold = nic->tx_threshold;
40072 cb->u.tcb.tbd_count = 1;
40073 - cb->u.tcb.tbd.buf_addr = cpu_to_le32(pci_map_single(nic->pdev,
40074 - skb->data, skb->len, PCI_DMA_TODEVICE));
40075 - /* check for mapping failure? */
40076 + cb->u.tcb.tbd.buf_addr = cpu_to_le32(dma_addr);
40077 cb->u.tcb.tbd.size = cpu_to_le16(skb->len);
40078 skb_tx_timestamp(skb);
40079 + return 0;
40080 }
40081
40082 static netdev_tx_t e100_xmit_frame(struct sk_buff *skb,
40083 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40084 index bb9256a..56d8752 100644
40085 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40086 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40087 @@ -806,7 +806,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
40088 }
40089
40090 /* update the base incval used to calculate frequency adjustment */
40091 - ACCESS_ONCE(adapter->base_incval) = incval;
40092 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
40093 smp_mb();
40094
40095 /* need lock to prevent incorrect read while modifying cyclecounter */
40096 diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
40097 index c124e67..db9b897 100644
40098 --- a/drivers/net/ethernet/lantiq_etop.c
40099 +++ b/drivers/net/ethernet/lantiq_etop.c
40100 @@ -769,7 +769,7 @@ ltq_etop_probe(struct platform_device *pdev)
40101 return 0;
40102
40103 err_free:
40104 - kfree(dev);
40105 + free_netdev(dev);
40106 err_out:
40107 return err;
40108 }
40109 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40110 index fbe5363..266b4e3 100644
40111 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
40112 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40113 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40114 struct __vxge_hw_fifo *fifo;
40115 struct vxge_hw_fifo_config *config;
40116 u32 txdl_size, txdl_per_memblock;
40117 - struct vxge_hw_mempool_cbs fifo_mp_callback;
40118 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
40119 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
40120 + };
40121 +
40122 struct __vxge_hw_virtualpath *vpath;
40123
40124 if ((vp == NULL) || (attr == NULL)) {
40125 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40126 goto exit;
40127 }
40128
40129 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
40130 -
40131 fifo->mempool =
40132 __vxge_hw_mempool_create(vpath->hldev,
40133 fifo->config->memblock_size,
40134 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
40135 index 998974f..ecd26db 100644
40136 --- a/drivers/net/ethernet/realtek/r8169.c
40137 +++ b/drivers/net/ethernet/realtek/r8169.c
40138 @@ -741,22 +741,22 @@ struct rtl8169_private {
40139 struct mdio_ops {
40140 void (*write)(struct rtl8169_private *, int, int);
40141 int (*read)(struct rtl8169_private *, int);
40142 - } mdio_ops;
40143 + } __no_const mdio_ops;
40144
40145 struct pll_power_ops {
40146 void (*down)(struct rtl8169_private *);
40147 void (*up)(struct rtl8169_private *);
40148 - } pll_power_ops;
40149 + } __no_const pll_power_ops;
40150
40151 struct jumbo_ops {
40152 void (*enable)(struct rtl8169_private *);
40153 void (*disable)(struct rtl8169_private *);
40154 - } jumbo_ops;
40155 + } __no_const jumbo_ops;
40156
40157 struct csi_ops {
40158 void (*write)(struct rtl8169_private *, int, int);
40159 u32 (*read)(struct rtl8169_private *, int);
40160 - } csi_ops;
40161 + } __no_const csi_ops;
40162
40163 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
40164 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
40165 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
40166 index 3f93624..cf01144 100644
40167 --- a/drivers/net/ethernet/sfc/ptp.c
40168 +++ b/drivers/net/ethernet/sfc/ptp.c
40169 @@ -553,7 +553,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
40170 (u32)((u64)ptp->start.dma_addr >> 32));
40171
40172 /* Clear flag that signals MC ready */
40173 - ACCESS_ONCE(*start) = 0;
40174 + ACCESS_ONCE_RW(*start) = 0;
40175 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
40176 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
40177
40178 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40179 index 0c74a70..3bc6f68 100644
40180 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40181 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40182 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
40183
40184 writel(value, ioaddr + MMC_CNTRL);
40185
40186 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40187 - MMC_CNTRL, value);
40188 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40189 +// MMC_CNTRL, value);
40190 }
40191
40192 /* To mask all all interrupts.*/
40193 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
40194 index e6fe0d8..2b7d752 100644
40195 --- a/drivers/net/hyperv/hyperv_net.h
40196 +++ b/drivers/net/hyperv/hyperv_net.h
40197 @@ -101,7 +101,7 @@ struct rndis_device {
40198
40199 enum rndis_device_state state;
40200 bool link_state;
40201 - atomic_t new_req_id;
40202 + atomic_unchecked_t new_req_id;
40203
40204 spinlock_t request_lock;
40205 struct list_head req_list;
40206 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
40207 index 2b657d4..9903bc0 100644
40208 --- a/drivers/net/hyperv/rndis_filter.c
40209 +++ b/drivers/net/hyperv/rndis_filter.c
40210 @@ -107,7 +107,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
40211 * template
40212 */
40213 set = &rndis_msg->msg.set_req;
40214 - set->req_id = atomic_inc_return(&dev->new_req_id);
40215 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40216
40217 /* Add to the request list */
40218 spin_lock_irqsave(&dev->request_lock, flags);
40219 @@ -758,7 +758,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
40220
40221 /* Setup the rndis set */
40222 halt = &request->request_msg.msg.halt_req;
40223 - halt->req_id = atomic_inc_return(&dev->new_req_id);
40224 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40225
40226 /* Ignore return since this msg is optional. */
40227 rndis_filter_send_request(dev, request);
40228 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
40229 index 1e9cb0b..7839125 100644
40230 --- a/drivers/net/ieee802154/fakehard.c
40231 +++ b/drivers/net/ieee802154/fakehard.c
40232 @@ -386,7 +386,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
40233 phy->transmit_power = 0xbf;
40234
40235 dev->netdev_ops = &fake_ops;
40236 - dev->ml_priv = &fake_mlme;
40237 + dev->ml_priv = (void *)&fake_mlme;
40238
40239 priv = netdev_priv(dev);
40240 priv->phy = phy;
40241 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
40242 index e5cb723..1fc0461 100644
40243 --- a/drivers/net/macvlan.c
40244 +++ b/drivers/net/macvlan.c
40245 @@ -852,13 +852,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
40246 int macvlan_link_register(struct rtnl_link_ops *ops)
40247 {
40248 /* common fields */
40249 - ops->priv_size = sizeof(struct macvlan_dev);
40250 - ops->validate = macvlan_validate;
40251 - ops->maxtype = IFLA_MACVLAN_MAX;
40252 - ops->policy = macvlan_policy;
40253 - ops->changelink = macvlan_changelink;
40254 - ops->get_size = macvlan_get_size;
40255 - ops->fill_info = macvlan_fill_info;
40256 + pax_open_kernel();
40257 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
40258 + *(void **)&ops->validate = macvlan_validate;
40259 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
40260 + *(const void **)&ops->policy = macvlan_policy;
40261 + *(void **)&ops->changelink = macvlan_changelink;
40262 + *(void **)&ops->get_size = macvlan_get_size;
40263 + *(void **)&ops->fill_info = macvlan_fill_info;
40264 + pax_close_kernel();
40265
40266 return rtnl_link_register(ops);
40267 };
40268 @@ -914,7 +916,7 @@ static int macvlan_device_event(struct notifier_block *unused,
40269 return NOTIFY_DONE;
40270 }
40271
40272 -static struct notifier_block macvlan_notifier_block __read_mostly = {
40273 +static struct notifier_block macvlan_notifier_block = {
40274 .notifier_call = macvlan_device_event,
40275 };
40276
40277 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
40278 index 0f0f9ce..0ca5819 100644
40279 --- a/drivers/net/macvtap.c
40280 +++ b/drivers/net/macvtap.c
40281 @@ -1100,7 +1100,7 @@ static int macvtap_device_event(struct notifier_block *unused,
40282 return NOTIFY_DONE;
40283 }
40284
40285 -static struct notifier_block macvtap_notifier_block __read_mostly = {
40286 +static struct notifier_block macvtap_notifier_block = {
40287 .notifier_call = macvtap_device_event,
40288 };
40289
40290 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
40291 index daec9b0..6428fcb 100644
40292 --- a/drivers/net/phy/mdio-bitbang.c
40293 +++ b/drivers/net/phy/mdio-bitbang.c
40294 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
40295 struct mdiobb_ctrl *ctrl = bus->priv;
40296
40297 module_put(ctrl->ops->owner);
40298 + mdiobus_unregister(bus);
40299 mdiobus_free(bus);
40300 }
40301 EXPORT_SYMBOL(free_mdio_bitbang);
40302 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
40303 index 508570e..f706dc7 100644
40304 --- a/drivers/net/ppp/ppp_generic.c
40305 +++ b/drivers/net/ppp/ppp_generic.c
40306 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40307 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
40308 struct ppp_stats stats;
40309 struct ppp_comp_stats cstats;
40310 - char *vers;
40311
40312 switch (cmd) {
40313 case SIOCGPPPSTATS:
40314 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40315 break;
40316
40317 case SIOCGPPPVER:
40318 - vers = PPP_VERSION;
40319 - if (copy_to_user(addr, vers, strlen(vers) + 1))
40320 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
40321 break;
40322 err = 0;
40323 break;
40324 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
40325 index 8efe47a..a8075c5 100644
40326 --- a/drivers/net/team/team.c
40327 +++ b/drivers/net/team/team.c
40328 @@ -2603,7 +2603,7 @@ static int team_device_event(struct notifier_block *unused,
40329 return NOTIFY_DONE;
40330 }
40331
40332 -static struct notifier_block team_notifier_block __read_mostly = {
40333 +static struct notifier_block team_notifier_block = {
40334 .notifier_call = team_device_event,
40335 };
40336
40337 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
40338 index cb95fe5..a5bdab5 100644
40339 --- a/drivers/net/tun.c
40340 +++ b/drivers/net/tun.c
40341 @@ -1838,7 +1838,7 @@ unlock:
40342 }
40343
40344 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40345 - unsigned long arg, int ifreq_len)
40346 + unsigned long arg, size_t ifreq_len)
40347 {
40348 struct tun_file *tfile = file->private_data;
40349 struct tun_struct *tun;
40350 @@ -1850,6 +1850,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40351 int vnet_hdr_sz;
40352 int ret;
40353
40354 + if (ifreq_len > sizeof ifr)
40355 + return -EFAULT;
40356 +
40357 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
40358 if (copy_from_user(&ifr, argp, ifreq_len))
40359 return -EFAULT;
40360 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
40361 index cd8ccb2..cff5144 100644
40362 --- a/drivers/net/usb/hso.c
40363 +++ b/drivers/net/usb/hso.c
40364 @@ -71,7 +71,7 @@
40365 #include <asm/byteorder.h>
40366 #include <linux/serial_core.h>
40367 #include <linux/serial.h>
40368 -
40369 +#include <asm/local.h>
40370
40371 #define MOD_AUTHOR "Option Wireless"
40372 #define MOD_DESCRIPTION "USB High Speed Option driver"
40373 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
40374 struct urb *urb;
40375
40376 urb = serial->rx_urb[0];
40377 - if (serial->port.count > 0) {
40378 + if (atomic_read(&serial->port.count) > 0) {
40379 count = put_rxbuf_data(urb, serial);
40380 if (count == -1)
40381 return;
40382 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
40383 DUMP1(urb->transfer_buffer, urb->actual_length);
40384
40385 /* Anyone listening? */
40386 - if (serial->port.count == 0)
40387 + if (atomic_read(&serial->port.count) == 0)
40388 return;
40389
40390 if (status == 0) {
40391 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40392 tty_port_tty_set(&serial->port, tty);
40393
40394 /* check for port already opened, if not set the termios */
40395 - serial->port.count++;
40396 - if (serial->port.count == 1) {
40397 + if (atomic_inc_return(&serial->port.count) == 1) {
40398 serial->rx_state = RX_IDLE;
40399 /* Force default termio settings */
40400 _hso_serial_set_termios(tty, NULL);
40401 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40402 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
40403 if (result) {
40404 hso_stop_serial_device(serial->parent);
40405 - serial->port.count--;
40406 + atomic_dec(&serial->port.count);
40407 kref_put(&serial->parent->ref, hso_serial_ref_free);
40408 }
40409 } else {
40410 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
40411
40412 /* reset the rts and dtr */
40413 /* do the actual close */
40414 - serial->port.count--;
40415 + atomic_dec(&serial->port.count);
40416
40417 - if (serial->port.count <= 0) {
40418 - serial->port.count = 0;
40419 + if (atomic_read(&serial->port.count) <= 0) {
40420 + atomic_set(&serial->port.count, 0);
40421 tty_port_tty_set(&serial->port, NULL);
40422 if (!usb_gone)
40423 hso_stop_serial_device(serial->parent);
40424 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
40425
40426 /* the actual setup */
40427 spin_lock_irqsave(&serial->serial_lock, flags);
40428 - if (serial->port.count)
40429 + if (atomic_read(&serial->port.count))
40430 _hso_serial_set_termios(tty, old);
40431 else
40432 tty->termios = *old;
40433 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
40434 D1("Pending read interrupt on port %d\n", i);
40435 spin_lock(&serial->serial_lock);
40436 if (serial->rx_state == RX_IDLE &&
40437 - serial->port.count > 0) {
40438 + atomic_read(&serial->port.count) > 0) {
40439 /* Setup and send a ctrl req read on
40440 * port i */
40441 if (!serial->rx_urb_filled[0]) {
40442 @@ -3079,7 +3078,7 @@ static int hso_resume(struct usb_interface *iface)
40443 /* Start all serial ports */
40444 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
40445 if (serial_table[i] && (serial_table[i]->interface == iface)) {
40446 - if (dev2ser(serial_table[i])->port.count) {
40447 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
40448 result =
40449 hso_start_serial_device(serial_table[i], GFP_NOIO);
40450 hso_kick_transmit(dev2ser(serial_table[i]));
40451 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
40452 index 6993bfa..9053a34 100644
40453 --- a/drivers/net/vxlan.c
40454 +++ b/drivers/net/vxlan.c
40455 @@ -1428,7 +1428,7 @@ nla_put_failure:
40456 return -EMSGSIZE;
40457 }
40458
40459 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
40460 +static struct rtnl_link_ops vxlan_link_ops = {
40461 .kind = "vxlan",
40462 .maxtype = IFLA_VXLAN_MAX,
40463 .policy = vxlan_policy,
40464 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
40465 index 77fa428..996b355 100644
40466 --- a/drivers/net/wireless/at76c50x-usb.c
40467 +++ b/drivers/net/wireless/at76c50x-usb.c
40468 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
40469 }
40470
40471 /* Convert timeout from the DFU status to jiffies */
40472 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
40473 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
40474 {
40475 return msecs_to_jiffies((s->poll_timeout[2] << 16)
40476 | (s->poll_timeout[1] << 8)
40477 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40478 index 8d78253..bebbb68 100644
40479 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40480 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40481 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40482 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
40483 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
40484
40485 - ACCESS_ONCE(ads->ds_link) = i->link;
40486 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
40487 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
40488 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
40489
40490 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
40491 ctl6 = SM(i->keytype, AR_EncrType);
40492 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40493
40494 if ((i->is_first || i->is_last) &&
40495 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
40496 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
40497 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
40498 | set11nTries(i->rates, 1)
40499 | set11nTries(i->rates, 2)
40500 | set11nTries(i->rates, 3)
40501 | (i->dur_update ? AR_DurUpdateEna : 0)
40502 | SM(0, AR_BurstDur);
40503
40504 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
40505 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
40506 | set11nRate(i->rates, 1)
40507 | set11nRate(i->rates, 2)
40508 | set11nRate(i->rates, 3);
40509 } else {
40510 - ACCESS_ONCE(ads->ds_ctl2) = 0;
40511 - ACCESS_ONCE(ads->ds_ctl3) = 0;
40512 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
40513 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
40514 }
40515
40516 if (!i->is_first) {
40517 - ACCESS_ONCE(ads->ds_ctl0) = 0;
40518 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40519 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40520 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
40521 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40522 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40523 return;
40524 }
40525
40526 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40527 break;
40528 }
40529
40530 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40531 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40532 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40533 | SM(i->txpower, AR_XmitPower)
40534 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40535 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40536 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
40537 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
40538
40539 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40540 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40541 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40542 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40543
40544 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
40545 return;
40546
40547 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40548 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40549 | set11nPktDurRTSCTS(i->rates, 1);
40550
40551 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40552 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40553 | set11nPktDurRTSCTS(i->rates, 3);
40554
40555 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40556 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40557 | set11nRateFlags(i->rates, 1)
40558 | set11nRateFlags(i->rates, 2)
40559 | set11nRateFlags(i->rates, 3)
40560 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40561 index 301bf72..3f5654f 100644
40562 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40563 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40564 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40565 (i->qcu << AR_TxQcuNum_S) | desc_len;
40566
40567 checksum += val;
40568 - ACCESS_ONCE(ads->info) = val;
40569 + ACCESS_ONCE_RW(ads->info) = val;
40570
40571 checksum += i->link;
40572 - ACCESS_ONCE(ads->link) = i->link;
40573 + ACCESS_ONCE_RW(ads->link) = i->link;
40574
40575 checksum += i->buf_addr[0];
40576 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
40577 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
40578 checksum += i->buf_addr[1];
40579 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
40580 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
40581 checksum += i->buf_addr[2];
40582 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
40583 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
40584 checksum += i->buf_addr[3];
40585 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
40586 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
40587
40588 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
40589 - ACCESS_ONCE(ads->ctl3) = val;
40590 + ACCESS_ONCE_RW(ads->ctl3) = val;
40591 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
40592 - ACCESS_ONCE(ads->ctl5) = val;
40593 + ACCESS_ONCE_RW(ads->ctl5) = val;
40594 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
40595 - ACCESS_ONCE(ads->ctl7) = val;
40596 + ACCESS_ONCE_RW(ads->ctl7) = val;
40597 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
40598 - ACCESS_ONCE(ads->ctl9) = val;
40599 + ACCESS_ONCE_RW(ads->ctl9) = val;
40600
40601 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
40602 - ACCESS_ONCE(ads->ctl10) = checksum;
40603 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
40604
40605 if (i->is_first || i->is_last) {
40606 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
40607 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
40608 | set11nTries(i->rates, 1)
40609 | set11nTries(i->rates, 2)
40610 | set11nTries(i->rates, 3)
40611 | (i->dur_update ? AR_DurUpdateEna : 0)
40612 | SM(0, AR_BurstDur);
40613
40614 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
40615 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
40616 | set11nRate(i->rates, 1)
40617 | set11nRate(i->rates, 2)
40618 | set11nRate(i->rates, 3);
40619 } else {
40620 - ACCESS_ONCE(ads->ctl13) = 0;
40621 - ACCESS_ONCE(ads->ctl14) = 0;
40622 + ACCESS_ONCE_RW(ads->ctl13) = 0;
40623 + ACCESS_ONCE_RW(ads->ctl14) = 0;
40624 }
40625
40626 ads->ctl20 = 0;
40627 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40628
40629 ctl17 = SM(i->keytype, AR_EncrType);
40630 if (!i->is_first) {
40631 - ACCESS_ONCE(ads->ctl11) = 0;
40632 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40633 - ACCESS_ONCE(ads->ctl15) = 0;
40634 - ACCESS_ONCE(ads->ctl16) = 0;
40635 - ACCESS_ONCE(ads->ctl17) = ctl17;
40636 - ACCESS_ONCE(ads->ctl18) = 0;
40637 - ACCESS_ONCE(ads->ctl19) = 0;
40638 + ACCESS_ONCE_RW(ads->ctl11) = 0;
40639 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40640 + ACCESS_ONCE_RW(ads->ctl15) = 0;
40641 + ACCESS_ONCE_RW(ads->ctl16) = 0;
40642 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40643 + ACCESS_ONCE_RW(ads->ctl18) = 0;
40644 + ACCESS_ONCE_RW(ads->ctl19) = 0;
40645 return;
40646 }
40647
40648 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40649 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40650 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40651 | SM(i->txpower, AR_XmitPower)
40652 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40653 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40654 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
40655 ctl12 |= SM(val, AR_PAPRDChainMask);
40656
40657 - ACCESS_ONCE(ads->ctl12) = ctl12;
40658 - ACCESS_ONCE(ads->ctl17) = ctl17;
40659 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
40660 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40661
40662 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40663 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40664 | set11nPktDurRTSCTS(i->rates, 1);
40665
40666 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40667 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40668 | set11nPktDurRTSCTS(i->rates, 3);
40669
40670 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
40671 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
40672 | set11nRateFlags(i->rates, 1)
40673 | set11nRateFlags(i->rates, 2)
40674 | set11nRateFlags(i->rates, 3)
40675 | SM(i->rtscts_rate, AR_RTSCTSRate);
40676
40677 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
40678 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
40679 }
40680
40681 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
40682 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
40683 index 9d26fc5..60d9f14 100644
40684 --- a/drivers/net/wireless/ath/ath9k/hw.h
40685 +++ b/drivers/net/wireless/ath/ath9k/hw.h
40686 @@ -658,7 +658,7 @@ struct ath_hw_private_ops {
40687
40688 /* ANI */
40689 void (*ani_cache_ini_regs)(struct ath_hw *ah);
40690 -};
40691 +} __no_const;
40692
40693 /**
40694 * struct ath_hw_ops - callbacks used by hardware code and driver code
40695 @@ -688,7 +688,7 @@ struct ath_hw_ops {
40696 void (*antdiv_comb_conf_set)(struct ath_hw *ah,
40697 struct ath_hw_antcomb_conf *antconf);
40698 void (*antctrl_shared_chain_lnadiv)(struct ath_hw *hw, bool enable);
40699 -};
40700 +} __no_const;
40701
40702 struct ath_nf_limits {
40703 s16 max;
40704 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
40705 index 3726cd6..b655808 100644
40706 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
40707 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
40708 @@ -3615,7 +3615,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40709 */
40710 if (il3945_mod_params.disable_hw_scan) {
40711 D_INFO("Disabling hw_scan\n");
40712 - il3945_mac_ops.hw_scan = NULL;
40713 + pax_open_kernel();
40714 + *(void **)&il3945_mac_ops.hw_scan = NULL;
40715 + pax_close_kernel();
40716 }
40717
40718 D_INFO("*** LOAD DRIVER ***\n");
40719 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40720 index 5b9533e..7733880 100644
40721 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40722 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40723 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
40724 {
40725 struct iwl_priv *priv = file->private_data;
40726 char buf[64];
40727 - int buf_size;
40728 + size_t buf_size;
40729 u32 offset, len;
40730
40731 memset(buf, 0, sizeof(buf));
40732 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
40733 struct iwl_priv *priv = file->private_data;
40734
40735 char buf[8];
40736 - int buf_size;
40737 + size_t buf_size;
40738 u32 reset_flag;
40739
40740 memset(buf, 0, sizeof(buf));
40741 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
40742 {
40743 struct iwl_priv *priv = file->private_data;
40744 char buf[8];
40745 - int buf_size;
40746 + size_t buf_size;
40747 int ht40;
40748
40749 memset(buf, 0, sizeof(buf));
40750 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
40751 {
40752 struct iwl_priv *priv = file->private_data;
40753 char buf[8];
40754 - int buf_size;
40755 + size_t buf_size;
40756 int value;
40757
40758 memset(buf, 0, sizeof(buf));
40759 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
40760 {
40761 struct iwl_priv *priv = file->private_data;
40762 char buf[8];
40763 - int buf_size;
40764 + size_t buf_size;
40765 int clear;
40766
40767 memset(buf, 0, sizeof(buf));
40768 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
40769 {
40770 struct iwl_priv *priv = file->private_data;
40771 char buf[8];
40772 - int buf_size;
40773 + size_t buf_size;
40774 int trace;
40775
40776 memset(buf, 0, sizeof(buf));
40777 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
40778 {
40779 struct iwl_priv *priv = file->private_data;
40780 char buf[8];
40781 - int buf_size;
40782 + size_t buf_size;
40783 int missed;
40784
40785 memset(buf, 0, sizeof(buf));
40786 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
40787
40788 struct iwl_priv *priv = file->private_data;
40789 char buf[8];
40790 - int buf_size;
40791 + size_t buf_size;
40792 int plcp;
40793
40794 memset(buf, 0, sizeof(buf));
40795 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
40796
40797 struct iwl_priv *priv = file->private_data;
40798 char buf[8];
40799 - int buf_size;
40800 + size_t buf_size;
40801 int flush;
40802
40803 memset(buf, 0, sizeof(buf));
40804 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
40805
40806 struct iwl_priv *priv = file->private_data;
40807 char buf[8];
40808 - int buf_size;
40809 + size_t buf_size;
40810 int rts;
40811
40812 if (!priv->cfg->ht_params)
40813 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
40814 {
40815 struct iwl_priv *priv = file->private_data;
40816 char buf[8];
40817 - int buf_size;
40818 + size_t buf_size;
40819
40820 memset(buf, 0, sizeof(buf));
40821 buf_size = min(count, sizeof(buf) - 1);
40822 @@ -2256,7 +2256,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
40823 struct iwl_priv *priv = file->private_data;
40824 u32 event_log_flag;
40825 char buf[8];
40826 - int buf_size;
40827 + size_t buf_size;
40828
40829 /* check that the interface is up */
40830 if (!iwl_is_ready(priv))
40831 @@ -2310,7 +2310,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
40832 struct iwl_priv *priv = file->private_data;
40833 char buf[8];
40834 u32 calib_disabled;
40835 - int buf_size;
40836 + size_t buf_size;
40837
40838 memset(buf, 0, sizeof(buf));
40839 buf_size = min(count, sizeof(buf) - 1);
40840 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
40841 index 35708b9..31f7754 100644
40842 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
40843 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
40844 @@ -1100,7 +1100,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
40845 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
40846
40847 char buf[8];
40848 - int buf_size;
40849 + size_t buf_size;
40850 u32 reset_flag;
40851
40852 memset(buf, 0, sizeof(buf));
40853 @@ -1121,7 +1121,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
40854 {
40855 struct iwl_trans *trans = file->private_data;
40856 char buf[8];
40857 - int buf_size;
40858 + size_t buf_size;
40859 int csr;
40860
40861 memset(buf, 0, sizeof(buf));
40862 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
40863 index ff90855..e46d223 100644
40864 --- a/drivers/net/wireless/mac80211_hwsim.c
40865 +++ b/drivers/net/wireless/mac80211_hwsim.c
40866 @@ -2062,25 +2062,19 @@ static int __init init_mac80211_hwsim(void)
40867
40868 if (channels > 1) {
40869 hwsim_if_comb.num_different_channels = channels;
40870 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40871 - mac80211_hwsim_ops.cancel_hw_scan =
40872 - mac80211_hwsim_cancel_hw_scan;
40873 - mac80211_hwsim_ops.sw_scan_start = NULL;
40874 - mac80211_hwsim_ops.sw_scan_complete = NULL;
40875 - mac80211_hwsim_ops.remain_on_channel =
40876 - mac80211_hwsim_roc;
40877 - mac80211_hwsim_ops.cancel_remain_on_channel =
40878 - mac80211_hwsim_croc;
40879 - mac80211_hwsim_ops.add_chanctx =
40880 - mac80211_hwsim_add_chanctx;
40881 - mac80211_hwsim_ops.remove_chanctx =
40882 - mac80211_hwsim_remove_chanctx;
40883 - mac80211_hwsim_ops.change_chanctx =
40884 - mac80211_hwsim_change_chanctx;
40885 - mac80211_hwsim_ops.assign_vif_chanctx =
40886 - mac80211_hwsim_assign_vif_chanctx;
40887 - mac80211_hwsim_ops.unassign_vif_chanctx =
40888 - mac80211_hwsim_unassign_vif_chanctx;
40889 + pax_open_kernel();
40890 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40891 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
40892 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
40893 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
40894 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
40895 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
40896 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
40897 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
40898 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
40899 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
40900 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
40901 + pax_close_kernel();
40902 }
40903
40904 spin_lock_init(&hwsim_radio_lock);
40905 diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
40906 index cdb11b3..3eca710 100644
40907 --- a/drivers/net/wireless/mwifiex/cfg80211.c
40908 +++ b/drivers/net/wireless/mwifiex/cfg80211.c
40909 @@ -1846,7 +1846,8 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy,
40910 }
40911 }
40912
40913 - for (i = 0; i < request->n_channels; i++) {
40914 + for (i = 0; i < min_t(u32, request->n_channels,
40915 + MWIFIEX_USER_SCAN_CHAN_MAX); i++) {
40916 chan = request->channels[i];
40917 priv->user_scan_cfg->chan_list[i].chan_number = chan->hw_value;
40918 priv->user_scan_cfg->chan_list[i].radio_type = chan->band;
40919 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
40920 index abe1d03..fb02c22 100644
40921 --- a/drivers/net/wireless/rndis_wlan.c
40922 +++ b/drivers/net/wireless/rndis_wlan.c
40923 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
40924
40925 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
40926
40927 - if (rts_threshold < 0 || rts_threshold > 2347)
40928 + if (rts_threshold > 2347)
40929 rts_threshold = 2347;
40930
40931 tmp = cpu_to_le32(rts_threshold);
40932 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
40933 index 0751b35..246ba3e 100644
40934 --- a/drivers/net/wireless/rt2x00/rt2x00.h
40935 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
40936 @@ -398,7 +398,7 @@ struct rt2x00_intf {
40937 * for hardware which doesn't support hardware
40938 * sequence counting.
40939 */
40940 - atomic_t seqno;
40941 + atomic_unchecked_t seqno;
40942 };
40943
40944 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
40945 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
40946 index e488b94..14b6a0c 100644
40947 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
40948 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
40949 @@ -240,9 +240,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
40950 * sequence counter given by mac80211.
40951 */
40952 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
40953 - seqno = atomic_add_return(0x10, &intf->seqno);
40954 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
40955 else
40956 - seqno = atomic_read(&intf->seqno);
40957 + seqno = atomic_read_unchecked(&intf->seqno);
40958
40959 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
40960 hdr->seq_ctrl |= cpu_to_le16(seqno);
40961 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
40962 index e57ee48..541cf6c 100644
40963 --- a/drivers/net/wireless/ti/wl1251/sdio.c
40964 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
40965 @@ -269,13 +269,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
40966
40967 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
40968
40969 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40970 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40971 + pax_open_kernel();
40972 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40973 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40974 + pax_close_kernel();
40975
40976 wl1251_info("using dedicated interrupt line");
40977 } else {
40978 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40979 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40980 + pax_open_kernel();
40981 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40982 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40983 + pax_close_kernel();
40984
40985 wl1251_info("using SDIO interrupt");
40986 }
40987 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
40988 index e5f5f8f..fdf15b7 100644
40989 --- a/drivers/net/wireless/ti/wl12xx/main.c
40990 +++ b/drivers/net/wireless/ti/wl12xx/main.c
40991 @@ -644,7 +644,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40992 sizeof(wl->conf.mem));
40993
40994 /* read data preparation is only needed by wl127x */
40995 - wl->ops->prepare_read = wl127x_prepare_read;
40996 + pax_open_kernel();
40997 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40998 + pax_close_kernel();
40999
41000 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
41001 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
41002 @@ -665,7 +667,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
41003 sizeof(wl->conf.mem));
41004
41005 /* read data preparation is only needed by wl127x */
41006 - wl->ops->prepare_read = wl127x_prepare_read;
41007 + pax_open_kernel();
41008 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
41009 + pax_close_kernel();
41010
41011 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
41012 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
41013 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
41014 index 8d8c1f8..e754844 100644
41015 --- a/drivers/net/wireless/ti/wl18xx/main.c
41016 +++ b/drivers/net/wireless/ti/wl18xx/main.c
41017 @@ -1489,8 +1489,10 @@ static int wl18xx_setup(struct wl1271 *wl)
41018 }
41019
41020 if (!checksum_param) {
41021 - wl18xx_ops.set_rx_csum = NULL;
41022 - wl18xx_ops.init_vif = NULL;
41023 + pax_open_kernel();
41024 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
41025 + *(void **)&wl18xx_ops.init_vif = NULL;
41026 + pax_close_kernel();
41027 }
41028
41029 /* Enable 11a Band only if we have 5G antennas */
41030 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
41031 index ef2b171..bb513a6 100644
41032 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
41033 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
41034 @@ -387,7 +387,7 @@ static inline void handle_regs_int(struct urb *urb)
41035 {
41036 struct zd_usb *usb = urb->context;
41037 struct zd_usb_interrupt *intr = &usb->intr;
41038 - int len;
41039 + unsigned int len;
41040 u16 int_num;
41041
41042 ZD_ASSERT(in_interrupt());
41043 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
41044 index d93b2b6..ae50401 100644
41045 --- a/drivers/oprofile/buffer_sync.c
41046 +++ b/drivers/oprofile/buffer_sync.c
41047 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
41048 if (cookie == NO_COOKIE)
41049 offset = pc;
41050 if (cookie == INVALID_COOKIE) {
41051 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41052 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41053 offset = pc;
41054 }
41055 if (cookie != last_cookie) {
41056 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
41057 /* add userspace sample */
41058
41059 if (!mm) {
41060 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
41061 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
41062 return 0;
41063 }
41064
41065 cookie = lookup_dcookie(mm, s->eip, &offset);
41066
41067 if (cookie == INVALID_COOKIE) {
41068 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41069 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41070 return 0;
41071 }
41072
41073 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
41074 /* ignore backtraces if failed to add a sample */
41075 if (state == sb_bt_start) {
41076 state = sb_bt_ignore;
41077 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
41078 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
41079 }
41080 }
41081 release_mm(mm);
41082 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
41083 index c0cc4e7..44d4e54 100644
41084 --- a/drivers/oprofile/event_buffer.c
41085 +++ b/drivers/oprofile/event_buffer.c
41086 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
41087 }
41088
41089 if (buffer_pos == buffer_size) {
41090 - atomic_inc(&oprofile_stats.event_lost_overflow);
41091 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
41092 return;
41093 }
41094
41095 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
41096 index ed2c3ec..deda85a 100644
41097 --- a/drivers/oprofile/oprof.c
41098 +++ b/drivers/oprofile/oprof.c
41099 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
41100 if (oprofile_ops.switch_events())
41101 return;
41102
41103 - atomic_inc(&oprofile_stats.multiplex_counter);
41104 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
41105 start_switch_worker();
41106 }
41107
41108 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
41109 index 84a208d..d61b0a1 100644
41110 --- a/drivers/oprofile/oprofile_files.c
41111 +++ b/drivers/oprofile/oprofile_files.c
41112 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
41113
41114 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
41115
41116 -static ssize_t timeout_read(struct file *file, char __user *buf,
41117 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
41118 size_t count, loff_t *offset)
41119 {
41120 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
41121 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
41122 index 917d28e..d62d981 100644
41123 --- a/drivers/oprofile/oprofile_stats.c
41124 +++ b/drivers/oprofile/oprofile_stats.c
41125 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
41126 cpu_buf->sample_invalid_eip = 0;
41127 }
41128
41129 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
41130 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
41131 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
41132 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
41133 - atomic_set(&oprofile_stats.multiplex_counter, 0);
41134 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
41135 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
41136 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
41137 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
41138 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
41139 }
41140
41141
41142 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
41143 index 38b6fc0..b5cbfce 100644
41144 --- a/drivers/oprofile/oprofile_stats.h
41145 +++ b/drivers/oprofile/oprofile_stats.h
41146 @@ -13,11 +13,11 @@
41147 #include <linux/atomic.h>
41148
41149 struct oprofile_stat_struct {
41150 - atomic_t sample_lost_no_mm;
41151 - atomic_t sample_lost_no_mapping;
41152 - atomic_t bt_lost_no_mapping;
41153 - atomic_t event_lost_overflow;
41154 - atomic_t multiplex_counter;
41155 + atomic_unchecked_t sample_lost_no_mm;
41156 + atomic_unchecked_t sample_lost_no_mapping;
41157 + atomic_unchecked_t bt_lost_no_mapping;
41158 + atomic_unchecked_t event_lost_overflow;
41159 + atomic_unchecked_t multiplex_counter;
41160 };
41161
41162 extern struct oprofile_stat_struct oprofile_stats;
41163 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
41164 index 849357c..b83c1e0 100644
41165 --- a/drivers/oprofile/oprofilefs.c
41166 +++ b/drivers/oprofile/oprofilefs.c
41167 @@ -185,7 +185,7 @@ static const struct file_operations atomic_ro_fops = {
41168
41169
41170 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
41171 - char const *name, atomic_t *val)
41172 + char const *name, atomic_unchecked_t *val)
41173 {
41174 return __oprofilefs_create_file(sb, root, name,
41175 &atomic_ro_fops, 0444, val);
41176 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
41177 index 93404f7..4a313d8 100644
41178 --- a/drivers/oprofile/timer_int.c
41179 +++ b/drivers/oprofile/timer_int.c
41180 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
41181 return NOTIFY_OK;
41182 }
41183
41184 -static struct notifier_block __refdata oprofile_cpu_notifier = {
41185 +static struct notifier_block oprofile_cpu_notifier = {
41186 .notifier_call = oprofile_cpu_notify,
41187 };
41188
41189 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
41190 index 3f56bc0..707d642 100644
41191 --- a/drivers/parport/procfs.c
41192 +++ b/drivers/parport/procfs.c
41193 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
41194
41195 *ppos += len;
41196
41197 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
41198 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
41199 }
41200
41201 #ifdef CONFIG_PARPORT_1284
41202 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
41203
41204 *ppos += len;
41205
41206 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
41207 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
41208 }
41209 #endif /* IEEE1284.3 support. */
41210
41211 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
41212 index c35e8ad..fc33beb 100644
41213 --- a/drivers/pci/hotplug/acpiphp_ibm.c
41214 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
41215 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
41216 goto init_cleanup;
41217 }
41218
41219 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41220 + pax_open_kernel();
41221 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41222 + pax_close_kernel();
41223 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
41224
41225 return retval;
41226 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
41227 index a6a71c4..c91097b 100644
41228 --- a/drivers/pci/hotplug/cpcihp_generic.c
41229 +++ b/drivers/pci/hotplug/cpcihp_generic.c
41230 @@ -73,7 +73,6 @@ static u16 port;
41231 static unsigned int enum_bit;
41232 static u8 enum_mask;
41233
41234 -static struct cpci_hp_controller_ops generic_hpc_ops;
41235 static struct cpci_hp_controller generic_hpc;
41236
41237 static int __init validate_parameters(void)
41238 @@ -139,6 +138,10 @@ static int query_enum(void)
41239 return ((value & enum_mask) == enum_mask);
41240 }
41241
41242 +static struct cpci_hp_controller_ops generic_hpc_ops = {
41243 + .query_enum = query_enum,
41244 +};
41245 +
41246 static int __init cpcihp_generic_init(void)
41247 {
41248 int status;
41249 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
41250 pci_dev_put(dev);
41251
41252 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
41253 - generic_hpc_ops.query_enum = query_enum;
41254 generic_hpc.ops = &generic_hpc_ops;
41255
41256 status = cpci_hp_register_controller(&generic_hpc);
41257 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
41258 index 449b4bb..257e2e8 100644
41259 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
41260 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
41261 @@ -59,7 +59,6 @@
41262 /* local variables */
41263 static bool debug;
41264 static bool poll;
41265 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
41266 static struct cpci_hp_controller zt5550_hpc;
41267
41268 /* Primary cPCI bus bridge device */
41269 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
41270 return 0;
41271 }
41272
41273 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
41274 + .query_enum = zt5550_hc_query_enum,
41275 +};
41276 +
41277 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
41278 {
41279 int status;
41280 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
41281 dbg("returned from zt5550_hc_config");
41282
41283 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
41284 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
41285 zt5550_hpc.ops = &zt5550_hpc_ops;
41286 if(!poll) {
41287 zt5550_hpc.irq = hc_dev->irq;
41288 zt5550_hpc.irq_flags = IRQF_SHARED;
41289 zt5550_hpc.dev_id = hc_dev;
41290
41291 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41292 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41293 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41294 + pax_open_kernel();
41295 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41296 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41297 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41298 + pax_open_kernel();
41299 } else {
41300 info("using ENUM# polling mode");
41301 }
41302 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
41303 index 76ba8a1..20ca857 100644
41304 --- a/drivers/pci/hotplug/cpqphp_nvram.c
41305 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
41306 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
41307
41308 void compaq_nvram_init (void __iomem *rom_start)
41309 {
41310 +
41311 +#ifndef CONFIG_PAX_KERNEXEC
41312 if (rom_start) {
41313 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
41314 }
41315 +#endif
41316 +
41317 dbg("int15 entry = %p\n", compaq_int15_entry_point);
41318
41319 /* initialize our int15 lock */
41320 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
41321 index 202f4a9..8ee47d0 100644
41322 --- a/drivers/pci/hotplug/pci_hotplug_core.c
41323 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
41324 @@ -448,8 +448,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
41325 return -EINVAL;
41326 }
41327
41328 - slot->ops->owner = owner;
41329 - slot->ops->mod_name = mod_name;
41330 + pax_open_kernel();
41331 + *(struct module **)&slot->ops->owner = owner;
41332 + *(const char **)&slot->ops->mod_name = mod_name;
41333 + pax_close_kernel();
41334
41335 mutex_lock(&pci_hp_mutex);
41336 /*
41337 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
41338 index 939bd1d..a1459c9 100644
41339 --- a/drivers/pci/hotplug/pciehp_core.c
41340 +++ b/drivers/pci/hotplug/pciehp_core.c
41341 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
41342 struct slot *slot = ctrl->slot;
41343 struct hotplug_slot *hotplug = NULL;
41344 struct hotplug_slot_info *info = NULL;
41345 - struct hotplug_slot_ops *ops = NULL;
41346 + hotplug_slot_ops_no_const *ops = NULL;
41347 char name[SLOT_NAME_SIZE];
41348 int retval = -ENOMEM;
41349
41350 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
41351 index 9c6e9bb..2916736 100644
41352 --- a/drivers/pci/pci-sysfs.c
41353 +++ b/drivers/pci/pci-sysfs.c
41354 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
41355 {
41356 /* allocate attribute structure, piggyback attribute name */
41357 int name_len = write_combine ? 13 : 10;
41358 - struct bin_attribute *res_attr;
41359 + bin_attribute_no_const *res_attr;
41360 int retval;
41361
41362 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
41363 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
41364 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
41365 {
41366 int retval;
41367 - struct bin_attribute *attr;
41368 + bin_attribute_no_const *attr;
41369
41370 /* If the device has VPD, try to expose it in sysfs. */
41371 if (dev->vpd) {
41372 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
41373 {
41374 int retval;
41375 int rom_size = 0;
41376 - struct bin_attribute *attr;
41377 + bin_attribute_no_const *attr;
41378
41379 if (!sysfs_initialized)
41380 return -EACCES;
41381 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
41382 index e851829..a1a7196 100644
41383 --- a/drivers/pci/pci.h
41384 +++ b/drivers/pci/pci.h
41385 @@ -98,7 +98,7 @@ struct pci_vpd_ops {
41386 struct pci_vpd {
41387 unsigned int len;
41388 const struct pci_vpd_ops *ops;
41389 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
41390 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
41391 };
41392
41393 extern int pci_vpd_pci22_init(struct pci_dev *dev);
41394 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
41395 index 8474b6a..ee81993 100644
41396 --- a/drivers/pci/pcie/aspm.c
41397 +++ b/drivers/pci/pcie/aspm.c
41398 @@ -27,9 +27,9 @@
41399 #define MODULE_PARAM_PREFIX "pcie_aspm."
41400
41401 /* Note: those are not register definitions */
41402 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
41403 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
41404 -#define ASPM_STATE_L1 (4) /* L1 state */
41405 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
41406 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
41407 +#define ASPM_STATE_L1 (4U) /* L1 state */
41408 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
41409 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
41410
41411 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
41412 index 6186f03..1a78714 100644
41413 --- a/drivers/pci/probe.c
41414 +++ b/drivers/pci/probe.c
41415 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
41416 struct pci_bus_region region;
41417 bool bar_too_big = false, bar_disabled = false;
41418
41419 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
41420 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
41421
41422 /* No printks while decoding is disabled! */
41423 if (!dev->mmio_always_on) {
41424 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
41425 index 9b8505c..f00870a 100644
41426 --- a/drivers/pci/proc.c
41427 +++ b/drivers/pci/proc.c
41428 @@ -465,7 +465,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
41429 static int __init pci_proc_init(void)
41430 {
41431 struct pci_dev *dev = NULL;
41432 +
41433 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
41434 +#ifdef CONFIG_GRKERNSEC_PROC_USER
41435 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
41436 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
41437 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
41438 +#endif
41439 +#else
41440 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
41441 +#endif
41442 proc_create("devices", 0, proc_bus_pci_dir,
41443 &proc_bus_pci_dev_operations);
41444 proc_initialized = 1;
41445 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
41446 index 2111dbb..79e434b 100644
41447 --- a/drivers/platform/x86/msi-laptop.c
41448 +++ b/drivers/platform/x86/msi-laptop.c
41449 @@ -820,12 +820,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
41450 int result;
41451
41452 /* allow userland write sysfs file */
41453 - dev_attr_bluetooth.store = store_bluetooth;
41454 - dev_attr_wlan.store = store_wlan;
41455 - dev_attr_threeg.store = store_threeg;
41456 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
41457 - dev_attr_wlan.attr.mode |= S_IWUSR;
41458 - dev_attr_threeg.attr.mode |= S_IWUSR;
41459 + pax_open_kernel();
41460 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
41461 + *(void **)&dev_attr_wlan.store = store_wlan;
41462 + *(void **)&dev_attr_threeg.store = store_threeg;
41463 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
41464 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
41465 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
41466 + pax_close_kernel();
41467
41468 /* disable hardware control by fn key */
41469 result = ec_read(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, &data);
41470 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
41471 index 0fe987f..6f3d5c3 100644
41472 --- a/drivers/platform/x86/sony-laptop.c
41473 +++ b/drivers/platform/x86/sony-laptop.c
41474 @@ -2356,7 +2356,7 @@ static void sony_nc_lid_resume_cleanup(struct platform_device *pd)
41475 }
41476
41477 /* High speed charging function */
41478 -static struct device_attribute *hsc_handle;
41479 +static device_attribute_no_const *hsc_handle;
41480
41481 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
41482 struct device_attribute *attr,
41483 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
41484 index f946ca7..f25c833 100644
41485 --- a/drivers/platform/x86/thinkpad_acpi.c
41486 +++ b/drivers/platform/x86/thinkpad_acpi.c
41487 @@ -2097,7 +2097,7 @@ static int hotkey_mask_get(void)
41488 return 0;
41489 }
41490
41491 -void static hotkey_mask_warn_incomplete_mask(void)
41492 +static void hotkey_mask_warn_incomplete_mask(void)
41493 {
41494 /* log only what the user can fix... */
41495 const u32 wantedmask = hotkey_driver_mask &
41496 @@ -2328,11 +2328,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
41497 }
41498 }
41499
41500 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41501 - struct tp_nvram_state *newn,
41502 - const u32 event_mask)
41503 -{
41504 -
41505 #define TPACPI_COMPARE_KEY(__scancode, __member) \
41506 do { \
41507 if ((event_mask & (1 << __scancode)) && \
41508 @@ -2346,36 +2341,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41509 tpacpi_hotkey_send_key(__scancode); \
41510 } while (0)
41511
41512 - void issue_volchange(const unsigned int oldvol,
41513 - const unsigned int newvol)
41514 - {
41515 - unsigned int i = oldvol;
41516 +static void issue_volchange(const unsigned int oldvol,
41517 + const unsigned int newvol,
41518 + const u32 event_mask)
41519 +{
41520 + unsigned int i = oldvol;
41521
41522 - while (i > newvol) {
41523 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41524 - i--;
41525 - }
41526 - while (i < newvol) {
41527 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41528 - i++;
41529 - }
41530 + while (i > newvol) {
41531 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41532 + i--;
41533 }
41534 + while (i < newvol) {
41535 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41536 + i++;
41537 + }
41538 +}
41539
41540 - void issue_brightnesschange(const unsigned int oldbrt,
41541 - const unsigned int newbrt)
41542 - {
41543 - unsigned int i = oldbrt;
41544 +static void issue_brightnesschange(const unsigned int oldbrt,
41545 + const unsigned int newbrt,
41546 + const u32 event_mask)
41547 +{
41548 + unsigned int i = oldbrt;
41549
41550 - while (i > newbrt) {
41551 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41552 - i--;
41553 - }
41554 - while (i < newbrt) {
41555 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41556 - i++;
41557 - }
41558 + while (i > newbrt) {
41559 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41560 + i--;
41561 + }
41562 + while (i < newbrt) {
41563 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41564 + i++;
41565 }
41566 +}
41567
41568 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41569 + struct tp_nvram_state *newn,
41570 + const u32 event_mask)
41571 +{
41572 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
41573 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
41574 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
41575 @@ -2409,7 +2410,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41576 oldn->volume_level != newn->volume_level) {
41577 /* recently muted, or repeated mute keypress, or
41578 * multiple presses ending in mute */
41579 - issue_volchange(oldn->volume_level, newn->volume_level);
41580 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41581 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
41582 }
41583 } else {
41584 @@ -2419,7 +2420,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41585 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41586 }
41587 if (oldn->volume_level != newn->volume_level) {
41588 - issue_volchange(oldn->volume_level, newn->volume_level);
41589 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41590 } else if (oldn->volume_toggle != newn->volume_toggle) {
41591 /* repeated vol up/down keypress at end of scale ? */
41592 if (newn->volume_level == 0)
41593 @@ -2432,7 +2433,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41594 /* handle brightness */
41595 if (oldn->brightness_level != newn->brightness_level) {
41596 issue_brightnesschange(oldn->brightness_level,
41597 - newn->brightness_level);
41598 + newn->brightness_level,
41599 + event_mask);
41600 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
41601 /* repeated key presses that didn't change state */
41602 if (newn->brightness_level == 0)
41603 @@ -2441,10 +2443,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41604 && !tp_features.bright_unkfw)
41605 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41606 }
41607 +}
41608
41609 #undef TPACPI_COMPARE_KEY
41610 #undef TPACPI_MAY_SEND_KEY
41611 -}
41612
41613 /*
41614 * Polling driver
41615 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
41616 index 769d265..a3a05ca 100644
41617 --- a/drivers/pnp/pnpbios/bioscalls.c
41618 +++ b/drivers/pnp/pnpbios/bioscalls.c
41619 @@ -58,7 +58,7 @@ do { \
41620 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
41621 } while(0)
41622
41623 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
41624 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
41625 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
41626
41627 /*
41628 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41629
41630 cpu = get_cpu();
41631 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
41632 +
41633 + pax_open_kernel();
41634 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
41635 + pax_close_kernel();
41636
41637 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
41638 spin_lock_irqsave(&pnp_bios_lock, flags);
41639 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41640 :"memory");
41641 spin_unlock_irqrestore(&pnp_bios_lock, flags);
41642
41643 + pax_open_kernel();
41644 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
41645 + pax_close_kernel();
41646 +
41647 put_cpu();
41648
41649 /* If we get here and this is set then the PnP BIOS faulted on us. */
41650 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
41651 return status;
41652 }
41653
41654 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
41655 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
41656 {
41657 int i;
41658
41659 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41660 pnp_bios_callpoint.offset = header->fields.pm16offset;
41661 pnp_bios_callpoint.segment = PNP_CS16;
41662
41663 + pax_open_kernel();
41664 +
41665 for_each_possible_cpu(i) {
41666 struct desc_struct *gdt = get_cpu_gdt_table(i);
41667 if (!gdt)
41668 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41669 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
41670 (unsigned long)__va(header->fields.pm16dseg));
41671 }
41672 +
41673 + pax_close_kernel();
41674 }
41675 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
41676 index 3e6db1c..1fbbdae 100644
41677 --- a/drivers/pnp/resource.c
41678 +++ b/drivers/pnp/resource.c
41679 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
41680 return 1;
41681
41682 /* check if the resource is valid */
41683 - if (*irq < 0 || *irq > 15)
41684 + if (*irq > 15)
41685 return 0;
41686
41687 /* check if the resource is reserved */
41688 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
41689 return 1;
41690
41691 /* check if the resource is valid */
41692 - if (*dma < 0 || *dma == 4 || *dma > 7)
41693 + if (*dma == 4 || *dma > 7)
41694 return 0;
41695
41696 /* check if the resource is reserved */
41697 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
41698 index 7df7c5f..bd48c47 100644
41699 --- a/drivers/power/pda_power.c
41700 +++ b/drivers/power/pda_power.c
41701 @@ -37,7 +37,11 @@ static int polling;
41702
41703 #ifdef CONFIG_USB_OTG_UTILS
41704 static struct usb_phy *transceiver;
41705 -static struct notifier_block otg_nb;
41706 +static int otg_handle_notification(struct notifier_block *nb,
41707 + unsigned long event, void *unused);
41708 +static struct notifier_block otg_nb = {
41709 + .notifier_call = otg_handle_notification
41710 +};
41711 #endif
41712
41713 static struct regulator *ac_draw;
41714 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
41715
41716 #ifdef CONFIG_USB_OTG_UTILS
41717 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
41718 - otg_nb.notifier_call = otg_handle_notification;
41719 ret = usb_register_notifier(transceiver, &otg_nb);
41720 if (ret) {
41721 dev_err(dev, "failure to register otg notifier\n");
41722 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
41723 index cc439fd..8fa30df 100644
41724 --- a/drivers/power/power_supply.h
41725 +++ b/drivers/power/power_supply.h
41726 @@ -16,12 +16,12 @@ struct power_supply;
41727
41728 #ifdef CONFIG_SYSFS
41729
41730 -extern void power_supply_init_attrs(struct device_type *dev_type);
41731 +extern void power_supply_init_attrs(void);
41732 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
41733
41734 #else
41735
41736 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
41737 +static inline void power_supply_init_attrs(void) {}
41738 #define power_supply_uevent NULL
41739
41740 #endif /* CONFIG_SYSFS */
41741 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
41742 index 8a7cfb3..72e6e9b 100644
41743 --- a/drivers/power/power_supply_core.c
41744 +++ b/drivers/power/power_supply_core.c
41745 @@ -24,7 +24,10 @@
41746 struct class *power_supply_class;
41747 EXPORT_SYMBOL_GPL(power_supply_class);
41748
41749 -static struct device_type power_supply_dev_type;
41750 +extern const struct attribute_group *power_supply_attr_groups[];
41751 +static struct device_type power_supply_dev_type = {
41752 + .groups = power_supply_attr_groups,
41753 +};
41754
41755 static int __power_supply_changed_work(struct device *dev, void *data)
41756 {
41757 @@ -393,7 +396,7 @@ static int __init power_supply_class_init(void)
41758 return PTR_ERR(power_supply_class);
41759
41760 power_supply_class->dev_uevent = power_supply_uevent;
41761 - power_supply_init_attrs(&power_supply_dev_type);
41762 + power_supply_init_attrs();
41763
41764 return 0;
41765 }
41766 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
41767 index 40fa3b7..d9c2e0e 100644
41768 --- a/drivers/power/power_supply_sysfs.c
41769 +++ b/drivers/power/power_supply_sysfs.c
41770 @@ -229,17 +229,15 @@ static struct attribute_group power_supply_attr_group = {
41771 .is_visible = power_supply_attr_is_visible,
41772 };
41773
41774 -static const struct attribute_group *power_supply_attr_groups[] = {
41775 +const struct attribute_group *power_supply_attr_groups[] = {
41776 &power_supply_attr_group,
41777 NULL,
41778 };
41779
41780 -void power_supply_init_attrs(struct device_type *dev_type)
41781 +void power_supply_init_attrs(void)
41782 {
41783 int i;
41784
41785 - dev_type->groups = power_supply_attr_groups;
41786 -
41787 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
41788 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
41789 }
41790 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
41791 index 4d7c635..9860196 100644
41792 --- a/drivers/regulator/max8660.c
41793 +++ b/drivers/regulator/max8660.c
41794 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
41795 max8660->shadow_regs[MAX8660_OVER1] = 5;
41796 } else {
41797 /* Otherwise devices can be toggled via software */
41798 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
41799 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
41800 + pax_open_kernel();
41801 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
41802 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
41803 + pax_close_kernel();
41804 }
41805
41806 /*
41807 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
41808 index 9a8ea91..c483dd9 100644
41809 --- a/drivers/regulator/max8973-regulator.c
41810 +++ b/drivers/regulator/max8973-regulator.c
41811 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
41812 if (!pdata->enable_ext_control) {
41813 max->desc.enable_reg = MAX8973_VOUT;
41814 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
41815 - max8973_dcdc_ops.enable = regulator_enable_regmap;
41816 - max8973_dcdc_ops.disable = regulator_disable_regmap;
41817 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41818 + pax_open_kernel();
41819 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
41820 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
41821 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41822 + pax_close_kernel();
41823 }
41824
41825 max->enable_external_control = pdata->enable_ext_control;
41826 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
41827 index 0d84b1f..c2da6ac 100644
41828 --- a/drivers/regulator/mc13892-regulator.c
41829 +++ b/drivers/regulator/mc13892-regulator.c
41830 @@ -540,10 +540,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
41831 }
41832 mc13xxx_unlock(mc13892);
41833
41834 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41835 + pax_open_kernel();
41836 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41837 = mc13892_vcam_set_mode;
41838 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41839 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41840 = mc13892_vcam_get_mode;
41841 + pax_close_kernel();
41842
41843 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
41844 ARRAY_SIZE(mc13892_regulators));
41845 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
41846 index 16630aa..6afc992 100644
41847 --- a/drivers/rtc/rtc-cmos.c
41848 +++ b/drivers/rtc/rtc-cmos.c
41849 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
41850 hpet_rtc_timer_init();
41851
41852 /* export at least the first block of NVRAM */
41853 - nvram.size = address_space - NVRAM_OFFSET;
41854 + pax_open_kernel();
41855 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
41856 + pax_close_kernel();
41857 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
41858 if (retval < 0) {
41859 dev_dbg(dev, "can't create nvram file? %d\n", retval);
41860 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
41861 index 9a86b4b..3a383dc 100644
41862 --- a/drivers/rtc/rtc-dev.c
41863 +++ b/drivers/rtc/rtc-dev.c
41864 @@ -14,6 +14,7 @@
41865 #include <linux/module.h>
41866 #include <linux/rtc.h>
41867 #include <linux/sched.h>
41868 +#include <linux/grsecurity.h>
41869 #include "rtc-core.h"
41870
41871 static dev_t rtc_devt;
41872 @@ -345,6 +346,8 @@ static long rtc_dev_ioctl(struct file *file,
41873 if (copy_from_user(&tm, uarg, sizeof(tm)))
41874 return -EFAULT;
41875
41876 + gr_log_timechange();
41877 +
41878 return rtc_set_time(rtc, &tm);
41879
41880 case RTC_PIE_ON:
41881 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
41882 index e0d0ba4..3c65868 100644
41883 --- a/drivers/rtc/rtc-ds1307.c
41884 +++ b/drivers/rtc/rtc-ds1307.c
41885 @@ -106,7 +106,7 @@ struct ds1307 {
41886 u8 offset; /* register's offset */
41887 u8 regs[11];
41888 u16 nvram_offset;
41889 - struct bin_attribute *nvram;
41890 + bin_attribute_no_const *nvram;
41891 enum ds_type type;
41892 unsigned long flags;
41893 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
41894 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
41895 index 130f29a..6179d03 100644
41896 --- a/drivers/rtc/rtc-m48t59.c
41897 +++ b/drivers/rtc/rtc-m48t59.c
41898 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
41899 goto out;
41900 }
41901
41902 - m48t59_nvram_attr.size = pdata->offset;
41903 + pax_open_kernel();
41904 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
41905 + pax_close_kernel();
41906
41907 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
41908 if (ret) {
41909 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
41910 index e693af6..2e525b6 100644
41911 --- a/drivers/scsi/bfa/bfa_fcpim.h
41912 +++ b/drivers/scsi/bfa/bfa_fcpim.h
41913 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
41914
41915 struct bfa_itn_s {
41916 bfa_isr_func_t isr;
41917 -};
41918 +} __no_const;
41919
41920 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
41921 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
41922 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
41923 index 23a90e7..9cf04ee 100644
41924 --- a/drivers/scsi/bfa/bfa_ioc.h
41925 +++ b/drivers/scsi/bfa/bfa_ioc.h
41926 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
41927 bfa_ioc_disable_cbfn_t disable_cbfn;
41928 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
41929 bfa_ioc_reset_cbfn_t reset_cbfn;
41930 -};
41931 +} __no_const;
41932
41933 /*
41934 * IOC event notification mechanism.
41935 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
41936 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
41937 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
41938 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
41939 -};
41940 +} __no_const;
41941
41942 /*
41943 * Queue element to wait for room in request queue. FIFO order is
41944 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
41945 index 593085a..47aa999 100644
41946 --- a/drivers/scsi/hosts.c
41947 +++ b/drivers/scsi/hosts.c
41948 @@ -42,7 +42,7 @@
41949 #include "scsi_logging.h"
41950
41951
41952 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41953 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41954
41955
41956 static void scsi_host_cls_release(struct device *dev)
41957 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
41958 * subtract one because we increment first then return, but we need to
41959 * know what the next host number was before increment
41960 */
41961 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
41962 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
41963 shost->dma_channel = 0xff;
41964
41965 /* These three are default values which can be overridden */
41966 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
41967 index 4f33806..afd6f60 100644
41968 --- a/drivers/scsi/hpsa.c
41969 +++ b/drivers/scsi/hpsa.c
41970 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
41971 unsigned long flags;
41972
41973 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
41974 - return h->access.command_completed(h, q);
41975 + return h->access->command_completed(h, q);
41976
41977 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
41978 a = rq->head[rq->current_entry];
41979 @@ -3374,7 +3374,7 @@ static void start_io(struct ctlr_info *h)
41980 while (!list_empty(&h->reqQ)) {
41981 c = list_entry(h->reqQ.next, struct CommandList, list);
41982 /* can't do anything if fifo is full */
41983 - if ((h->access.fifo_full(h))) {
41984 + if ((h->access->fifo_full(h))) {
41985 dev_warn(&h->pdev->dev, "fifo full\n");
41986 break;
41987 }
41988 @@ -3396,7 +3396,7 @@ static void start_io(struct ctlr_info *h)
41989
41990 /* Tell the controller execute command */
41991 spin_unlock_irqrestore(&h->lock, flags);
41992 - h->access.submit_command(h, c);
41993 + h->access->submit_command(h, c);
41994 spin_lock_irqsave(&h->lock, flags);
41995 }
41996 spin_unlock_irqrestore(&h->lock, flags);
41997 @@ -3404,17 +3404,17 @@ static void start_io(struct ctlr_info *h)
41998
41999 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
42000 {
42001 - return h->access.command_completed(h, q);
42002 + return h->access->command_completed(h, q);
42003 }
42004
42005 static inline bool interrupt_pending(struct ctlr_info *h)
42006 {
42007 - return h->access.intr_pending(h);
42008 + return h->access->intr_pending(h);
42009 }
42010
42011 static inline long interrupt_not_for_us(struct ctlr_info *h)
42012 {
42013 - return (h->access.intr_pending(h) == 0) ||
42014 + return (h->access->intr_pending(h) == 0) ||
42015 (h->interrupts_enabled == 0);
42016 }
42017
42018 @@ -4316,7 +4316,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
42019 if (prod_index < 0)
42020 return -ENODEV;
42021 h->product_name = products[prod_index].product_name;
42022 - h->access = *(products[prod_index].access);
42023 + h->access = products[prod_index].access;
42024
42025 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
42026 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
42027 @@ -4598,7 +4598,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
42028
42029 assert_spin_locked(&lockup_detector_lock);
42030 remove_ctlr_from_lockup_detector_list(h);
42031 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42032 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42033 spin_lock_irqsave(&h->lock, flags);
42034 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
42035 spin_unlock_irqrestore(&h->lock, flags);
42036 @@ -4775,7 +4775,7 @@ reinit_after_soft_reset:
42037 }
42038
42039 /* make sure the board interrupts are off */
42040 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42041 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42042
42043 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
42044 goto clean2;
42045 @@ -4809,7 +4809,7 @@ reinit_after_soft_reset:
42046 * fake ones to scoop up any residual completions.
42047 */
42048 spin_lock_irqsave(&h->lock, flags);
42049 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42050 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42051 spin_unlock_irqrestore(&h->lock, flags);
42052 free_irqs(h);
42053 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
42054 @@ -4828,9 +4828,9 @@ reinit_after_soft_reset:
42055 dev_info(&h->pdev->dev, "Board READY.\n");
42056 dev_info(&h->pdev->dev,
42057 "Waiting for stale completions to drain.\n");
42058 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42059 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42060 msleep(10000);
42061 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42062 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42063
42064 rc = controller_reset_failed(h->cfgtable);
42065 if (rc)
42066 @@ -4851,7 +4851,7 @@ reinit_after_soft_reset:
42067 }
42068
42069 /* Turn the interrupts on so we can service requests */
42070 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42071 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42072
42073 hpsa_hba_inquiry(h);
42074 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
42075 @@ -4903,7 +4903,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
42076 * To write all data in the battery backed cache to disks
42077 */
42078 hpsa_flush_cache(h);
42079 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42080 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42081 hpsa_free_irqs_and_disable_msix(h);
42082 }
42083
42084 @@ -5071,7 +5071,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
42085 return;
42086 }
42087 /* Change the access methods to the performant access methods */
42088 - h->access = SA5_performant_access;
42089 + h->access = &SA5_performant_access;
42090 h->transMethod = CFGTBL_Trans_Performant;
42091 }
42092
42093 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
42094 index 9816479..c5d4e97 100644
42095 --- a/drivers/scsi/hpsa.h
42096 +++ b/drivers/scsi/hpsa.h
42097 @@ -79,7 +79,7 @@ struct ctlr_info {
42098 unsigned int msix_vector;
42099 unsigned int msi_vector;
42100 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
42101 - struct access_method access;
42102 + struct access_method *access;
42103
42104 /* queue and queue Info */
42105 struct list_head reqQ;
42106 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
42107 index c772d8d..35c362c 100644
42108 --- a/drivers/scsi/libfc/fc_exch.c
42109 +++ b/drivers/scsi/libfc/fc_exch.c
42110 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
42111 u16 pool_max_index;
42112
42113 struct {
42114 - atomic_t no_free_exch;
42115 - atomic_t no_free_exch_xid;
42116 - atomic_t xid_not_found;
42117 - atomic_t xid_busy;
42118 - atomic_t seq_not_found;
42119 - atomic_t non_bls_resp;
42120 + atomic_unchecked_t no_free_exch;
42121 + atomic_unchecked_t no_free_exch_xid;
42122 + atomic_unchecked_t xid_not_found;
42123 + atomic_unchecked_t xid_busy;
42124 + atomic_unchecked_t seq_not_found;
42125 + atomic_unchecked_t non_bls_resp;
42126 } stats;
42127 };
42128
42129 @@ -725,7 +725,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
42130 /* allocate memory for exchange */
42131 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
42132 if (!ep) {
42133 - atomic_inc(&mp->stats.no_free_exch);
42134 + atomic_inc_unchecked(&mp->stats.no_free_exch);
42135 goto out;
42136 }
42137 memset(ep, 0, sizeof(*ep));
42138 @@ -786,7 +786,7 @@ out:
42139 return ep;
42140 err:
42141 spin_unlock_bh(&pool->lock);
42142 - atomic_inc(&mp->stats.no_free_exch_xid);
42143 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
42144 mempool_free(ep, mp->ep_pool);
42145 return NULL;
42146 }
42147 @@ -929,7 +929,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42148 xid = ntohs(fh->fh_ox_id); /* we originated exch */
42149 ep = fc_exch_find(mp, xid);
42150 if (!ep) {
42151 - atomic_inc(&mp->stats.xid_not_found);
42152 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42153 reject = FC_RJT_OX_ID;
42154 goto out;
42155 }
42156 @@ -959,7 +959,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42157 ep = fc_exch_find(mp, xid);
42158 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
42159 if (ep) {
42160 - atomic_inc(&mp->stats.xid_busy);
42161 + atomic_inc_unchecked(&mp->stats.xid_busy);
42162 reject = FC_RJT_RX_ID;
42163 goto rel;
42164 }
42165 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42166 }
42167 xid = ep->xid; /* get our XID */
42168 } else if (!ep) {
42169 - atomic_inc(&mp->stats.xid_not_found);
42170 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42171 reject = FC_RJT_RX_ID; /* XID not found */
42172 goto out;
42173 }
42174 @@ -987,7 +987,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42175 } else {
42176 sp = &ep->seq;
42177 if (sp->id != fh->fh_seq_id) {
42178 - atomic_inc(&mp->stats.seq_not_found);
42179 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42180 if (f_ctl & FC_FC_END_SEQ) {
42181 /*
42182 * Update sequence_id based on incoming last
42183 @@ -1437,22 +1437,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42184
42185 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
42186 if (!ep) {
42187 - atomic_inc(&mp->stats.xid_not_found);
42188 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42189 goto out;
42190 }
42191 if (ep->esb_stat & ESB_ST_COMPLETE) {
42192 - atomic_inc(&mp->stats.xid_not_found);
42193 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42194 goto rel;
42195 }
42196 if (ep->rxid == FC_XID_UNKNOWN)
42197 ep->rxid = ntohs(fh->fh_rx_id);
42198 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
42199 - atomic_inc(&mp->stats.xid_not_found);
42200 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42201 goto rel;
42202 }
42203 if (ep->did != ntoh24(fh->fh_s_id) &&
42204 ep->did != FC_FID_FLOGI) {
42205 - atomic_inc(&mp->stats.xid_not_found);
42206 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42207 goto rel;
42208 }
42209 sof = fr_sof(fp);
42210 @@ -1461,7 +1461,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42211 sp->ssb_stat |= SSB_ST_RESP;
42212 sp->id = fh->fh_seq_id;
42213 } else if (sp->id != fh->fh_seq_id) {
42214 - atomic_inc(&mp->stats.seq_not_found);
42215 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42216 goto rel;
42217 }
42218
42219 @@ -1525,9 +1525,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42220 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
42221
42222 if (!sp)
42223 - atomic_inc(&mp->stats.xid_not_found);
42224 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42225 else
42226 - atomic_inc(&mp->stats.non_bls_resp);
42227 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
42228
42229 fc_frame_free(fp);
42230 }
42231 @@ -2174,13 +2174,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
42232
42233 list_for_each_entry(ema, &lport->ema_list, ema_list) {
42234 mp = ema->mp;
42235 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
42236 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
42237 st->fc_no_free_exch_xid +=
42238 - atomic_read(&mp->stats.no_free_exch_xid);
42239 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
42240 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
42241 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
42242 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
42243 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
42244 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
42245 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
42246 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
42247 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
42248 }
42249 }
42250 EXPORT_SYMBOL(fc_exch_update_stats);
42251 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
42252 index bdb81cd..d3c7c2c 100644
42253 --- a/drivers/scsi/libsas/sas_ata.c
42254 +++ b/drivers/scsi/libsas/sas_ata.c
42255 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
42256 .postreset = ata_std_postreset,
42257 .error_handler = ata_std_error_handler,
42258 .post_internal_cmd = sas_ata_post_internal,
42259 - .qc_defer = ata_std_qc_defer,
42260 + .qc_defer = ata_std_qc_defer,
42261 .qc_prep = ata_noop_qc_prep,
42262 .qc_issue = sas_ata_qc_issue,
42263 .qc_fill_rtf = sas_ata_qc_fill_rtf,
42264 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
42265 index df4c13a..a51e90c 100644
42266 --- a/drivers/scsi/lpfc/lpfc.h
42267 +++ b/drivers/scsi/lpfc/lpfc.h
42268 @@ -424,7 +424,7 @@ struct lpfc_vport {
42269 struct dentry *debug_nodelist;
42270 struct dentry *vport_debugfs_root;
42271 struct lpfc_debugfs_trc *disc_trc;
42272 - atomic_t disc_trc_cnt;
42273 + atomic_unchecked_t disc_trc_cnt;
42274 #endif
42275 uint8_t stat_data_enabled;
42276 uint8_t stat_data_blocked;
42277 @@ -842,8 +842,8 @@ struct lpfc_hba {
42278 struct timer_list fabric_block_timer;
42279 unsigned long bit_flags;
42280 #define FABRIC_COMANDS_BLOCKED 0
42281 - atomic_t num_rsrc_err;
42282 - atomic_t num_cmd_success;
42283 + atomic_unchecked_t num_rsrc_err;
42284 + atomic_unchecked_t num_cmd_success;
42285 unsigned long last_rsrc_error_time;
42286 unsigned long last_ramp_down_time;
42287 unsigned long last_ramp_up_time;
42288 @@ -879,7 +879,7 @@ struct lpfc_hba {
42289
42290 struct dentry *debug_slow_ring_trc;
42291 struct lpfc_debugfs_trc *slow_ring_trc;
42292 - atomic_t slow_ring_trc_cnt;
42293 + atomic_unchecked_t slow_ring_trc_cnt;
42294 /* iDiag debugfs sub-directory */
42295 struct dentry *idiag_root;
42296 struct dentry *idiag_pci_cfg;
42297 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
42298 index f63f5ff..de29189 100644
42299 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
42300 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
42301 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
42302
42303 #include <linux/debugfs.h>
42304
42305 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42306 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42307 static unsigned long lpfc_debugfs_start_time = 0L;
42308
42309 /* iDiag */
42310 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
42311 lpfc_debugfs_enable = 0;
42312
42313 len = 0;
42314 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
42315 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
42316 (lpfc_debugfs_max_disc_trc - 1);
42317 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
42318 dtp = vport->disc_trc + i;
42319 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
42320 lpfc_debugfs_enable = 0;
42321
42322 len = 0;
42323 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
42324 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
42325 (lpfc_debugfs_max_slow_ring_trc - 1);
42326 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
42327 dtp = phba->slow_ring_trc + i;
42328 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
42329 !vport || !vport->disc_trc)
42330 return;
42331
42332 - index = atomic_inc_return(&vport->disc_trc_cnt) &
42333 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
42334 (lpfc_debugfs_max_disc_trc - 1);
42335 dtp = vport->disc_trc + index;
42336 dtp->fmt = fmt;
42337 dtp->data1 = data1;
42338 dtp->data2 = data2;
42339 dtp->data3 = data3;
42340 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42341 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42342 dtp->jif = jiffies;
42343 #endif
42344 return;
42345 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
42346 !phba || !phba->slow_ring_trc)
42347 return;
42348
42349 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
42350 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
42351 (lpfc_debugfs_max_slow_ring_trc - 1);
42352 dtp = phba->slow_ring_trc + index;
42353 dtp->fmt = fmt;
42354 dtp->data1 = data1;
42355 dtp->data2 = data2;
42356 dtp->data3 = data3;
42357 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42358 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42359 dtp->jif = jiffies;
42360 #endif
42361 return;
42362 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42363 "slow_ring buffer\n");
42364 goto debug_failed;
42365 }
42366 - atomic_set(&phba->slow_ring_trc_cnt, 0);
42367 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
42368 memset(phba->slow_ring_trc, 0,
42369 (sizeof(struct lpfc_debugfs_trc) *
42370 lpfc_debugfs_max_slow_ring_trc));
42371 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42372 "buffer\n");
42373 goto debug_failed;
42374 }
42375 - atomic_set(&vport->disc_trc_cnt, 0);
42376 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
42377
42378 snprintf(name, sizeof(name), "discovery_trace");
42379 vport->debug_disc_trc =
42380 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
42381 index 89ad558..76956c4 100644
42382 --- a/drivers/scsi/lpfc/lpfc_init.c
42383 +++ b/drivers/scsi/lpfc/lpfc_init.c
42384 @@ -10618,8 +10618,10 @@ lpfc_init(void)
42385 "misc_register returned with status %d", error);
42386
42387 if (lpfc_enable_npiv) {
42388 - lpfc_transport_functions.vport_create = lpfc_vport_create;
42389 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42390 + pax_open_kernel();
42391 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
42392 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42393 + pax_close_kernel();
42394 }
42395 lpfc_transport_template =
42396 fc_attach_transport(&lpfc_transport_functions);
42397 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
42398 index 60e5a17..ff7a793 100644
42399 --- a/drivers/scsi/lpfc/lpfc_scsi.c
42400 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
42401 @@ -305,7 +305,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
42402 uint32_t evt_posted;
42403
42404 spin_lock_irqsave(&phba->hbalock, flags);
42405 - atomic_inc(&phba->num_rsrc_err);
42406 + atomic_inc_unchecked(&phba->num_rsrc_err);
42407 phba->last_rsrc_error_time = jiffies;
42408
42409 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
42410 @@ -346,7 +346,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
42411 unsigned long flags;
42412 struct lpfc_hba *phba = vport->phba;
42413 uint32_t evt_posted;
42414 - atomic_inc(&phba->num_cmd_success);
42415 + atomic_inc_unchecked(&phba->num_cmd_success);
42416
42417 if (vport->cfg_lun_queue_depth <= queue_depth)
42418 return;
42419 @@ -390,8 +390,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42420 unsigned long num_rsrc_err, num_cmd_success;
42421 int i;
42422
42423 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
42424 - num_cmd_success = atomic_read(&phba->num_cmd_success);
42425 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
42426 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
42427
42428 /*
42429 * The error and success command counters are global per
42430 @@ -419,8 +419,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42431 }
42432 }
42433 lpfc_destroy_vport_work_array(phba, vports);
42434 - atomic_set(&phba->num_rsrc_err, 0);
42435 - atomic_set(&phba->num_cmd_success, 0);
42436 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42437 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42438 }
42439
42440 /**
42441 @@ -454,8 +454,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
42442 }
42443 }
42444 lpfc_destroy_vport_work_array(phba, vports);
42445 - atomic_set(&phba->num_rsrc_err, 0);
42446 - atomic_set(&phba->num_cmd_success, 0);
42447 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42448 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42449 }
42450
42451 /**
42452 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
42453 index b46f5e9..c4c4ccb 100644
42454 --- a/drivers/scsi/pmcraid.c
42455 +++ b/drivers/scsi/pmcraid.c
42456 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
42457 res->scsi_dev = scsi_dev;
42458 scsi_dev->hostdata = res;
42459 res->change_detected = 0;
42460 - atomic_set(&res->read_failures, 0);
42461 - atomic_set(&res->write_failures, 0);
42462 + atomic_set_unchecked(&res->read_failures, 0);
42463 + atomic_set_unchecked(&res->write_failures, 0);
42464 rc = 0;
42465 }
42466 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
42467 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
42468
42469 /* If this was a SCSI read/write command keep count of errors */
42470 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
42471 - atomic_inc(&res->read_failures);
42472 + atomic_inc_unchecked(&res->read_failures);
42473 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
42474 - atomic_inc(&res->write_failures);
42475 + atomic_inc_unchecked(&res->write_failures);
42476
42477 if (!RES_IS_GSCSI(res->cfg_entry) &&
42478 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
42479 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
42480 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42481 * hrrq_id assigned here in queuecommand
42482 */
42483 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42484 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42485 pinstance->num_hrrq;
42486 cmd->cmd_done = pmcraid_io_done;
42487
42488 @@ -3859,7 +3859,7 @@ static long pmcraid_ioctl_passthrough(
42489 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42490 * hrrq_id assigned here in queuecommand
42491 */
42492 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42493 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42494 pinstance->num_hrrq;
42495
42496 if (request_size) {
42497 @@ -4497,7 +4497,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
42498
42499 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
42500 /* add resources only after host is added into system */
42501 - if (!atomic_read(&pinstance->expose_resources))
42502 + if (!atomic_read_unchecked(&pinstance->expose_resources))
42503 return;
42504
42505 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
42506 @@ -5324,8 +5324,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
42507 init_waitqueue_head(&pinstance->reset_wait_q);
42508
42509 atomic_set(&pinstance->outstanding_cmds, 0);
42510 - atomic_set(&pinstance->last_message_id, 0);
42511 - atomic_set(&pinstance->expose_resources, 0);
42512 + atomic_set_unchecked(&pinstance->last_message_id, 0);
42513 + atomic_set_unchecked(&pinstance->expose_resources, 0);
42514
42515 INIT_LIST_HEAD(&pinstance->free_res_q);
42516 INIT_LIST_HEAD(&pinstance->used_res_q);
42517 @@ -6038,7 +6038,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
42518 /* Schedule worker thread to handle CCN and take care of adding and
42519 * removing devices to OS
42520 */
42521 - atomic_set(&pinstance->expose_resources, 1);
42522 + atomic_set_unchecked(&pinstance->expose_resources, 1);
42523 schedule_work(&pinstance->worker_q);
42524 return rc;
42525
42526 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
42527 index e1d150f..6c6df44 100644
42528 --- a/drivers/scsi/pmcraid.h
42529 +++ b/drivers/scsi/pmcraid.h
42530 @@ -748,7 +748,7 @@ struct pmcraid_instance {
42531 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
42532
42533 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
42534 - atomic_t last_message_id;
42535 + atomic_unchecked_t last_message_id;
42536
42537 /* configuration table */
42538 struct pmcraid_config_table *cfg_table;
42539 @@ -777,7 +777,7 @@ struct pmcraid_instance {
42540 atomic_t outstanding_cmds;
42541
42542 /* should add/delete resources to mid-layer now ?*/
42543 - atomic_t expose_resources;
42544 + atomic_unchecked_t expose_resources;
42545
42546
42547
42548 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
42549 struct pmcraid_config_table_entry_ext cfg_entry_ext;
42550 };
42551 struct scsi_device *scsi_dev; /* Link scsi_device structure */
42552 - atomic_t read_failures; /* count of failed READ commands */
42553 - atomic_t write_failures; /* count of failed WRITE commands */
42554 + atomic_unchecked_t read_failures; /* count of failed READ commands */
42555 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
42556
42557 /* To indicate add/delete/modify during CCN */
42558 u8 change_detected;
42559 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
42560 index 83d7984..a27d947 100644
42561 --- a/drivers/scsi/qla2xxx/qla_attr.c
42562 +++ b/drivers/scsi/qla2xxx/qla_attr.c
42563 @@ -1969,7 +1969,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
42564 return 0;
42565 }
42566
42567 -struct fc_function_template qla2xxx_transport_functions = {
42568 +fc_function_template_no_const qla2xxx_transport_functions = {
42569
42570 .show_host_node_name = 1,
42571 .show_host_port_name = 1,
42572 @@ -2016,7 +2016,7 @@ struct fc_function_template qla2xxx_transport_functions = {
42573 .bsg_timeout = qla24xx_bsg_timeout,
42574 };
42575
42576 -struct fc_function_template qla2xxx_transport_vport_functions = {
42577 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
42578
42579 .show_host_node_name = 1,
42580 .show_host_port_name = 1,
42581 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
42582 index 2411d1a..4673766 100644
42583 --- a/drivers/scsi/qla2xxx/qla_gbl.h
42584 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
42585 @@ -515,8 +515,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
42586 struct device_attribute;
42587 extern struct device_attribute *qla2x00_host_attrs[];
42588 struct fc_function_template;
42589 -extern struct fc_function_template qla2xxx_transport_functions;
42590 -extern struct fc_function_template qla2xxx_transport_vport_functions;
42591 +extern fc_function_template_no_const qla2xxx_transport_functions;
42592 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
42593 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
42594 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
42595 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
42596 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
42597 index 10d23f8..a7d5d4c 100644
42598 --- a/drivers/scsi/qla2xxx/qla_os.c
42599 +++ b/drivers/scsi/qla2xxx/qla_os.c
42600 @@ -1472,8 +1472,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
42601 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
42602 /* Ok, a 64bit DMA mask is applicable. */
42603 ha->flags.enable_64bit_addressing = 1;
42604 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42605 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42606 + pax_open_kernel();
42607 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42608 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42609 + pax_close_kernel();
42610 return;
42611 }
42612 }
42613 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
42614 index 329d553..f20d31d 100644
42615 --- a/drivers/scsi/qla4xxx/ql4_def.h
42616 +++ b/drivers/scsi/qla4xxx/ql4_def.h
42617 @@ -273,7 +273,7 @@ struct ddb_entry {
42618 * (4000 only) */
42619 atomic_t relogin_timer; /* Max Time to wait for
42620 * relogin to complete */
42621 - atomic_t relogin_retry_count; /* Num of times relogin has been
42622 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
42623 * retried */
42624 uint32_t default_time2wait; /* Default Min time between
42625 * relogins (+aens) */
42626 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
42627 index 4cec123..7c1329f 100644
42628 --- a/drivers/scsi/qla4xxx/ql4_os.c
42629 +++ b/drivers/scsi/qla4xxx/ql4_os.c
42630 @@ -2621,12 +2621,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
42631 */
42632 if (!iscsi_is_session_online(cls_sess)) {
42633 /* Reset retry relogin timer */
42634 - atomic_inc(&ddb_entry->relogin_retry_count);
42635 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
42636 DEBUG2(ql4_printk(KERN_INFO, ha,
42637 "%s: index[%d] relogin timed out-retrying"
42638 " relogin (%d), retry (%d)\n", __func__,
42639 ddb_entry->fw_ddb_index,
42640 - atomic_read(&ddb_entry->relogin_retry_count),
42641 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
42642 ddb_entry->default_time2wait + 4));
42643 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
42644 atomic_set(&ddb_entry->retry_relogin_timer,
42645 @@ -4738,7 +4738,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
42646
42647 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
42648 atomic_set(&ddb_entry->relogin_timer, 0);
42649 - atomic_set(&ddb_entry->relogin_retry_count, 0);
42650 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
42651 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
42652 ddb_entry->default_relogin_timeout =
42653 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
42654 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
42655 index 2c0d0ec..4e8681a 100644
42656 --- a/drivers/scsi/scsi.c
42657 +++ b/drivers/scsi/scsi.c
42658 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
42659 unsigned long timeout;
42660 int rtn = 0;
42661
42662 - atomic_inc(&cmd->device->iorequest_cnt);
42663 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42664
42665 /* check if the device is still usable */
42666 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
42667 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
42668 index f1bf5af..f67e943 100644
42669 --- a/drivers/scsi/scsi_lib.c
42670 +++ b/drivers/scsi/scsi_lib.c
42671 @@ -1454,7 +1454,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
42672 shost = sdev->host;
42673 scsi_init_cmd_errh(cmd);
42674 cmd->result = DID_NO_CONNECT << 16;
42675 - atomic_inc(&cmd->device->iorequest_cnt);
42676 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42677
42678 /*
42679 * SCSI request completion path will do scsi_device_unbusy(),
42680 @@ -1480,9 +1480,9 @@ static void scsi_softirq_done(struct request *rq)
42681
42682 INIT_LIST_HEAD(&cmd->eh_entry);
42683
42684 - atomic_inc(&cmd->device->iodone_cnt);
42685 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
42686 if (cmd->result)
42687 - atomic_inc(&cmd->device->ioerr_cnt);
42688 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
42689
42690 disposition = scsi_decide_disposition(cmd);
42691 if (disposition != SUCCESS &&
42692 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
42693 index 931a7d9..0c2a754 100644
42694 --- a/drivers/scsi/scsi_sysfs.c
42695 +++ b/drivers/scsi/scsi_sysfs.c
42696 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
42697 char *buf) \
42698 { \
42699 struct scsi_device *sdev = to_scsi_device(dev); \
42700 - unsigned long long count = atomic_read(&sdev->field); \
42701 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
42702 return snprintf(buf, 20, "0x%llx\n", count); \
42703 } \
42704 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
42705 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
42706 index 84a1fdf..693b0d6 100644
42707 --- a/drivers/scsi/scsi_tgt_lib.c
42708 +++ b/drivers/scsi/scsi_tgt_lib.c
42709 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
42710 int err;
42711
42712 dprintk("%lx %u\n", uaddr, len);
42713 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
42714 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
42715 if (err) {
42716 /*
42717 * TODO: need to fixup sg_tablesize, max_segment_size,
42718 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
42719 index e894ca7..de9d7660 100644
42720 --- a/drivers/scsi/scsi_transport_fc.c
42721 +++ b/drivers/scsi/scsi_transport_fc.c
42722 @@ -498,7 +498,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
42723 * Netlink Infrastructure
42724 */
42725
42726 -static atomic_t fc_event_seq;
42727 +static atomic_unchecked_t fc_event_seq;
42728
42729 /**
42730 * fc_get_event_number - Obtain the next sequential FC event number
42731 @@ -511,7 +511,7 @@ static atomic_t fc_event_seq;
42732 u32
42733 fc_get_event_number(void)
42734 {
42735 - return atomic_add_return(1, &fc_event_seq);
42736 + return atomic_add_return_unchecked(1, &fc_event_seq);
42737 }
42738 EXPORT_SYMBOL(fc_get_event_number);
42739
42740 @@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
42741 {
42742 int error;
42743
42744 - atomic_set(&fc_event_seq, 0);
42745 + atomic_set_unchecked(&fc_event_seq, 0);
42746
42747 error = transport_class_register(&fc_host_class);
42748 if (error)
42749 @@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
42750 char *cp;
42751
42752 *val = simple_strtoul(buf, &cp, 0);
42753 - if ((*cp && (*cp != '\n')) || (*val < 0))
42754 + if (*cp && (*cp != '\n'))
42755 return -EINVAL;
42756 /*
42757 * Check for overflow; dev_loss_tmo is u32
42758 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
42759 index 31969f2..2b348f0 100644
42760 --- a/drivers/scsi/scsi_transport_iscsi.c
42761 +++ b/drivers/scsi/scsi_transport_iscsi.c
42762 @@ -79,7 +79,7 @@ struct iscsi_internal {
42763 struct transport_container session_cont;
42764 };
42765
42766 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
42767 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
42768 static struct workqueue_struct *iscsi_eh_timer_workq;
42769
42770 static DEFINE_IDA(iscsi_sess_ida);
42771 @@ -1064,7 +1064,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
42772 int err;
42773
42774 ihost = shost->shost_data;
42775 - session->sid = atomic_add_return(1, &iscsi_session_nr);
42776 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
42777
42778 if (target_id == ISCSI_MAX_TARGET) {
42779 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
42780 @@ -2943,7 +2943,7 @@ static __init int iscsi_transport_init(void)
42781 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
42782 ISCSI_TRANSPORT_VERSION);
42783
42784 - atomic_set(&iscsi_session_nr, 0);
42785 + atomic_set_unchecked(&iscsi_session_nr, 0);
42786
42787 err = class_register(&iscsi_transport_class);
42788 if (err)
42789 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
42790 index f379c7f..e8fc69c 100644
42791 --- a/drivers/scsi/scsi_transport_srp.c
42792 +++ b/drivers/scsi/scsi_transport_srp.c
42793 @@ -33,7 +33,7 @@
42794 #include "scsi_transport_srp_internal.h"
42795
42796 struct srp_host_attrs {
42797 - atomic_t next_port_id;
42798 + atomic_unchecked_t next_port_id;
42799 };
42800 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
42801
42802 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
42803 struct Scsi_Host *shost = dev_to_shost(dev);
42804 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
42805
42806 - atomic_set(&srp_host->next_port_id, 0);
42807 + atomic_set_unchecked(&srp_host->next_port_id, 0);
42808 return 0;
42809 }
42810
42811 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
42812 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
42813 rport->roles = ids->roles;
42814
42815 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
42816 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
42817 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
42818
42819 transport_setup_device(&rport->dev);
42820 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
42821 index 7992635..609faf8 100644
42822 --- a/drivers/scsi/sd.c
42823 +++ b/drivers/scsi/sd.c
42824 @@ -2909,7 +2909,7 @@ static int sd_probe(struct device *dev)
42825 sdkp->disk = gd;
42826 sdkp->index = index;
42827 atomic_set(&sdkp->openers, 0);
42828 - atomic_set(&sdkp->device->ioerr_cnt, 0);
42829 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
42830
42831 if (!sdp->request_queue->rq_timeout) {
42832 if (sdp->type != TYPE_MOD)
42833 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
42834 index be2c9a6..275525c 100644
42835 --- a/drivers/scsi/sg.c
42836 +++ b/drivers/scsi/sg.c
42837 @@ -1101,7 +1101,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
42838 sdp->disk->disk_name,
42839 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
42840 NULL,
42841 - (char *)arg);
42842 + (char __user *)arg);
42843 case BLKTRACESTART:
42844 return blk_trace_startstop(sdp->device->request_queue, 1);
42845 case BLKTRACESTOP:
42846 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
42847 index 19ee901..6e8c2ef 100644
42848 --- a/drivers/spi/spi.c
42849 +++ b/drivers/spi/spi.c
42850 @@ -1616,7 +1616,7 @@ int spi_bus_unlock(struct spi_master *master)
42851 EXPORT_SYMBOL_GPL(spi_bus_unlock);
42852
42853 /* portable code must never pass more than 32 bytes */
42854 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
42855 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
42856
42857 static u8 *buf;
42858
42859 diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
42860 index c7a5f97..71ecd35 100644
42861 --- a/drivers/staging/iio/iio_hwmon.c
42862 +++ b/drivers/staging/iio/iio_hwmon.c
42863 @@ -72,7 +72,7 @@ static void iio_hwmon_free_attrs(struct iio_hwmon_state *st)
42864 static int iio_hwmon_probe(struct platform_device *pdev)
42865 {
42866 struct iio_hwmon_state *st;
42867 - struct sensor_device_attribute *a;
42868 + sensor_device_attribute_no_const *a;
42869 int ret, i;
42870 int in_i = 1, temp_i = 1, curr_i = 1;
42871 enum iio_chan_type type;
42872 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
42873 index 34afc16..ffe44dd 100644
42874 --- a/drivers/staging/octeon/ethernet-rx.c
42875 +++ b/drivers/staging/octeon/ethernet-rx.c
42876 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42877 /* Increment RX stats for virtual ports */
42878 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
42879 #ifdef CONFIG_64BIT
42880 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
42881 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
42882 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
42883 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
42884 #else
42885 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
42886 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
42887 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
42888 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
42889 #endif
42890 }
42891 netif_receive_skb(skb);
42892 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42893 dev->name);
42894 */
42895 #ifdef CONFIG_64BIT
42896 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
42897 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42898 #else
42899 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
42900 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
42901 #endif
42902 dev_kfree_skb_irq(skb);
42903 }
42904 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
42905 index ef32dc1..a159d68 100644
42906 --- a/drivers/staging/octeon/ethernet.c
42907 +++ b/drivers/staging/octeon/ethernet.c
42908 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
42909 * since the RX tasklet also increments it.
42910 */
42911 #ifdef CONFIG_64BIT
42912 - atomic64_add(rx_status.dropped_packets,
42913 - (atomic64_t *)&priv->stats.rx_dropped);
42914 + atomic64_add_unchecked(rx_status.dropped_packets,
42915 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42916 #else
42917 - atomic_add(rx_status.dropped_packets,
42918 - (atomic_t *)&priv->stats.rx_dropped);
42919 + atomic_add_unchecked(rx_status.dropped_packets,
42920 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
42921 #endif
42922 }
42923
42924 diff --git a/drivers/staging/ramster/tmem.c b/drivers/staging/ramster/tmem.c
42925 index a2b7e03..aaf3630 100644
42926 --- a/drivers/staging/ramster/tmem.c
42927 +++ b/drivers/staging/ramster/tmem.c
42928 @@ -50,25 +50,25 @@
42929 * A tmem host implementation must use this function to register callbacks
42930 * for memory allocation.
42931 */
42932 -static struct tmem_hostops tmem_hostops;
42933 +static struct tmem_hostops *tmem_hostops;
42934
42935 static void tmem_objnode_tree_init(void);
42936
42937 void tmem_register_hostops(struct tmem_hostops *m)
42938 {
42939 tmem_objnode_tree_init();
42940 - tmem_hostops = *m;
42941 + tmem_hostops = m;
42942 }
42943
42944 /*
42945 * A tmem host implementation must use this function to register
42946 * callbacks for a page-accessible memory (PAM) implementation.
42947 */
42948 -static struct tmem_pamops tmem_pamops;
42949 +static struct tmem_pamops *tmem_pamops;
42950
42951 void tmem_register_pamops(struct tmem_pamops *m)
42952 {
42953 - tmem_pamops = *m;
42954 + tmem_pamops = m;
42955 }
42956
42957 /*
42958 @@ -174,7 +174,7 @@ static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb,
42959 obj->pampd_count = 0;
42960 #ifdef CONFIG_RAMSTER
42961 if (tmem_pamops.new_obj != NULL)
42962 - (*tmem_pamops.new_obj)(obj);
42963 + (tmem_pamops->new_obj)(obj);
42964 #endif
42965 SET_SENTINEL(obj, OBJ);
42966
42967 @@ -210,7 +210,7 @@ static void tmem_pool_flush(struct tmem_pool *pool, bool destroy)
42968 rbnode = rb_next(rbnode);
42969 tmem_pampd_destroy_all_in_obj(obj, true);
42970 tmem_obj_free(obj, hb);
42971 - (*tmem_hostops.obj_free)(obj, pool);
42972 + (tmem_hostops->obj_free)(obj, pool);
42973 }
42974 spin_unlock(&hb->lock);
42975 }
42976 @@ -261,7 +261,7 @@ static struct tmem_objnode *tmem_objnode_alloc(struct tmem_obj *obj)
42977 ASSERT_SENTINEL(obj, OBJ);
42978 BUG_ON(obj->pool == NULL);
42979 ASSERT_SENTINEL(obj->pool, POOL);
42980 - objnode = (*tmem_hostops.objnode_alloc)(obj->pool);
42981 + objnode = (tmem_hostops->objnode_alloc)(obj->pool);
42982 if (unlikely(objnode == NULL))
42983 goto out;
42984 objnode->obj = obj;
42985 @@ -290,7 +290,7 @@ static void tmem_objnode_free(struct tmem_objnode *objnode)
42986 ASSERT_SENTINEL(pool, POOL);
42987 objnode->obj->objnode_count--;
42988 objnode->obj = NULL;
42989 - (*tmem_hostops.objnode_free)(objnode, pool);
42990 + (tmem_hostops->objnode_free)(objnode, pool);
42991 }
42992
42993 /*
42994 @@ -348,7 +348,7 @@ static void *tmem_pampd_replace_in_obj(struct tmem_obj *obj, uint32_t index,
42995 void *old_pampd = *(void **)slot;
42996 *(void **)slot = new_pampd;
42997 if (!no_free)
42998 - (*tmem_pamops.free)(old_pampd, obj->pool,
42999 + (tmem_pamops->free)(old_pampd, obj->pool,
43000 NULL, 0, false);
43001 ret = new_pampd;
43002 }
43003 @@ -505,7 +505,7 @@ static void tmem_objnode_node_destroy(struct tmem_obj *obj,
43004 if (objnode->slots[i]) {
43005 if (ht == 1) {
43006 obj->pampd_count--;
43007 - (*tmem_pamops.free)(objnode->slots[i],
43008 + (tmem_pamops->free)(objnode->slots[i],
43009 obj->pool, NULL, 0, true);
43010 objnode->slots[i] = NULL;
43011 continue;
43012 @@ -524,7 +524,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
43013 return;
43014 if (obj->objnode_tree_height == 0) {
43015 obj->pampd_count--;
43016 - (*tmem_pamops.free)(obj->objnode_tree_root,
43017 + (tmem_pamops->free)(obj->objnode_tree_root,
43018 obj->pool, NULL, 0, true);
43019 } else {
43020 tmem_objnode_node_destroy(obj, obj->objnode_tree_root,
43021 @@ -535,7 +535,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
43022 obj->objnode_tree_root = NULL;
43023 #ifdef CONFIG_RAMSTER
43024 if (tmem_pamops.free_obj != NULL)
43025 - (*tmem_pamops.free_obj)(obj->pool, obj, pool_destroy);
43026 + (tmem_pamops->free_obj)(obj->pool, obj, pool_destroy);
43027 #endif
43028 }
43029
43030 @@ -574,7 +574,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43031 /* if found, is a dup put, flush the old one */
43032 pampd_del = tmem_pampd_delete_from_obj(obj, index);
43033 BUG_ON(pampd_del != pampd);
43034 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
43035 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
43036 if (obj->pampd_count == 0) {
43037 objnew = obj;
43038 objfound = NULL;
43039 @@ -582,7 +582,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43040 pampd = NULL;
43041 }
43042 } else {
43043 - obj = objnew = (*tmem_hostops.obj_alloc)(pool);
43044 + obj = objnew = (tmem_hostops->obj_alloc)(pool);
43045 if (unlikely(obj == NULL)) {
43046 ret = -ENOMEM;
43047 goto out;
43048 @@ -597,16 +597,16 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43049 if (unlikely(ret == -ENOMEM))
43050 /* may have partially built objnode tree ("stump") */
43051 goto delete_and_free;
43052 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(pool));
43053 + (tmem_pamops->create_finish)(pampd, is_ephemeral(pool));
43054 goto out;
43055
43056 delete_and_free:
43057 (void)tmem_pampd_delete_from_obj(obj, index);
43058 if (pampd)
43059 - (*tmem_pamops.free)(pampd, pool, NULL, 0, true);
43060 + (tmem_pamops->free)(pampd, pool, NULL, 0, true);
43061 if (objnew) {
43062 tmem_obj_free(objnew, hb);
43063 - (*tmem_hostops.obj_free)(objnew, pool);
43064 + (tmem_hostops->obj_free)(objnew, pool);
43065 }
43066 out:
43067 spin_unlock(&hb->lock);
43068 @@ -651,7 +651,7 @@ void tmem_localify_finish(struct tmem_obj *obj, uint32_t index,
43069 if (pampd != NULL) {
43070 BUG_ON(obj == NULL);
43071 (void)tmem_pampd_replace_in_obj(obj, index, pampd, 1);
43072 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(obj->pool));
43073 + (tmem_pamops->create_finish)(pampd, is_ephemeral(obj->pool));
43074 } else if (delete) {
43075 BUG_ON(obj == NULL);
43076 (void)tmem_pampd_delete_from_obj(obj, index);
43077 @@ -671,7 +671,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
43078 int ret = 0;
43079
43080 if (!is_ephemeral(pool))
43081 - new_pampd = (*tmem_pamops.repatriate_preload)(
43082 + new_pampd = (tmem_pamops->repatriate_preload)(
43083 old_pampd, pool, oidp, index, &intransit);
43084 if (intransit)
43085 ret = -EAGAIN;
43086 @@ -680,7 +680,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
43087 /* must release the hb->lock else repatriate can't sleep */
43088 spin_unlock(&hb->lock);
43089 if (!intransit)
43090 - ret = (*tmem_pamops.repatriate)(old_pampd, new_pampd, pool,
43091 + ret = (tmem_pamops->repatriate)(old_pampd, new_pampd, pool,
43092 oidp, index, free, data);
43093 if (ret == -EAGAIN) {
43094 /* rare I think, but should cond_resched()??? */
43095 @@ -714,7 +714,7 @@ int tmem_replace(struct tmem_pool *pool, struct tmem_oid *oidp,
43096 new_pampd = tmem_pampd_replace_in_obj(obj, index, new_pampd, 0);
43097 /* if we bug here, pamops wasn't properly set up for ramster */
43098 BUG_ON(tmem_pamops.replace_in_obj == NULL);
43099 - ret = (*tmem_pamops.replace_in_obj)(new_pampd, obj);
43100 + ret = (tmem_pamops->replace_in_obj)(new_pampd, obj);
43101 out:
43102 spin_unlock(&hb->lock);
43103 return ret;
43104 @@ -776,15 +776,15 @@ int tmem_get(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43105 if (free) {
43106 if (obj->pampd_count == 0) {
43107 tmem_obj_free(obj, hb);
43108 - (*tmem_hostops.obj_free)(obj, pool);
43109 + (tmem_hostops->obj_free)(obj, pool);
43110 obj = NULL;
43111 }
43112 }
43113 if (free)
43114 - ret = (*tmem_pamops.get_data_and_free)(
43115 + ret = (tmem_pamops->get_data_and_free)(
43116 data, sizep, raw, pampd, pool, oidp, index);
43117 else
43118 - ret = (*tmem_pamops.get_data)(
43119 + ret = (tmem_pamops->get_data)(
43120 data, sizep, raw, pampd, pool, oidp, index);
43121 if (ret < 0)
43122 goto out;
43123 @@ -816,10 +816,10 @@ int tmem_flush_page(struct tmem_pool *pool,
43124 pampd = tmem_pampd_delete_from_obj(obj, index);
43125 if (pampd == NULL)
43126 goto out;
43127 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
43128 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
43129 if (obj->pampd_count == 0) {
43130 tmem_obj_free(obj, hb);
43131 - (*tmem_hostops.obj_free)(obj, pool);
43132 + (tmem_hostops->obj_free)(obj, pool);
43133 }
43134 ret = 0;
43135
43136 @@ -844,7 +844,7 @@ int tmem_flush_object(struct tmem_pool *pool, struct tmem_oid *oidp)
43137 goto out;
43138 tmem_pampd_destroy_all_in_obj(obj, false);
43139 tmem_obj_free(obj, hb);
43140 - (*tmem_hostops.obj_free)(obj, pool);
43141 + (tmem_hostops->obj_free)(obj, pool);
43142 ret = 0;
43143
43144 out:
43145 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
43146 index dc23395..cf7e9b1 100644
43147 --- a/drivers/staging/rtl8712/rtl871x_io.h
43148 +++ b/drivers/staging/rtl8712/rtl871x_io.h
43149 @@ -108,7 +108,7 @@ struct _io_ops {
43150 u8 *pmem);
43151 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
43152 u8 *pmem);
43153 -};
43154 +} __no_const;
43155
43156 struct io_req {
43157 struct list_head list;
43158 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
43159 index 1f5088b..0e59820 100644
43160 --- a/drivers/staging/sbe-2t3e3/netdev.c
43161 +++ b/drivers/staging/sbe-2t3e3/netdev.c
43162 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43163 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
43164
43165 if (rlen)
43166 - if (copy_to_user(data, &resp, rlen))
43167 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
43168 return -EFAULT;
43169
43170 return 0;
43171 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
43172 index 5dddc4d..34fcb2f 100644
43173 --- a/drivers/staging/usbip/vhci.h
43174 +++ b/drivers/staging/usbip/vhci.h
43175 @@ -83,7 +83,7 @@ struct vhci_hcd {
43176 unsigned resuming:1;
43177 unsigned long re_timeout;
43178
43179 - atomic_t seqnum;
43180 + atomic_unchecked_t seqnum;
43181
43182 /*
43183 * NOTE:
43184 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
43185 index c3aa219..bf8b3de 100644
43186 --- a/drivers/staging/usbip/vhci_hcd.c
43187 +++ b/drivers/staging/usbip/vhci_hcd.c
43188 @@ -451,7 +451,7 @@ static void vhci_tx_urb(struct urb *urb)
43189 return;
43190 }
43191
43192 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
43193 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43194 if (priv->seqnum == 0xffff)
43195 dev_info(&urb->dev->dev, "seqnum max\n");
43196
43197 @@ -703,7 +703,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
43198 return -ENOMEM;
43199 }
43200
43201 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
43202 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43203 if (unlink->seqnum == 0xffff)
43204 pr_info("seqnum max\n");
43205
43206 @@ -907,7 +907,7 @@ static int vhci_start(struct usb_hcd *hcd)
43207 vdev->rhport = rhport;
43208 }
43209
43210 - atomic_set(&vhci->seqnum, 0);
43211 + atomic_set_unchecked(&vhci->seqnum, 0);
43212 spin_lock_init(&vhci->lock);
43213
43214 hcd->power_budget = 0; /* no limit */
43215 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
43216 index ba5f1c0..11d8122 100644
43217 --- a/drivers/staging/usbip/vhci_rx.c
43218 +++ b/drivers/staging/usbip/vhci_rx.c
43219 @@ -77,7 +77,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
43220 if (!urb) {
43221 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
43222 pr_info("max seqnum %d\n",
43223 - atomic_read(&the_controller->seqnum));
43224 + atomic_read_unchecked(&the_controller->seqnum));
43225 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
43226 return;
43227 }
43228 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
43229 index 5f13890..36a044b 100644
43230 --- a/drivers/staging/vt6655/hostap.c
43231 +++ b/drivers/staging/vt6655/hostap.c
43232 @@ -73,14 +73,13 @@ static int msglevel =MSG_LEVEL_INFO;
43233 *
43234 */
43235
43236 +static net_device_ops_no_const apdev_netdev_ops;
43237 +
43238 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43239 {
43240 PSDevice apdev_priv;
43241 struct net_device *dev = pDevice->dev;
43242 int ret;
43243 - const struct net_device_ops apdev_netdev_ops = {
43244 - .ndo_start_xmit = pDevice->tx_80211,
43245 - };
43246
43247 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43248
43249 @@ -92,6 +91,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43250 *apdev_priv = *pDevice;
43251 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43252
43253 + /* only half broken now */
43254 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43255 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43256
43257 pDevice->apdev->type = ARPHRD_IEEE80211;
43258 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
43259 index 26a7d0e..897b083 100644
43260 --- a/drivers/staging/vt6656/hostap.c
43261 +++ b/drivers/staging/vt6656/hostap.c
43262 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
43263 *
43264 */
43265
43266 +static net_device_ops_no_const apdev_netdev_ops;
43267 +
43268 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43269 {
43270 PSDevice apdev_priv;
43271 struct net_device *dev = pDevice->dev;
43272 int ret;
43273 - const struct net_device_ops apdev_netdev_ops = {
43274 - .ndo_start_xmit = pDevice->tx_80211,
43275 - };
43276
43277 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43278
43279 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43280 *apdev_priv = *pDevice;
43281 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43282
43283 + /* only half broken now */
43284 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43285 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43286
43287 pDevice->apdev->type = ARPHRD_IEEE80211;
43288 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
43289 index 56c8e60..1920c63 100644
43290 --- a/drivers/staging/zcache/tmem.c
43291 +++ b/drivers/staging/zcache/tmem.c
43292 @@ -39,7 +39,7 @@
43293 * A tmem host implementation must use this function to register callbacks
43294 * for memory allocation.
43295 */
43296 -static struct tmem_hostops tmem_hostops;
43297 +static tmem_hostops_no_const tmem_hostops;
43298
43299 static void tmem_objnode_tree_init(void);
43300
43301 @@ -53,7 +53,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
43302 * A tmem host implementation must use this function to register
43303 * callbacks for a page-accessible memory (PAM) implementation
43304 */
43305 -static struct tmem_pamops tmem_pamops;
43306 +static tmem_pamops_no_const tmem_pamops;
43307
43308 void tmem_register_pamops(struct tmem_pamops *m)
43309 {
43310 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
43311 index 0d4aa82..f7832d4 100644
43312 --- a/drivers/staging/zcache/tmem.h
43313 +++ b/drivers/staging/zcache/tmem.h
43314 @@ -180,6 +180,7 @@ struct tmem_pamops {
43315 void (*new_obj)(struct tmem_obj *);
43316 int (*replace_in_obj)(void *, struct tmem_obj *);
43317 };
43318 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
43319 extern void tmem_register_pamops(struct tmem_pamops *m);
43320
43321 /* memory allocation methods provided by the host implementation */
43322 @@ -189,6 +190,7 @@ struct tmem_hostops {
43323 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
43324 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
43325 };
43326 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
43327 extern void tmem_register_hostops(struct tmem_hostops *m);
43328
43329 /* core tmem accessor functions */
43330 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
43331 index 96f4981..4daaa7e 100644
43332 --- a/drivers/target/target_core_device.c
43333 +++ b/drivers/target/target_core_device.c
43334 @@ -1370,7 +1370,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
43335 spin_lock_init(&dev->se_port_lock);
43336 spin_lock_init(&dev->se_tmr_lock);
43337 spin_lock_init(&dev->qf_cmd_lock);
43338 - atomic_set(&dev->dev_ordered_id, 0);
43339 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
43340 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
43341 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
43342 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
43343 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
43344 index fcf880f..a4d1e8f 100644
43345 --- a/drivers/target/target_core_transport.c
43346 +++ b/drivers/target/target_core_transport.c
43347 @@ -1077,7 +1077,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
43348 * Used to determine when ORDERED commands should go from
43349 * Dormant to Active status.
43350 */
43351 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
43352 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
43353 smp_mb__after_atomic_inc();
43354 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
43355 cmd->se_ordered_id, cmd->sam_task_attr,
43356 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
43357 index b09c8d1f..c4225c0 100644
43358 --- a/drivers/tty/cyclades.c
43359 +++ b/drivers/tty/cyclades.c
43360 @@ -1589,10 +1589,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
43361 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
43362 info->port.count);
43363 #endif
43364 - info->port.count++;
43365 + atomic_inc(&info->port.count);
43366 #ifdef CY_DEBUG_COUNT
43367 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
43368 - current->pid, info->port.count);
43369 + current->pid, atomic_read(&info->port.count));
43370 #endif
43371
43372 /*
43373 @@ -3991,7 +3991,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
43374 for (j = 0; j < cy_card[i].nports; j++) {
43375 info = &cy_card[i].ports[j];
43376
43377 - if (info->port.count) {
43378 + if (atomic_read(&info->port.count)) {
43379 /* XXX is the ldisc num worth this? */
43380 struct tty_struct *tty;
43381 struct tty_ldisc *ld;
43382 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
43383 index 13ee53b..418d164 100644
43384 --- a/drivers/tty/hvc/hvc_console.c
43385 +++ b/drivers/tty/hvc/hvc_console.c
43386 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
43387
43388 spin_lock_irqsave(&hp->port.lock, flags);
43389 /* Check and then increment for fast path open. */
43390 - if (hp->port.count++ > 0) {
43391 + if (atomic_inc_return(&hp->port.count) > 1) {
43392 spin_unlock_irqrestore(&hp->port.lock, flags);
43393 hvc_kick();
43394 return 0;
43395 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43396
43397 spin_lock_irqsave(&hp->port.lock, flags);
43398
43399 - if (--hp->port.count == 0) {
43400 + if (atomic_dec_return(&hp->port.count) == 0) {
43401 spin_unlock_irqrestore(&hp->port.lock, flags);
43402 /* We are done with the tty pointer now. */
43403 tty_port_tty_set(&hp->port, NULL);
43404 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43405 */
43406 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
43407 } else {
43408 - if (hp->port.count < 0)
43409 + if (atomic_read(&hp->port.count) < 0)
43410 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
43411 - hp->vtermno, hp->port.count);
43412 + hp->vtermno, atomic_read(&hp->port.count));
43413 spin_unlock_irqrestore(&hp->port.lock, flags);
43414 }
43415 }
43416 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
43417 * open->hangup case this can be called after the final close so prevent
43418 * that from happening for now.
43419 */
43420 - if (hp->port.count <= 0) {
43421 + if (atomic_read(&hp->port.count) <= 0) {
43422 spin_unlock_irqrestore(&hp->port.lock, flags);
43423 return;
43424 }
43425
43426 - hp->port.count = 0;
43427 + atomic_set(&hp->port.count, 0);
43428 spin_unlock_irqrestore(&hp->port.lock, flags);
43429 tty_port_tty_set(&hp->port, NULL);
43430
43431 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
43432 return -EPIPE;
43433
43434 /* FIXME what's this (unprotected) check for? */
43435 - if (hp->port.count <= 0)
43436 + if (atomic_read(&hp->port.count) <= 0)
43437 return -EIO;
43438
43439 spin_lock_irqsave(&hp->lock, flags);
43440 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
43441 index 8776357..b2d4afd 100644
43442 --- a/drivers/tty/hvc/hvcs.c
43443 +++ b/drivers/tty/hvc/hvcs.c
43444 @@ -83,6 +83,7 @@
43445 #include <asm/hvcserver.h>
43446 #include <asm/uaccess.h>
43447 #include <asm/vio.h>
43448 +#include <asm/local.h>
43449
43450 /*
43451 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
43452 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
43453
43454 spin_lock_irqsave(&hvcsd->lock, flags);
43455
43456 - if (hvcsd->port.count > 0) {
43457 + if (atomic_read(&hvcsd->port.count) > 0) {
43458 spin_unlock_irqrestore(&hvcsd->lock, flags);
43459 printk(KERN_INFO "HVCS: vterm state unchanged. "
43460 "The hvcs device node is still in use.\n");
43461 @@ -1132,7 +1133,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
43462 }
43463 }
43464
43465 - hvcsd->port.count = 0;
43466 + atomic_set(&hvcsd->port.count, 0);
43467 hvcsd->port.tty = tty;
43468 tty->driver_data = hvcsd;
43469
43470 @@ -1185,7 +1186,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
43471 unsigned long flags;
43472
43473 spin_lock_irqsave(&hvcsd->lock, flags);
43474 - hvcsd->port.count++;
43475 + atomic_inc(&hvcsd->port.count);
43476 hvcsd->todo_mask |= HVCS_SCHED_READ;
43477 spin_unlock_irqrestore(&hvcsd->lock, flags);
43478
43479 @@ -1221,7 +1222,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43480 hvcsd = tty->driver_data;
43481
43482 spin_lock_irqsave(&hvcsd->lock, flags);
43483 - if (--hvcsd->port.count == 0) {
43484 + if (atomic_dec_and_test(&hvcsd->port.count)) {
43485
43486 vio_disable_interrupts(hvcsd->vdev);
43487
43488 @@ -1246,10 +1247,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43489
43490 free_irq(irq, hvcsd);
43491 return;
43492 - } else if (hvcsd->port.count < 0) {
43493 + } else if (atomic_read(&hvcsd->port.count) < 0) {
43494 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
43495 " is missmanaged.\n",
43496 - hvcsd->vdev->unit_address, hvcsd->port.count);
43497 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
43498 }
43499
43500 spin_unlock_irqrestore(&hvcsd->lock, flags);
43501 @@ -1271,7 +1272,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43502
43503 spin_lock_irqsave(&hvcsd->lock, flags);
43504 /* Preserve this so that we know how many kref refs to put */
43505 - temp_open_count = hvcsd->port.count;
43506 + temp_open_count = atomic_read(&hvcsd->port.count);
43507
43508 /*
43509 * Don't kref put inside the spinlock because the destruction
43510 @@ -1286,7 +1287,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43511 tty->driver_data = NULL;
43512 hvcsd->port.tty = NULL;
43513
43514 - hvcsd->port.count = 0;
43515 + atomic_set(&hvcsd->port.count, 0);
43516
43517 /* This will drop any buffered data on the floor which is OK in a hangup
43518 * scenario. */
43519 @@ -1357,7 +1358,7 @@ static int hvcs_write(struct tty_struct *tty,
43520 * the middle of a write operation? This is a crummy place to do this
43521 * but we want to keep it all in the spinlock.
43522 */
43523 - if (hvcsd->port.count <= 0) {
43524 + if (atomic_read(&hvcsd->port.count) <= 0) {
43525 spin_unlock_irqrestore(&hvcsd->lock, flags);
43526 return -ENODEV;
43527 }
43528 @@ -1431,7 +1432,7 @@ static int hvcs_write_room(struct tty_struct *tty)
43529 {
43530 struct hvcs_struct *hvcsd = tty->driver_data;
43531
43532 - if (!hvcsd || hvcsd->port.count <= 0)
43533 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
43534 return 0;
43535
43536 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
43537 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
43538 index 2cde13d..645d78f 100644
43539 --- a/drivers/tty/ipwireless/tty.c
43540 +++ b/drivers/tty/ipwireless/tty.c
43541 @@ -29,6 +29,7 @@
43542 #include <linux/tty_driver.h>
43543 #include <linux/tty_flip.h>
43544 #include <linux/uaccess.h>
43545 +#include <asm/local.h>
43546
43547 #include "tty.h"
43548 #include "network.h"
43549 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43550 mutex_unlock(&tty->ipw_tty_mutex);
43551 return -ENODEV;
43552 }
43553 - if (tty->port.count == 0)
43554 + if (atomic_read(&tty->port.count) == 0)
43555 tty->tx_bytes_queued = 0;
43556
43557 - tty->port.count++;
43558 + atomic_inc(&tty->port.count);
43559
43560 tty->port.tty = linux_tty;
43561 linux_tty->driver_data = tty;
43562 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43563
43564 static void do_ipw_close(struct ipw_tty *tty)
43565 {
43566 - tty->port.count--;
43567 -
43568 - if (tty->port.count == 0) {
43569 + if (atomic_dec_return(&tty->port.count) == 0) {
43570 struct tty_struct *linux_tty = tty->port.tty;
43571
43572 if (linux_tty != NULL) {
43573 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
43574 return;
43575
43576 mutex_lock(&tty->ipw_tty_mutex);
43577 - if (tty->port.count == 0) {
43578 + if (atomic_read(&tty->port.count) == 0) {
43579 mutex_unlock(&tty->ipw_tty_mutex);
43580 return;
43581 }
43582 @@ -170,7 +169,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
43583 return;
43584 }
43585
43586 - if (!tty->port.count) {
43587 + if (!atomic_read(&tty->port.count)) {
43588 mutex_unlock(&tty->ipw_tty_mutex);
43589 return;
43590 }
43591 @@ -212,7 +211,7 @@ static int ipw_write(struct tty_struct *linux_tty,
43592 return -ENODEV;
43593
43594 mutex_lock(&tty->ipw_tty_mutex);
43595 - if (!tty->port.count) {
43596 + if (!atomic_read(&tty->port.count)) {
43597 mutex_unlock(&tty->ipw_tty_mutex);
43598 return -EINVAL;
43599 }
43600 @@ -252,7 +251,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
43601 if (!tty)
43602 return -ENODEV;
43603
43604 - if (!tty->port.count)
43605 + if (!atomic_read(&tty->port.count))
43606 return -EINVAL;
43607
43608 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
43609 @@ -294,7 +293,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
43610 if (!tty)
43611 return 0;
43612
43613 - if (!tty->port.count)
43614 + if (!atomic_read(&tty->port.count))
43615 return 0;
43616
43617 return tty->tx_bytes_queued;
43618 @@ -375,7 +374,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
43619 if (!tty)
43620 return -ENODEV;
43621
43622 - if (!tty->port.count)
43623 + if (!atomic_read(&tty->port.count))
43624 return -EINVAL;
43625
43626 return get_control_lines(tty);
43627 @@ -391,7 +390,7 @@ ipw_tiocmset(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 return set_control_lines(tty, set, clear);
43636 @@ -405,7 +404,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
43637 if (!tty)
43638 return -ENODEV;
43639
43640 - if (!tty->port.count)
43641 + if (!atomic_read(&tty->port.count))
43642 return -EINVAL;
43643
43644 /* FIXME: Exactly how is the tty object locked here .. */
43645 @@ -561,7 +560,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
43646 * are gone */
43647 mutex_lock(&ttyj->ipw_tty_mutex);
43648 }
43649 - while (ttyj->port.count)
43650 + while (atomic_read(&ttyj->port.count))
43651 do_ipw_close(ttyj);
43652 ipwireless_disassociate_network_ttys(network,
43653 ttyj->channel_idx);
43654 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
43655 index f9d2850..b006f04 100644
43656 --- a/drivers/tty/moxa.c
43657 +++ b/drivers/tty/moxa.c
43658 @@ -1193,7 +1193,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
43659 }
43660
43661 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
43662 - ch->port.count++;
43663 + atomic_inc(&ch->port.count);
43664 tty->driver_data = ch;
43665 tty_port_tty_set(&ch->port, tty);
43666 mutex_lock(&ch->port.mutex);
43667 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
43668 index bfd6771..e0d93c4 100644
43669 --- a/drivers/tty/n_gsm.c
43670 +++ b/drivers/tty/n_gsm.c
43671 @@ -1636,7 +1636,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
43672 spin_lock_init(&dlci->lock);
43673 mutex_init(&dlci->mutex);
43674 dlci->fifo = &dlci->_fifo;
43675 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
43676 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
43677 kfree(dlci);
43678 return NULL;
43679 }
43680 @@ -2936,7 +2936,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
43681 struct gsm_dlci *dlci = tty->driver_data;
43682 struct tty_port *port = &dlci->port;
43683
43684 - port->count++;
43685 + atomic_inc(&port->count);
43686 dlci_get(dlci);
43687 dlci_get(dlci->gsm->dlci[0]);
43688 mux_get(dlci->gsm);
43689 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
43690 index 19083ef..6e34e97 100644
43691 --- a/drivers/tty/n_tty.c
43692 +++ b/drivers/tty/n_tty.c
43693 @@ -2196,6 +2196,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
43694 {
43695 *ops = tty_ldisc_N_TTY;
43696 ops->owner = NULL;
43697 - ops->refcount = ops->flags = 0;
43698 + atomic_set(&ops->refcount, 0);
43699 + ops->flags = 0;
43700 }
43701 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
43702 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
43703 index ac35c90..c47deac 100644
43704 --- a/drivers/tty/pty.c
43705 +++ b/drivers/tty/pty.c
43706 @@ -790,8 +790,10 @@ static void __init unix98_pty_init(void)
43707 panic("Couldn't register Unix98 pts driver");
43708
43709 /* Now create the /dev/ptmx special device */
43710 + pax_open_kernel();
43711 tty_default_fops(&ptmx_fops);
43712 - ptmx_fops.open = ptmx_open;
43713 + *(void **)&ptmx_fops.open = ptmx_open;
43714 + pax_close_kernel();
43715
43716 cdev_init(&ptmx_cdev, &ptmx_fops);
43717 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
43718 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
43719 index e42009a..566a036 100644
43720 --- a/drivers/tty/rocket.c
43721 +++ b/drivers/tty/rocket.c
43722 @@ -925,7 +925,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43723 tty->driver_data = info;
43724 tty_port_tty_set(port, tty);
43725
43726 - if (port->count++ == 0) {
43727 + if (atomic_inc_return(&port->count) == 1) {
43728 atomic_inc(&rp_num_ports_open);
43729
43730 #ifdef ROCKET_DEBUG_OPEN
43731 @@ -934,7 +934,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43732 #endif
43733 }
43734 #ifdef ROCKET_DEBUG_OPEN
43735 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
43736 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
43737 #endif
43738
43739 /*
43740 @@ -1529,7 +1529,7 @@ static void rp_hangup(struct tty_struct *tty)
43741 spin_unlock_irqrestore(&info->port.lock, flags);
43742 return;
43743 }
43744 - if (info->port.count)
43745 + if (atomic_read(&info->port.count))
43746 atomic_dec(&rp_num_ports_open);
43747 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
43748 spin_unlock_irqrestore(&info->port.lock, flags);
43749 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
43750 index 1002054..dd644a8 100644
43751 --- a/drivers/tty/serial/kgdboc.c
43752 +++ b/drivers/tty/serial/kgdboc.c
43753 @@ -24,8 +24,9 @@
43754 #define MAX_CONFIG_LEN 40
43755
43756 static struct kgdb_io kgdboc_io_ops;
43757 +static struct kgdb_io kgdboc_io_ops_console;
43758
43759 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
43760 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
43761 static int configured = -1;
43762
43763 static char config[MAX_CONFIG_LEN];
43764 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
43765 kgdboc_unregister_kbd();
43766 if (configured == 1)
43767 kgdb_unregister_io_module(&kgdboc_io_ops);
43768 + else if (configured == 2)
43769 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
43770 }
43771
43772 static int configure_kgdboc(void)
43773 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
43774 int err;
43775 char *cptr = config;
43776 struct console *cons;
43777 + int is_console = 0;
43778
43779 err = kgdboc_option_setup(config);
43780 if (err || !strlen(config) || isspace(config[0]))
43781 goto noconfig;
43782
43783 err = -ENODEV;
43784 - kgdboc_io_ops.is_console = 0;
43785 kgdb_tty_driver = NULL;
43786
43787 kgdboc_use_kms = 0;
43788 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
43789 int idx;
43790 if (cons->device && cons->device(cons, &idx) == p &&
43791 idx == tty_line) {
43792 - kgdboc_io_ops.is_console = 1;
43793 + is_console = 1;
43794 break;
43795 }
43796 cons = cons->next;
43797 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
43798 kgdb_tty_line = tty_line;
43799
43800 do_register:
43801 - err = kgdb_register_io_module(&kgdboc_io_ops);
43802 + if (is_console) {
43803 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
43804 + configured = 2;
43805 + } else {
43806 + err = kgdb_register_io_module(&kgdboc_io_ops);
43807 + configured = 1;
43808 + }
43809 if (err)
43810 goto noconfig;
43811
43812 @@ -205,8 +214,6 @@ do_register:
43813 if (err)
43814 goto nmi_con_failed;
43815
43816 - configured = 1;
43817 -
43818 return 0;
43819
43820 nmi_con_failed:
43821 @@ -223,7 +230,7 @@ noconfig:
43822 static int __init init_kgdboc(void)
43823 {
43824 /* Already configured? */
43825 - if (configured == 1)
43826 + if (configured >= 1)
43827 return 0;
43828
43829 return configure_kgdboc();
43830 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
43831 if (config[len - 1] == '\n')
43832 config[len - 1] = '\0';
43833
43834 - if (configured == 1)
43835 + if (configured >= 1)
43836 cleanup_kgdboc();
43837
43838 /* Go and configure with the new params. */
43839 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
43840 .post_exception = kgdboc_post_exp_handler,
43841 };
43842
43843 +static struct kgdb_io kgdboc_io_ops_console = {
43844 + .name = "kgdboc",
43845 + .read_char = kgdboc_get_char,
43846 + .write_char = kgdboc_put_char,
43847 + .pre_exception = kgdboc_pre_exp_handler,
43848 + .post_exception = kgdboc_post_exp_handler,
43849 + .is_console = 1
43850 +};
43851 +
43852 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
43853 /* This is only available if kgdboc is a built in for early debugging */
43854 static int __init kgdboc_early_init(char *opt)
43855 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
43856 index e514b3a..c73d614 100644
43857 --- a/drivers/tty/serial/samsung.c
43858 +++ b/drivers/tty/serial/samsung.c
43859 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
43860 }
43861 }
43862
43863 +static int s3c64xx_serial_startup(struct uart_port *port);
43864 static int s3c24xx_serial_startup(struct uart_port *port)
43865 {
43866 struct s3c24xx_uart_port *ourport = to_ourport(port);
43867 int ret;
43868
43869 + /* Startup sequence is different for s3c64xx and higher SoC's */
43870 + if (s3c24xx_serial_has_interrupt_mask(port))
43871 + return s3c64xx_serial_startup(port);
43872 +
43873 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
43874 port->mapbase, port->membase);
43875
43876 @@ -1122,10 +1127,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
43877 /* setup info for port */
43878 port->dev = &platdev->dev;
43879
43880 - /* Startup sequence is different for s3c64xx and higher SoC's */
43881 - if (s3c24xx_serial_has_interrupt_mask(port))
43882 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
43883 -
43884 port->uartclk = 1;
43885
43886 if (cfg->uart_flags & UPF_CONS_FLOW) {
43887 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
43888 index 2c7230a..2104f16 100644
43889 --- a/drivers/tty/serial/serial_core.c
43890 +++ b/drivers/tty/serial/serial_core.c
43891 @@ -1455,7 +1455,7 @@ static void uart_hangup(struct tty_struct *tty)
43892 uart_flush_buffer(tty);
43893 uart_shutdown(tty, state);
43894 spin_lock_irqsave(&port->lock, flags);
43895 - port->count = 0;
43896 + atomic_set(&port->count, 0);
43897 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
43898 spin_unlock_irqrestore(&port->lock, flags);
43899 tty_port_tty_set(port, NULL);
43900 @@ -1551,7 +1551,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43901 goto end;
43902 }
43903
43904 - port->count++;
43905 + atomic_inc(&port->count);
43906 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
43907 retval = -ENXIO;
43908 goto err_dec_count;
43909 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43910 /*
43911 * Make sure the device is in D0 state.
43912 */
43913 - if (port->count == 1)
43914 + if (atomic_read(&port->count) == 1)
43915 uart_change_pm(state, 0);
43916
43917 /*
43918 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43919 end:
43920 return retval;
43921 err_dec_count:
43922 - port->count--;
43923 + atomic_inc(&port->count);
43924 mutex_unlock(&port->mutex);
43925 goto end;
43926 }
43927 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
43928 index 9e071f6..f30ae69 100644
43929 --- a/drivers/tty/synclink.c
43930 +++ b/drivers/tty/synclink.c
43931 @@ -3095,7 +3095,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43932
43933 if (debug_level >= DEBUG_LEVEL_INFO)
43934 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
43935 - __FILE__,__LINE__, info->device_name, info->port.count);
43936 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43937
43938 if (tty_port_close_start(&info->port, tty, filp) == 0)
43939 goto cleanup;
43940 @@ -3113,7 +3113,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43941 cleanup:
43942 if (debug_level >= DEBUG_LEVEL_INFO)
43943 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
43944 - tty->driver->name, info->port.count);
43945 + tty->driver->name, atomic_read(&info->port.count));
43946
43947 } /* end of mgsl_close() */
43948
43949 @@ -3212,8 +3212,8 @@ static void mgsl_hangup(struct tty_struct *tty)
43950
43951 mgsl_flush_buffer(tty);
43952 shutdown(info);
43953 -
43954 - info->port.count = 0;
43955 +
43956 + atomic_set(&info->port.count, 0);
43957 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43958 info->port.tty = NULL;
43959
43960 @@ -3302,12 +3302,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43961
43962 if (debug_level >= DEBUG_LEVEL_INFO)
43963 printk("%s(%d):block_til_ready before block on %s count=%d\n",
43964 - __FILE__,__LINE__, tty->driver->name, port->count );
43965 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43966
43967 spin_lock_irqsave(&info->irq_spinlock, flags);
43968 if (!tty_hung_up_p(filp)) {
43969 extra_count = true;
43970 - port->count--;
43971 + atomic_dec(&port->count);
43972 }
43973 spin_unlock_irqrestore(&info->irq_spinlock, flags);
43974 port->blocked_open++;
43975 @@ -3336,7 +3336,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43976
43977 if (debug_level >= DEBUG_LEVEL_INFO)
43978 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
43979 - __FILE__,__LINE__, tty->driver->name, port->count );
43980 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43981
43982 tty_unlock(tty);
43983 schedule();
43984 @@ -3348,12 +3348,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43985
43986 /* FIXME: Racy on hangup during close wait */
43987 if (extra_count)
43988 - port->count++;
43989 + atomic_inc(&port->count);
43990 port->blocked_open--;
43991
43992 if (debug_level >= DEBUG_LEVEL_INFO)
43993 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
43994 - __FILE__,__LINE__, tty->driver->name, port->count );
43995 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43996
43997 if (!retval)
43998 port->flags |= ASYNC_NORMAL_ACTIVE;
43999 @@ -3405,7 +3405,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
44000
44001 if (debug_level >= DEBUG_LEVEL_INFO)
44002 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
44003 - __FILE__,__LINE__,tty->driver->name, info->port.count);
44004 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
44005
44006 /* If port is closing, signal caller to try again */
44007 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44008 @@ -3424,10 +3424,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
44009 spin_unlock_irqrestore(&info->netlock, flags);
44010 goto cleanup;
44011 }
44012 - info->port.count++;
44013 + atomic_inc(&info->port.count);
44014 spin_unlock_irqrestore(&info->netlock, flags);
44015
44016 - if (info->port.count == 1) {
44017 + if (atomic_read(&info->port.count) == 1) {
44018 /* 1st open on this device, init hardware */
44019 retval = startup(info);
44020 if (retval < 0)
44021 @@ -3451,8 +3451,8 @@ cleanup:
44022 if (retval) {
44023 if (tty->count == 1)
44024 info->port.tty = NULL; /* tty layer will release tty struct */
44025 - if(info->port.count)
44026 - info->port.count--;
44027 + if (atomic_read(&info->port.count))
44028 + atomic_dec(&info->port.count);
44029 }
44030
44031 return retval;
44032 @@ -7662,7 +7662,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44033 unsigned short new_crctype;
44034
44035 /* return error if TTY interface open */
44036 - if (info->port.count)
44037 + if (atomic_read(&info->port.count))
44038 return -EBUSY;
44039
44040 switch (encoding)
44041 @@ -7757,7 +7757,7 @@ static int hdlcdev_open(struct net_device *dev)
44042
44043 /* arbitrate between network and tty opens */
44044 spin_lock_irqsave(&info->netlock, flags);
44045 - if (info->port.count != 0 || info->netcount != 0) {
44046 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44047 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44048 spin_unlock_irqrestore(&info->netlock, flags);
44049 return -EBUSY;
44050 @@ -7843,7 +7843,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44051 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44052
44053 /* return error if TTY interface open */
44054 - if (info->port.count)
44055 + if (atomic_read(&info->port.count))
44056 return -EBUSY;
44057
44058 if (cmd != SIOCWANDEV)
44059 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
44060 index aba1e59..877ac33 100644
44061 --- a/drivers/tty/synclink_gt.c
44062 +++ b/drivers/tty/synclink_gt.c
44063 @@ -671,7 +671,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44064 tty->driver_data = info;
44065 info->port.tty = tty;
44066
44067 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
44068 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
44069
44070 /* If port is closing, signal caller to try again */
44071 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44072 @@ -692,10 +692,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44073 mutex_unlock(&info->port.mutex);
44074 goto cleanup;
44075 }
44076 - info->port.count++;
44077 + atomic_inc(&info->port.count);
44078 spin_unlock_irqrestore(&info->netlock, flags);
44079
44080 - if (info->port.count == 1) {
44081 + if (atomic_read(&info->port.count) == 1) {
44082 /* 1st open on this device, init hardware */
44083 retval = startup(info);
44084 if (retval < 0) {
44085 @@ -716,8 +716,8 @@ cleanup:
44086 if (retval) {
44087 if (tty->count == 1)
44088 info->port.tty = NULL; /* tty layer will release tty struct */
44089 - if(info->port.count)
44090 - info->port.count--;
44091 + if(atomic_read(&info->port.count))
44092 + atomic_dec(&info->port.count);
44093 }
44094
44095 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
44096 @@ -730,7 +730,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44097
44098 if (sanity_check(info, tty->name, "close"))
44099 return;
44100 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
44101 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
44102
44103 if (tty_port_close_start(&info->port, tty, filp) == 0)
44104 goto cleanup;
44105 @@ -747,7 +747,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44106 tty_port_close_end(&info->port, tty);
44107 info->port.tty = NULL;
44108 cleanup:
44109 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
44110 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
44111 }
44112
44113 static void hangup(struct tty_struct *tty)
44114 @@ -765,7 +765,7 @@ static void hangup(struct tty_struct *tty)
44115 shutdown(info);
44116
44117 spin_lock_irqsave(&info->port.lock, flags);
44118 - info->port.count = 0;
44119 + atomic_set(&info->port.count, 0);
44120 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44121 info->port.tty = NULL;
44122 spin_unlock_irqrestore(&info->port.lock, flags);
44123 @@ -1450,7 +1450,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44124 unsigned short new_crctype;
44125
44126 /* return error if TTY interface open */
44127 - if (info->port.count)
44128 + if (atomic_read(&info->port.count))
44129 return -EBUSY;
44130
44131 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
44132 @@ -1545,7 +1545,7 @@ static int hdlcdev_open(struct net_device *dev)
44133
44134 /* arbitrate between network and tty opens */
44135 spin_lock_irqsave(&info->netlock, flags);
44136 - if (info->port.count != 0 || info->netcount != 0) {
44137 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44138 DBGINFO(("%s hdlc_open busy\n", dev->name));
44139 spin_unlock_irqrestore(&info->netlock, flags);
44140 return -EBUSY;
44141 @@ -1630,7 +1630,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44142 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
44143
44144 /* return error if TTY interface open */
44145 - if (info->port.count)
44146 + if (atomic_read(&info->port.count))
44147 return -EBUSY;
44148
44149 if (cmd != SIOCWANDEV)
44150 @@ -2419,7 +2419,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
44151 if (port == NULL)
44152 continue;
44153 spin_lock(&port->lock);
44154 - if ((port->port.count || port->netcount) &&
44155 + if ((atomic_read(&port->port.count) || port->netcount) &&
44156 port->pending_bh && !port->bh_running &&
44157 !port->bh_requested) {
44158 DBGISR(("%s bh queued\n", port->device_name));
44159 @@ -3308,7 +3308,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44160 spin_lock_irqsave(&info->lock, flags);
44161 if (!tty_hung_up_p(filp)) {
44162 extra_count = true;
44163 - port->count--;
44164 + atomic_dec(&port->count);
44165 }
44166 spin_unlock_irqrestore(&info->lock, flags);
44167 port->blocked_open++;
44168 @@ -3345,7 +3345,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44169 remove_wait_queue(&port->open_wait, &wait);
44170
44171 if (extra_count)
44172 - port->count++;
44173 + atomic_inc(&port->count);
44174 port->blocked_open--;
44175
44176 if (!retval)
44177 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
44178 index fd43fb6..34704ad 100644
44179 --- a/drivers/tty/synclinkmp.c
44180 +++ b/drivers/tty/synclinkmp.c
44181 @@ -751,7 +751,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44182
44183 if (debug_level >= DEBUG_LEVEL_INFO)
44184 printk("%s(%d):%s open(), old ref count = %d\n",
44185 - __FILE__,__LINE__,tty->driver->name, info->port.count);
44186 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
44187
44188 /* If port is closing, signal caller to try again */
44189 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44190 @@ -770,10 +770,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44191 spin_unlock_irqrestore(&info->netlock, flags);
44192 goto cleanup;
44193 }
44194 - info->port.count++;
44195 + atomic_inc(&info->port.count);
44196 spin_unlock_irqrestore(&info->netlock, flags);
44197
44198 - if (info->port.count == 1) {
44199 + if (atomic_read(&info->port.count) == 1) {
44200 /* 1st open on this device, init hardware */
44201 retval = startup(info);
44202 if (retval < 0)
44203 @@ -797,8 +797,8 @@ cleanup:
44204 if (retval) {
44205 if (tty->count == 1)
44206 info->port.tty = NULL; /* tty layer will release tty struct */
44207 - if(info->port.count)
44208 - info->port.count--;
44209 + if(atomic_read(&info->port.count))
44210 + atomic_dec(&info->port.count);
44211 }
44212
44213 return retval;
44214 @@ -816,7 +816,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44215
44216 if (debug_level >= DEBUG_LEVEL_INFO)
44217 printk("%s(%d):%s close() entry, count=%d\n",
44218 - __FILE__,__LINE__, info->device_name, info->port.count);
44219 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
44220
44221 if (tty_port_close_start(&info->port, tty, filp) == 0)
44222 goto cleanup;
44223 @@ -835,7 +835,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44224 cleanup:
44225 if (debug_level >= DEBUG_LEVEL_INFO)
44226 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
44227 - tty->driver->name, info->port.count);
44228 + tty->driver->name, atomic_read(&info->port.count));
44229 }
44230
44231 /* Called by tty_hangup() when a hangup is signaled.
44232 @@ -858,7 +858,7 @@ static void hangup(struct tty_struct *tty)
44233 shutdown(info);
44234
44235 spin_lock_irqsave(&info->port.lock, flags);
44236 - info->port.count = 0;
44237 + atomic_set(&info->port.count, 0);
44238 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44239 info->port.tty = NULL;
44240 spin_unlock_irqrestore(&info->port.lock, flags);
44241 @@ -1566,7 +1566,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44242 unsigned short new_crctype;
44243
44244 /* return error if TTY interface open */
44245 - if (info->port.count)
44246 + if (atomic_read(&info->port.count))
44247 return -EBUSY;
44248
44249 switch (encoding)
44250 @@ -1661,7 +1661,7 @@ static int hdlcdev_open(struct net_device *dev)
44251
44252 /* arbitrate between network and tty opens */
44253 spin_lock_irqsave(&info->netlock, flags);
44254 - if (info->port.count != 0 || info->netcount != 0) {
44255 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44256 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44257 spin_unlock_irqrestore(&info->netlock, flags);
44258 return -EBUSY;
44259 @@ -1747,7 +1747,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44260 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44261
44262 /* return error if TTY interface open */
44263 - if (info->port.count)
44264 + if (atomic_read(&info->port.count))
44265 return -EBUSY;
44266
44267 if (cmd != SIOCWANDEV)
44268 @@ -2632,7 +2632,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
44269 * do not request bottom half processing if the
44270 * device is not open in a normal mode.
44271 */
44272 - if ( port && (port->port.count || port->netcount) &&
44273 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
44274 port->pending_bh && !port->bh_running &&
44275 !port->bh_requested ) {
44276 if ( debug_level >= DEBUG_LEVEL_ISR )
44277 @@ -3330,12 +3330,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44278
44279 if (debug_level >= DEBUG_LEVEL_INFO)
44280 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
44281 - __FILE__,__LINE__, tty->driver->name, port->count );
44282 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44283
44284 spin_lock_irqsave(&info->lock, flags);
44285 if (!tty_hung_up_p(filp)) {
44286 extra_count = true;
44287 - port->count--;
44288 + atomic_dec(&port->count);
44289 }
44290 spin_unlock_irqrestore(&info->lock, flags);
44291 port->blocked_open++;
44292 @@ -3364,7 +3364,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44293
44294 if (debug_level >= DEBUG_LEVEL_INFO)
44295 printk("%s(%d):%s block_til_ready() count=%d\n",
44296 - __FILE__,__LINE__, tty->driver->name, port->count );
44297 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44298
44299 tty_unlock(tty);
44300 schedule();
44301 @@ -3375,12 +3375,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44302 remove_wait_queue(&port->open_wait, &wait);
44303
44304 if (extra_count)
44305 - port->count++;
44306 + atomic_inc(&port->count);
44307 port->blocked_open--;
44308
44309 if (debug_level >= DEBUG_LEVEL_INFO)
44310 printk("%s(%d):%s block_til_ready() after, count=%d\n",
44311 - __FILE__,__LINE__, tty->driver->name, port->count );
44312 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44313
44314 if (!retval)
44315 port->flags |= ASYNC_NORMAL_ACTIVE;
44316 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
44317 index b3c4a25..723916f 100644
44318 --- a/drivers/tty/sysrq.c
44319 +++ b/drivers/tty/sysrq.c
44320 @@ -867,7 +867,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
44321 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
44322 size_t count, loff_t *ppos)
44323 {
44324 - if (count) {
44325 + if (count && capable(CAP_SYS_ADMIN)) {
44326 char c;
44327
44328 if (get_user(c, buf))
44329 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
44330 index da9fde8..c07975f 100644
44331 --- a/drivers/tty/tty_io.c
44332 +++ b/drivers/tty/tty_io.c
44333 @@ -3391,7 +3391,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
44334
44335 void tty_default_fops(struct file_operations *fops)
44336 {
44337 - *fops = tty_fops;
44338 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
44339 }
44340
44341 /*
44342 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
44343 index c578229..45aa9ee 100644
44344 --- a/drivers/tty/tty_ldisc.c
44345 +++ b/drivers/tty/tty_ldisc.c
44346 @@ -56,7 +56,7 @@ static void put_ldisc(struct tty_ldisc *ld)
44347 if (atomic_dec_and_test(&ld->users)) {
44348 struct tty_ldisc_ops *ldo = ld->ops;
44349
44350 - ldo->refcount--;
44351 + atomic_dec(&ldo->refcount);
44352 module_put(ldo->owner);
44353 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44354
44355 @@ -91,7 +91,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
44356 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44357 tty_ldiscs[disc] = new_ldisc;
44358 new_ldisc->num = disc;
44359 - new_ldisc->refcount = 0;
44360 + atomic_set(&new_ldisc->refcount, 0);
44361 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44362
44363 return ret;
44364 @@ -119,7 +119,7 @@ int tty_unregister_ldisc(int disc)
44365 return -EINVAL;
44366
44367 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44368 - if (tty_ldiscs[disc]->refcount)
44369 + if (atomic_read(&tty_ldiscs[disc]->refcount))
44370 ret = -EBUSY;
44371 else
44372 tty_ldiscs[disc] = NULL;
44373 @@ -140,7 +140,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
44374 if (ldops) {
44375 ret = ERR_PTR(-EAGAIN);
44376 if (try_module_get(ldops->owner)) {
44377 - ldops->refcount++;
44378 + atomic_inc(&ldops->refcount);
44379 ret = ldops;
44380 }
44381 }
44382 @@ -153,7 +153,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
44383 unsigned long flags;
44384
44385 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44386 - ldops->refcount--;
44387 + atomic_dec(&ldops->refcount);
44388 module_put(ldops->owner);
44389 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44390 }
44391 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
44392 index b7ff59d..7c6105e 100644
44393 --- a/drivers/tty/tty_port.c
44394 +++ b/drivers/tty/tty_port.c
44395 @@ -218,7 +218,7 @@ void tty_port_hangup(struct tty_port *port)
44396 unsigned long flags;
44397
44398 spin_lock_irqsave(&port->lock, flags);
44399 - port->count = 0;
44400 + atomic_set(&port->count, 0);
44401 port->flags &= ~ASYNC_NORMAL_ACTIVE;
44402 if (port->tty) {
44403 set_bit(TTY_IO_ERROR, &port->tty->flags);
44404 @@ -344,7 +344,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44405 /* The port lock protects the port counts */
44406 spin_lock_irqsave(&port->lock, flags);
44407 if (!tty_hung_up_p(filp))
44408 - port->count--;
44409 + atomic_dec(&port->count);
44410 port->blocked_open++;
44411 spin_unlock_irqrestore(&port->lock, flags);
44412
44413 @@ -386,7 +386,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44414 we must not mess that up further */
44415 spin_lock_irqsave(&port->lock, flags);
44416 if (!tty_hung_up_p(filp))
44417 - port->count++;
44418 + atomic_inc(&port->count);
44419 port->blocked_open--;
44420 if (retval == 0)
44421 port->flags |= ASYNC_NORMAL_ACTIVE;
44422 @@ -406,19 +406,19 @@ int tty_port_close_start(struct tty_port *port,
44423 return 0;
44424 }
44425
44426 - if (tty->count == 1 && port->count != 1) {
44427 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
44428 printk(KERN_WARNING
44429 "tty_port_close_start: tty->count = 1 port count = %d.\n",
44430 - port->count);
44431 - port->count = 1;
44432 + atomic_read(&port->count));
44433 + atomic_set(&port->count, 1);
44434 }
44435 - if (--port->count < 0) {
44436 + if (atomic_dec_return(&port->count) < 0) {
44437 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
44438 - port->count);
44439 - port->count = 0;
44440 + atomic_read(&port->count));
44441 + atomic_set(&port->count, 0);
44442 }
44443
44444 - if (port->count) {
44445 + if (atomic_read(&port->count)) {
44446 spin_unlock_irqrestore(&port->lock, flags);
44447 if (port->ops->drop)
44448 port->ops->drop(port);
44449 @@ -516,7 +516,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
44450 {
44451 spin_lock_irq(&port->lock);
44452 if (!tty_hung_up_p(filp))
44453 - ++port->count;
44454 + atomic_inc(&port->count);
44455 spin_unlock_irq(&port->lock);
44456 tty_port_tty_set(port, tty);
44457
44458 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
44459 index 681765b..d3ccdf2 100644
44460 --- a/drivers/tty/vt/keyboard.c
44461 +++ b/drivers/tty/vt/keyboard.c
44462 @@ -660,6 +660,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
44463 kbd->kbdmode == VC_OFF) &&
44464 value != KVAL(K_SAK))
44465 return; /* SAK is allowed even in raw mode */
44466 +
44467 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
44468 + {
44469 + void *func = fn_handler[value];
44470 + if (func == fn_show_state || func == fn_show_ptregs ||
44471 + func == fn_show_mem)
44472 + return;
44473 + }
44474 +#endif
44475 +
44476 fn_handler[value](vc);
44477 }
44478
44479 @@ -1808,9 +1818,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44480 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
44481 return -EFAULT;
44482
44483 - if (!capable(CAP_SYS_TTY_CONFIG))
44484 - perm = 0;
44485 -
44486 switch (cmd) {
44487 case KDGKBENT:
44488 /* Ensure another thread doesn't free it under us */
44489 @@ -1825,6 +1832,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44490 spin_unlock_irqrestore(&kbd_event_lock, flags);
44491 return put_user(val, &user_kbe->kb_value);
44492 case KDSKBENT:
44493 + if (!capable(CAP_SYS_TTY_CONFIG))
44494 + perm = 0;
44495 +
44496 if (!perm)
44497 return -EPERM;
44498 if (!i && v == K_NOSUCHMAP) {
44499 @@ -1915,9 +1925,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44500 int i, j, k;
44501 int ret;
44502
44503 - if (!capable(CAP_SYS_TTY_CONFIG))
44504 - perm = 0;
44505 -
44506 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
44507 if (!kbs) {
44508 ret = -ENOMEM;
44509 @@ -1951,6 +1958,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44510 kfree(kbs);
44511 return ((p && *p) ? -EOVERFLOW : 0);
44512 case KDSKBSENT:
44513 + if (!capable(CAP_SYS_TTY_CONFIG))
44514 + perm = 0;
44515 +
44516 if (!perm) {
44517 ret = -EPERM;
44518 goto reterr;
44519 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
44520 index 5110f36..8dc0a74 100644
44521 --- a/drivers/uio/uio.c
44522 +++ b/drivers/uio/uio.c
44523 @@ -25,6 +25,7 @@
44524 #include <linux/kobject.h>
44525 #include <linux/cdev.h>
44526 #include <linux/uio_driver.h>
44527 +#include <asm/local.h>
44528
44529 #define UIO_MAX_DEVICES (1U << MINORBITS)
44530
44531 @@ -32,10 +33,10 @@ struct uio_device {
44532 struct module *owner;
44533 struct device *dev;
44534 int minor;
44535 - atomic_t event;
44536 + atomic_unchecked_t event;
44537 struct fasync_struct *async_queue;
44538 wait_queue_head_t wait;
44539 - int vma_count;
44540 + local_t vma_count;
44541 struct uio_info *info;
44542 struct kobject *map_dir;
44543 struct kobject *portio_dir;
44544 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
44545 struct device_attribute *attr, char *buf)
44546 {
44547 struct uio_device *idev = dev_get_drvdata(dev);
44548 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
44549 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
44550 }
44551
44552 static struct device_attribute uio_class_attributes[] = {
44553 @@ -408,7 +409,7 @@ void uio_event_notify(struct uio_info *info)
44554 {
44555 struct uio_device *idev = info->uio_dev;
44556
44557 - atomic_inc(&idev->event);
44558 + atomic_inc_unchecked(&idev->event);
44559 wake_up_interruptible(&idev->wait);
44560 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
44561 }
44562 @@ -461,7 +462,7 @@ static int uio_open(struct inode *inode, struct file *filep)
44563 }
44564
44565 listener->dev = idev;
44566 - listener->event_count = atomic_read(&idev->event);
44567 + listener->event_count = atomic_read_unchecked(&idev->event);
44568 filep->private_data = listener;
44569
44570 if (idev->info->open) {
44571 @@ -512,7 +513,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
44572 return -EIO;
44573
44574 poll_wait(filep, &idev->wait, wait);
44575 - if (listener->event_count != atomic_read(&idev->event))
44576 + if (listener->event_count != atomic_read_unchecked(&idev->event))
44577 return POLLIN | POLLRDNORM;
44578 return 0;
44579 }
44580 @@ -537,7 +538,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
44581 do {
44582 set_current_state(TASK_INTERRUPTIBLE);
44583
44584 - event_count = atomic_read(&idev->event);
44585 + event_count = atomic_read_unchecked(&idev->event);
44586 if (event_count != listener->event_count) {
44587 if (copy_to_user(buf, &event_count, count))
44588 retval = -EFAULT;
44589 @@ -606,13 +607,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
44590 static void uio_vma_open(struct vm_area_struct *vma)
44591 {
44592 struct uio_device *idev = vma->vm_private_data;
44593 - idev->vma_count++;
44594 + local_inc(&idev->vma_count);
44595 }
44596
44597 static void uio_vma_close(struct vm_area_struct *vma)
44598 {
44599 struct uio_device *idev = vma->vm_private_data;
44600 - idev->vma_count--;
44601 + local_dec(&idev->vma_count);
44602 }
44603
44604 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
44605 @@ -819,7 +820,7 @@ int __uio_register_device(struct module *owner,
44606 idev->owner = owner;
44607 idev->info = info;
44608 init_waitqueue_head(&idev->wait);
44609 - atomic_set(&idev->event, 0);
44610 + atomic_set_unchecked(&idev->event, 0);
44611
44612 ret = uio_get_minor(idev);
44613 if (ret)
44614 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
44615 index b7eb86a..36d28af 100644
44616 --- a/drivers/usb/atm/cxacru.c
44617 +++ b/drivers/usb/atm/cxacru.c
44618 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
44619 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
44620 if (ret < 2)
44621 return -EINVAL;
44622 - if (index < 0 || index > 0x7f)
44623 + if (index > 0x7f)
44624 return -EINVAL;
44625 pos += tmp;
44626
44627 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
44628 index 35f10bf..6a38a0b 100644
44629 --- a/drivers/usb/atm/usbatm.c
44630 +++ b/drivers/usb/atm/usbatm.c
44631 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44632 if (printk_ratelimit())
44633 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
44634 __func__, vpi, vci);
44635 - atomic_inc(&vcc->stats->rx_err);
44636 + atomic_inc_unchecked(&vcc->stats->rx_err);
44637 return;
44638 }
44639
44640 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44641 if (length > ATM_MAX_AAL5_PDU) {
44642 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
44643 __func__, length, vcc);
44644 - atomic_inc(&vcc->stats->rx_err);
44645 + atomic_inc_unchecked(&vcc->stats->rx_err);
44646 goto out;
44647 }
44648
44649 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44650 if (sarb->len < pdu_length) {
44651 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
44652 __func__, pdu_length, sarb->len, vcc);
44653 - atomic_inc(&vcc->stats->rx_err);
44654 + atomic_inc_unchecked(&vcc->stats->rx_err);
44655 goto out;
44656 }
44657
44658 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
44659 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
44660 __func__, vcc);
44661 - atomic_inc(&vcc->stats->rx_err);
44662 + atomic_inc_unchecked(&vcc->stats->rx_err);
44663 goto out;
44664 }
44665
44666 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44667 if (printk_ratelimit())
44668 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
44669 __func__, length);
44670 - atomic_inc(&vcc->stats->rx_drop);
44671 + atomic_inc_unchecked(&vcc->stats->rx_drop);
44672 goto out;
44673 }
44674
44675 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44676
44677 vcc->push(vcc, skb);
44678
44679 - atomic_inc(&vcc->stats->rx);
44680 + atomic_inc_unchecked(&vcc->stats->rx);
44681 out:
44682 skb_trim(sarb, 0);
44683 }
44684 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
44685 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
44686
44687 usbatm_pop(vcc, skb);
44688 - atomic_inc(&vcc->stats->tx);
44689 + atomic_inc_unchecked(&vcc->stats->tx);
44690
44691 skb = skb_dequeue(&instance->sndqueue);
44692 }
44693 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
44694 if (!left--)
44695 return sprintf(page,
44696 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
44697 - atomic_read(&atm_dev->stats.aal5.tx),
44698 - atomic_read(&atm_dev->stats.aal5.tx_err),
44699 - atomic_read(&atm_dev->stats.aal5.rx),
44700 - atomic_read(&atm_dev->stats.aal5.rx_err),
44701 - atomic_read(&atm_dev->stats.aal5.rx_drop));
44702 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
44703 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
44704 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
44705 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
44706 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
44707
44708 if (!left--) {
44709 if (instance->disconnected)
44710 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
44711 index cbacea9..246cccd 100644
44712 --- a/drivers/usb/core/devices.c
44713 +++ b/drivers/usb/core/devices.c
44714 @@ -126,7 +126,7 @@ static const char format_endpt[] =
44715 * time it gets called.
44716 */
44717 static struct device_connect_event {
44718 - atomic_t count;
44719 + atomic_unchecked_t count;
44720 wait_queue_head_t wait;
44721 } device_event = {
44722 .count = ATOMIC_INIT(1),
44723 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
44724
44725 void usbfs_conn_disc_event(void)
44726 {
44727 - atomic_add(2, &device_event.count);
44728 + atomic_add_unchecked(2, &device_event.count);
44729 wake_up(&device_event.wait);
44730 }
44731
44732 @@ -645,7 +645,7 @@ static unsigned int usb_device_poll(struct file *file,
44733
44734 poll_wait(file, &device_event.wait, wait);
44735
44736 - event_count = atomic_read(&device_event.count);
44737 + event_count = atomic_read_unchecked(&device_event.count);
44738 if (file->f_version != event_count) {
44739 file->f_version = event_count;
44740 return POLLIN | POLLRDNORM;
44741 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
44742 index 8e64adf..9a33a3c 100644
44743 --- a/drivers/usb/core/hcd.c
44744 +++ b/drivers/usb/core/hcd.c
44745 @@ -1522,7 +1522,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44746 */
44747 usb_get_urb(urb);
44748 atomic_inc(&urb->use_count);
44749 - atomic_inc(&urb->dev->urbnum);
44750 + atomic_inc_unchecked(&urb->dev->urbnum);
44751 usbmon_urb_submit(&hcd->self, urb);
44752
44753 /* NOTE requirements on root-hub callers (usbfs and the hub
44754 @@ -1549,7 +1549,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44755 urb->hcpriv = NULL;
44756 INIT_LIST_HEAD(&urb->urb_list);
44757 atomic_dec(&urb->use_count);
44758 - atomic_dec(&urb->dev->urbnum);
44759 + atomic_dec_unchecked(&urb->dev->urbnum);
44760 if (atomic_read(&urb->reject))
44761 wake_up(&usb_kill_urb_queue);
44762 usb_put_urb(urb);
44763 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
44764 index 131f736..99004c3 100644
44765 --- a/drivers/usb/core/message.c
44766 +++ b/drivers/usb/core/message.c
44767 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
44768 * method can wait for it to complete. Since you don't have a handle on the
44769 * URB used, you can't cancel the request.
44770 */
44771 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44772 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44773 __u8 requesttype, __u16 value, __u16 index, void *data,
44774 __u16 size, int timeout)
44775 {
44776 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
44777 index 818e4a0..0fc9589 100644
44778 --- a/drivers/usb/core/sysfs.c
44779 +++ b/drivers/usb/core/sysfs.c
44780 @@ -226,7 +226,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
44781 struct usb_device *udev;
44782
44783 udev = to_usb_device(dev);
44784 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
44785 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
44786 }
44787 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
44788
44789 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
44790 index f81b925..78d22ec 100644
44791 --- a/drivers/usb/core/usb.c
44792 +++ b/drivers/usb/core/usb.c
44793 @@ -388,7 +388,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
44794 set_dev_node(&dev->dev, dev_to_node(bus->controller));
44795 dev->state = USB_STATE_ATTACHED;
44796 dev->lpm_disable_count = 1;
44797 - atomic_set(&dev->urbnum, 0);
44798 + atomic_set_unchecked(&dev->urbnum, 0);
44799
44800 INIT_LIST_HEAD(&dev->ep0.urb_list);
44801 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
44802 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
44803 index 5e29dde..eca992f 100644
44804 --- a/drivers/usb/early/ehci-dbgp.c
44805 +++ b/drivers/usb/early/ehci-dbgp.c
44806 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
44807
44808 #ifdef CONFIG_KGDB
44809 static struct kgdb_io kgdbdbgp_io_ops;
44810 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
44811 +static struct kgdb_io kgdbdbgp_io_ops_console;
44812 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
44813 #else
44814 #define dbgp_kgdb_mode (0)
44815 #endif
44816 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
44817 .write_char = kgdbdbgp_write_char,
44818 };
44819
44820 +static struct kgdb_io kgdbdbgp_io_ops_console = {
44821 + .name = "kgdbdbgp",
44822 + .read_char = kgdbdbgp_read_char,
44823 + .write_char = kgdbdbgp_write_char,
44824 + .is_console = 1
44825 +};
44826 +
44827 static int kgdbdbgp_wait_time;
44828
44829 static int __init kgdbdbgp_parse_config(char *str)
44830 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
44831 ptr++;
44832 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
44833 }
44834 - kgdb_register_io_module(&kgdbdbgp_io_ops);
44835 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
44836 + if (early_dbgp_console.index != -1)
44837 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
44838 + else
44839 + kgdb_register_io_module(&kgdbdbgp_io_ops);
44840
44841 return 0;
44842 }
44843 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
44844 index 598dcc1..032dd4f 100644
44845 --- a/drivers/usb/gadget/u_serial.c
44846 +++ b/drivers/usb/gadget/u_serial.c
44847 @@ -735,9 +735,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44848 spin_lock_irq(&port->port_lock);
44849
44850 /* already open? Great. */
44851 - if (port->port.count) {
44852 + if (atomic_read(&port->port.count)) {
44853 status = 0;
44854 - port->port.count++;
44855 + atomic_inc(&port->port.count);
44856
44857 /* currently opening/closing? wait ... */
44858 } else if (port->openclose) {
44859 @@ -796,7 +796,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44860 tty->driver_data = port;
44861 port->port.tty = tty;
44862
44863 - port->port.count = 1;
44864 + atomic_set(&port->port.count, 1);
44865 port->openclose = false;
44866
44867 /* if connected, start the I/O stream */
44868 @@ -838,11 +838,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44869
44870 spin_lock_irq(&port->port_lock);
44871
44872 - if (port->port.count != 1) {
44873 - if (port->port.count == 0)
44874 + if (atomic_read(&port->port.count) != 1) {
44875 + if (atomic_read(&port->port.count) == 0)
44876 WARN_ON(1);
44877 else
44878 - --port->port.count;
44879 + atomic_dec(&port->port.count);
44880 goto exit;
44881 }
44882
44883 @@ -852,7 +852,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44884 * and sleep if necessary
44885 */
44886 port->openclose = true;
44887 - port->port.count = 0;
44888 + atomic_set(&port->port.count, 0);
44889
44890 gser = port->port_usb;
44891 if (gser && gser->disconnect)
44892 @@ -1159,7 +1159,7 @@ static int gs_closed(struct gs_port *port)
44893 int cond;
44894
44895 spin_lock_irq(&port->port_lock);
44896 - cond = (port->port.count == 0) && !port->openclose;
44897 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
44898 spin_unlock_irq(&port->port_lock);
44899 return cond;
44900 }
44901 @@ -1273,7 +1273,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
44902 /* if it's already open, start I/O ... and notify the serial
44903 * protocol about open/close status (connect/disconnect).
44904 */
44905 - if (port->port.count) {
44906 + if (atomic_read(&port->port.count)) {
44907 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
44908 gs_start_io(port);
44909 if (gser->connect)
44910 @@ -1320,7 +1320,7 @@ void gserial_disconnect(struct gserial *gser)
44911
44912 port->port_usb = NULL;
44913 gser->ioport = NULL;
44914 - if (port->port.count > 0 || port->openclose) {
44915 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
44916 wake_up_interruptible(&port->drain_wait);
44917 if (port->port.tty)
44918 tty_hangup(port->port.tty);
44919 @@ -1336,7 +1336,7 @@ void gserial_disconnect(struct gserial *gser)
44920
44921 /* finally, free any unused/unusable I/O buffers */
44922 spin_lock_irqsave(&port->port_lock, flags);
44923 - if (port->port.count == 0 && !port->openclose)
44924 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
44925 gs_buf_free(&port->port_write_buf);
44926 gs_free_requests(gser->out, &port->read_pool, NULL);
44927 gs_free_requests(gser->out, &port->read_queue, NULL);
44928 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
44929 index 5f3bcd3..bfca43f 100644
44930 --- a/drivers/usb/serial/console.c
44931 +++ b/drivers/usb/serial/console.c
44932 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
44933
44934 info->port = port;
44935
44936 - ++port->port.count;
44937 + atomic_inc(&port->port.count);
44938 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
44939 if (serial->type->set_termios) {
44940 /*
44941 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
44942 }
44943 /* Now that any required fake tty operations are completed restore
44944 * the tty port count */
44945 - --port->port.count;
44946 + atomic_dec(&port->port.count);
44947 /* The console is special in terms of closing the device so
44948 * indicate this port is now acting as a system console. */
44949 port->port.console = 1;
44950 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
44951 free_tty:
44952 kfree(tty);
44953 reset_open_count:
44954 - port->port.count = 0;
44955 + atomic_set(&port->port.count, 0);
44956 usb_autopm_put_interface(serial->interface);
44957 error_get_interface:
44958 usb_serial_put(serial);
44959 diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
44960 index 6c3586a..a94e621 100644
44961 --- a/drivers/usb/storage/realtek_cr.c
44962 +++ b/drivers/usb/storage/realtek_cr.c
44963 @@ -429,7 +429,7 @@ static int rts51x_read_status(struct us_data *us,
44964
44965 buf = kmalloc(len, GFP_NOIO);
44966 if (buf == NULL)
44967 - return USB_STOR_TRANSPORT_ERROR;
44968 + return -ENOMEM;
44969
44970 US_DEBUGP("%s, lun = %d\n", __func__, lun);
44971
44972 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
44973 index 75f70f0..d467e1a 100644
44974 --- a/drivers/usb/storage/usb.h
44975 +++ b/drivers/usb/storage/usb.h
44976 @@ -63,7 +63,7 @@ struct us_unusual_dev {
44977 __u8 useProtocol;
44978 __u8 useTransport;
44979 int (*initFunction)(struct us_data *);
44980 -};
44981 +} __do_const;
44982
44983
44984 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
44985 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
44986 index d6bea3e..60b250e 100644
44987 --- a/drivers/usb/wusbcore/wa-hc.h
44988 +++ b/drivers/usb/wusbcore/wa-hc.h
44989 @@ -192,7 +192,7 @@ struct wahc {
44990 struct list_head xfer_delayed_list;
44991 spinlock_t xfer_list_lock;
44992 struct work_struct xfer_work;
44993 - atomic_t xfer_id_count;
44994 + atomic_unchecked_t xfer_id_count;
44995 };
44996
44997
44998 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
44999 INIT_LIST_HEAD(&wa->xfer_delayed_list);
45000 spin_lock_init(&wa->xfer_list_lock);
45001 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
45002 - atomic_set(&wa->xfer_id_count, 1);
45003 + atomic_set_unchecked(&wa->xfer_id_count, 1);
45004 }
45005
45006 /**
45007 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
45008 index 57c01ab..8a05959 100644
45009 --- a/drivers/usb/wusbcore/wa-xfer.c
45010 +++ b/drivers/usb/wusbcore/wa-xfer.c
45011 @@ -296,7 +296,7 @@ out:
45012 */
45013 static void wa_xfer_id_init(struct wa_xfer *xfer)
45014 {
45015 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
45016 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
45017 }
45018
45019 /*
45020 diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
45021 index b28e66c..4a62e12 100644
45022 --- a/drivers/vfio/pci/vfio_pci.c
45023 +++ b/drivers/vfio/pci/vfio_pci.c
45024 @@ -331,6 +331,7 @@ static long vfio_pci_ioctl(void *device_data,
45025
45026 if (!(hdr.flags & VFIO_IRQ_SET_DATA_NONE)) {
45027 size_t size;
45028 + int max = vfio_pci_get_irq_count(vdev, hdr.index);
45029
45030 if (hdr.flags & VFIO_IRQ_SET_DATA_BOOL)
45031 size = sizeof(uint8_t);
45032 @@ -340,7 +341,7 @@ static long vfio_pci_ioctl(void *device_data,
45033 return -EINVAL;
45034
45035 if (hdr.argsz - minsz < hdr.count * size ||
45036 - hdr.count > vfio_pci_get_irq_count(vdev, hdr.index))
45037 + hdr.start >= max || hdr.start + hdr.count > max)
45038 return -EINVAL;
45039
45040 data = memdup_user((void __user *)(arg + minsz),
45041 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
45042 index 8c55011..eed4ae1a 100644
45043 --- a/drivers/video/aty/aty128fb.c
45044 +++ b/drivers/video/aty/aty128fb.c
45045 @@ -149,7 +149,7 @@ enum {
45046 };
45047
45048 /* Must match above enum */
45049 -static char * const r128_family[] = {
45050 +static const char * const r128_family[] = {
45051 "AGP",
45052 "PCI",
45053 "PRO AGP",
45054 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
45055 index 4f27fdc..d3537e6 100644
45056 --- a/drivers/video/aty/atyfb_base.c
45057 +++ b/drivers/video/aty/atyfb_base.c
45058 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
45059 par->accel_flags = var->accel_flags; /* hack */
45060
45061 if (var->accel_flags) {
45062 - info->fbops->fb_sync = atyfb_sync;
45063 + pax_open_kernel();
45064 + *(void **)&info->fbops->fb_sync = atyfb_sync;
45065 + pax_close_kernel();
45066 info->flags &= ~FBINFO_HWACCEL_DISABLED;
45067 } else {
45068 - info->fbops->fb_sync = NULL;
45069 + pax_open_kernel();
45070 + *(void **)&info->fbops->fb_sync = NULL;
45071 + pax_close_kernel();
45072 info->flags |= FBINFO_HWACCEL_DISABLED;
45073 }
45074
45075 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
45076 index 95ec042..e6affdd 100644
45077 --- a/drivers/video/aty/mach64_cursor.c
45078 +++ b/drivers/video/aty/mach64_cursor.c
45079 @@ -7,6 +7,7 @@
45080 #include <linux/string.h>
45081
45082 #include <asm/io.h>
45083 +#include <asm/pgtable.h>
45084
45085 #ifdef __sparc__
45086 #include <asm/fbio.h>
45087 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
45088 info->sprite.buf_align = 16; /* and 64 lines tall. */
45089 info->sprite.flags = FB_PIXMAP_IO;
45090
45091 - info->fbops->fb_cursor = atyfb_cursor;
45092 + pax_open_kernel();
45093 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
45094 + pax_close_kernel();
45095
45096 return 0;
45097 }
45098 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
45099 index 6c5ed6b..b727c88 100644
45100 --- a/drivers/video/backlight/kb3886_bl.c
45101 +++ b/drivers/video/backlight/kb3886_bl.c
45102 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
45103 static unsigned long kb3886bl_flags;
45104 #define KB3886BL_SUSPENDED 0x01
45105
45106 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
45107 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
45108 {
45109 .ident = "Sahara Touch-iT",
45110 .matches = {
45111 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
45112 index 88cad6b..dd746c7 100644
45113 --- a/drivers/video/fb_defio.c
45114 +++ b/drivers/video/fb_defio.c
45115 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
45116
45117 BUG_ON(!fbdefio);
45118 mutex_init(&fbdefio->lock);
45119 - info->fbops->fb_mmap = fb_deferred_io_mmap;
45120 + pax_open_kernel();
45121 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
45122 + pax_close_kernel();
45123 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
45124 INIT_LIST_HEAD(&fbdefio->pagelist);
45125 if (fbdefio->delay == 0) /* set a default of 1 s */
45126 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
45127 page->mapping = NULL;
45128 }
45129
45130 - info->fbops->fb_mmap = NULL;
45131 + *(void **)&info->fbops->fb_mmap = NULL;
45132 mutex_destroy(&fbdefio->lock);
45133 }
45134 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
45135 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
45136 index 5c3960d..15cf8fc 100644
45137 --- a/drivers/video/fbcmap.c
45138 +++ b/drivers/video/fbcmap.c
45139 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
45140 rc = -ENODEV;
45141 goto out;
45142 }
45143 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
45144 - !info->fbops->fb_setcmap)) {
45145 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
45146 rc = -EINVAL;
45147 goto out1;
45148 }
45149 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
45150 index dc61c12..e29796e 100644
45151 --- a/drivers/video/fbmem.c
45152 +++ b/drivers/video/fbmem.c
45153 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45154 image->dx += image->width + 8;
45155 }
45156 } else if (rotate == FB_ROTATE_UD) {
45157 - for (x = 0; x < num && image->dx >= 0; x++) {
45158 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
45159 info->fbops->fb_imageblit(info, image);
45160 image->dx -= image->width + 8;
45161 }
45162 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45163 image->dy += image->height + 8;
45164 }
45165 } else if (rotate == FB_ROTATE_CCW) {
45166 - for (x = 0; x < num && image->dy >= 0; x++) {
45167 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
45168 info->fbops->fb_imageblit(info, image);
45169 image->dy -= image->height + 8;
45170 }
45171 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
45172 return -EFAULT;
45173 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
45174 return -EINVAL;
45175 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
45176 + if (con2fb.framebuffer >= FB_MAX)
45177 return -EINVAL;
45178 if (!registered_fb[con2fb.framebuffer])
45179 request_module("fb%d", con2fb.framebuffer);
45180 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
45181 index 7672d2e..b56437f 100644
45182 --- a/drivers/video/i810/i810_accel.c
45183 +++ b/drivers/video/i810/i810_accel.c
45184 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
45185 }
45186 }
45187 printk("ringbuffer lockup!!!\n");
45188 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
45189 i810_report_error(mmio);
45190 par->dev_flags |= LOCKUP;
45191 info->pixmap.scan_align = 1;
45192 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
45193 index 3c14e43..eafa544 100644
45194 --- a/drivers/video/logo/logo_linux_clut224.ppm
45195 +++ b/drivers/video/logo/logo_linux_clut224.ppm
45196 @@ -1,1604 +1,1123 @@
45197 P3
45198 -# Standard 224-color Linux logo
45199 80 80
45200 255
45201 - 0 0 0 0 0 0 0 0 0 0 0 0
45202 - 0 0 0 0 0 0 0 0 0 0 0 0
45203 - 0 0 0 0 0 0 0 0 0 0 0 0
45204 - 0 0 0 0 0 0 0 0 0 0 0 0
45205 - 0 0 0 0 0 0 0 0 0 0 0 0
45206 - 0 0 0 0 0 0 0 0 0 0 0 0
45207 - 0 0 0 0 0 0 0 0 0 0 0 0
45208 - 0 0 0 0 0 0 0 0 0 0 0 0
45209 - 0 0 0 0 0 0 0 0 0 0 0 0
45210 - 6 6 6 6 6 6 10 10 10 10 10 10
45211 - 10 10 10 6 6 6 6 6 6 6 6 6
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 - 0 0 0 0 0 0 0 0 0 0 0 0
45217 - 0 0 0 0 0 0 0 0 0 0 0 0
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 6 6 6 10 10 10 14 14 14
45230 - 22 22 22 26 26 26 30 30 30 34 34 34
45231 - 30 30 30 30 30 30 26 26 26 18 18 18
45232 - 14 14 14 10 10 10 6 6 6 0 0 0
45233 - 0 0 0 0 0 0 0 0 0 0 0 0
45234 - 0 0 0 0 0 0 0 0 0 0 0 0
45235 - 0 0 0 0 0 0 0 0 0 0 0 0
45236 - 0 0 0 0 0 0 0 0 0 0 0 0
45237 - 0 0 0 0 0 0 0 0 0 0 0 0
45238 - 0 0 0 0 0 0 0 0 0 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 1 0 0 1 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 0 0 0 0 0 0 0
45249 - 6 6 6 14 14 14 26 26 26 42 42 42
45250 - 54 54 54 66 66 66 78 78 78 78 78 78
45251 - 78 78 78 74 74 74 66 66 66 54 54 54
45252 - 42 42 42 26 26 26 18 18 18 10 10 10
45253 - 6 6 6 0 0 0 0 0 0 0 0 0
45254 - 0 0 0 0 0 0 0 0 0 0 0 0
45255 - 0 0 0 0 0 0 0 0 0 0 0 0
45256 - 0 0 0 0 0 0 0 0 0 0 0 0
45257 - 0 0 0 0 0 0 0 0 0 0 0 0
45258 - 0 0 0 0 0 0 0 0 0 0 0 0
45259 - 0 0 0 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 1 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 0 0 0 0 0 0 0 10 10 10
45269 - 22 22 22 42 42 42 66 66 66 86 86 86
45270 - 66 66 66 38 38 38 38 38 38 22 22 22
45271 - 26 26 26 34 34 34 54 54 54 66 66 66
45272 - 86 86 86 70 70 70 46 46 46 26 26 26
45273 - 14 14 14 6 6 6 0 0 0 0 0 0
45274 - 0 0 0 0 0 0 0 0 0 0 0 0
45275 - 0 0 0 0 0 0 0 0 0 0 0 0
45276 - 0 0 0 0 0 0 0 0 0 0 0 0
45277 - 0 0 0 0 0 0 0 0 0 0 0 0
45278 - 0 0 0 0 0 0 0 0 0 0 0 0
45279 - 0 0 0 0 0 0 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 1 0 0 1 0 0 1 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 0 0 0 0 10 10 10 26 26 26
45289 - 50 50 50 82 82 82 58 58 58 6 6 6
45290 - 2 2 6 2 2 6 2 2 6 2 2 6
45291 - 2 2 6 2 2 6 2 2 6 2 2 6
45292 - 6 6 6 54 54 54 86 86 86 66 66 66
45293 - 38 38 38 18 18 18 6 6 6 0 0 0
45294 - 0 0 0 0 0 0 0 0 0 0 0 0
45295 - 0 0 0 0 0 0 0 0 0 0 0 0
45296 - 0 0 0 0 0 0 0 0 0 0 0 0
45297 - 0 0 0 0 0 0 0 0 0 0 0 0
45298 - 0 0 0 0 0 0 0 0 0 0 0 0
45299 - 0 0 0 0 0 0 0 0 0 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 6 6 6 22 22 22 50 50 50
45309 - 78 78 78 34 34 34 2 2 6 2 2 6
45310 - 2 2 6 2 2 6 2 2 6 2 2 6
45311 - 2 2 6 2 2 6 2 2 6 2 2 6
45312 - 2 2 6 2 2 6 6 6 6 70 70 70
45313 - 78 78 78 46 46 46 22 22 22 6 6 6
45314 - 0 0 0 0 0 0 0 0 0 0 0 0
45315 - 0 0 0 0 0 0 0 0 0 0 0 0
45316 - 0 0 0 0 0 0 0 0 0 0 0 0
45317 - 0 0 0 0 0 0 0 0 0 0 0 0
45318 - 0 0 0 0 0 0 0 0 0 0 0 0
45319 - 0 0 0 0 0 0 0 0 0 0 0 0
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 1 0 0 1 0 0 1 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 - 6 6 6 18 18 18 42 42 42 82 82 82
45329 - 26 26 26 2 2 6 2 2 6 2 2 6
45330 - 2 2 6 2 2 6 2 2 6 2 2 6
45331 - 2 2 6 2 2 6 2 2 6 14 14 14
45332 - 46 46 46 34 34 34 6 6 6 2 2 6
45333 - 42 42 42 78 78 78 42 42 42 18 18 18
45334 - 6 6 6 0 0 0 0 0 0 0 0 0
45335 - 0 0 0 0 0 0 0 0 0 0 0 0
45336 - 0 0 0 0 0 0 0 0 0 0 0 0
45337 - 0 0 0 0 0 0 0 0 0 0 0 0
45338 - 0 0 0 0 0 0 0 0 0 0 0 0
45339 - 0 0 0 0 0 0 0 0 0 0 0 0
45340 - 0 0 0 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 1 0 0 0 0 0 1 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 - 10 10 10 30 30 30 66 66 66 58 58 58
45349 - 2 2 6 2 2 6 2 2 6 2 2 6
45350 - 2 2 6 2 2 6 2 2 6 2 2 6
45351 - 2 2 6 2 2 6 2 2 6 26 26 26
45352 - 86 86 86 101 101 101 46 46 46 10 10 10
45353 - 2 2 6 58 58 58 70 70 70 34 34 34
45354 - 10 10 10 0 0 0 0 0 0 0 0 0
45355 - 0 0 0 0 0 0 0 0 0 0 0 0
45356 - 0 0 0 0 0 0 0 0 0 0 0 0
45357 - 0 0 0 0 0 0 0 0 0 0 0 0
45358 - 0 0 0 0 0 0 0 0 0 0 0 0
45359 - 0 0 0 0 0 0 0 0 0 0 0 0
45360 - 0 0 0 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 1 0 0 1 0 0 1 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 - 14 14 14 42 42 42 86 86 86 10 10 10
45369 - 2 2 6 2 2 6 2 2 6 2 2 6
45370 - 2 2 6 2 2 6 2 2 6 2 2 6
45371 - 2 2 6 2 2 6 2 2 6 30 30 30
45372 - 94 94 94 94 94 94 58 58 58 26 26 26
45373 - 2 2 6 6 6 6 78 78 78 54 54 54
45374 - 22 22 22 6 6 6 0 0 0 0 0 0
45375 - 0 0 0 0 0 0 0 0 0 0 0 0
45376 - 0 0 0 0 0 0 0 0 0 0 0 0
45377 - 0 0 0 0 0 0 0 0 0 0 0 0
45378 - 0 0 0 0 0 0 0 0 0 0 0 0
45379 - 0 0 0 0 0 0 0 0 0 0 0 0
45380 - 0 0 0 0 0 0 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 6 6 6
45388 - 22 22 22 62 62 62 62 62 62 2 2 6
45389 - 2 2 6 2 2 6 2 2 6 2 2 6
45390 - 2 2 6 2 2 6 2 2 6 2 2 6
45391 - 2 2 6 2 2 6 2 2 6 26 26 26
45392 - 54 54 54 38 38 38 18 18 18 10 10 10
45393 - 2 2 6 2 2 6 34 34 34 82 82 82
45394 - 38 38 38 14 14 14 0 0 0 0 0 0
45395 - 0 0 0 0 0 0 0 0 0 0 0 0
45396 - 0 0 0 0 0 0 0 0 0 0 0 0
45397 - 0 0 0 0 0 0 0 0 0 0 0 0
45398 - 0 0 0 0 0 0 0 0 0 0 0 0
45399 - 0 0 0 0 0 0 0 0 0 0 0 0
45400 - 0 0 0 0 0 0 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 1 0 0 1 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 6 6 6
45408 - 30 30 30 78 78 78 30 30 30 2 2 6
45409 - 2 2 6 2 2 6 2 2 6 2 2 6
45410 - 2 2 6 2 2 6 2 2 6 2 2 6
45411 - 2 2 6 2 2 6 2 2 6 10 10 10
45412 - 10 10 10 2 2 6 2 2 6 2 2 6
45413 - 2 2 6 2 2 6 2 2 6 78 78 78
45414 - 50 50 50 18 18 18 6 6 6 0 0 0
45415 - 0 0 0 0 0 0 0 0 0 0 0 0
45416 - 0 0 0 0 0 0 0 0 0 0 0 0
45417 - 0 0 0 0 0 0 0 0 0 0 0 0
45418 - 0 0 0 0 0 0 0 0 0 0 0 0
45419 - 0 0 0 0 0 0 0 0 0 0 0 0
45420 - 0 0 0 0 0 0 0 0 0 0 0 0
45421 - 0 0 0 0 0 0 0 0 0 0 0 0
45422 - 0 0 1 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 10 10 10
45428 - 38 38 38 86 86 86 14 14 14 2 2 6
45429 - 2 2 6 2 2 6 2 2 6 2 2 6
45430 - 2 2 6 2 2 6 2 2 6 2 2 6
45431 - 2 2 6 2 2 6 2 2 6 2 2 6
45432 - 2 2 6 2 2 6 2 2 6 2 2 6
45433 - 2 2 6 2 2 6 2 2 6 54 54 54
45434 - 66 66 66 26 26 26 6 6 6 0 0 0
45435 - 0 0 0 0 0 0 0 0 0 0 0 0
45436 - 0 0 0 0 0 0 0 0 0 0 0 0
45437 - 0 0 0 0 0 0 0 0 0 0 0 0
45438 - 0 0 0 0 0 0 0 0 0 0 0 0
45439 - 0 0 0 0 0 0 0 0 0 0 0 0
45440 - 0 0 0 0 0 0 0 0 0 0 0 0
45441 - 0 0 0 0 0 0 0 0 0 0 0 0
45442 - 0 0 0 0 0 1 0 0 1 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 14 14 14
45448 - 42 42 42 82 82 82 2 2 6 2 2 6
45449 - 2 2 6 6 6 6 10 10 10 2 2 6
45450 - 2 2 6 2 2 6 2 2 6 2 2 6
45451 - 2 2 6 2 2 6 2 2 6 6 6 6
45452 - 14 14 14 10 10 10 2 2 6 2 2 6
45453 - 2 2 6 2 2 6 2 2 6 18 18 18
45454 - 82 82 82 34 34 34 10 10 10 0 0 0
45455 - 0 0 0 0 0 0 0 0 0 0 0 0
45456 - 0 0 0 0 0 0 0 0 0 0 0 0
45457 - 0 0 0 0 0 0 0 0 0 0 0 0
45458 - 0 0 0 0 0 0 0 0 0 0 0 0
45459 - 0 0 0 0 0 0 0 0 0 0 0 0
45460 - 0 0 0 0 0 0 0 0 0 0 0 0
45461 - 0 0 0 0 0 0 0 0 0 0 0 0
45462 - 0 0 1 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 14 14 14
45468 - 46 46 46 86 86 86 2 2 6 2 2 6
45469 - 6 6 6 6 6 6 22 22 22 34 34 34
45470 - 6 6 6 2 2 6 2 2 6 2 2 6
45471 - 2 2 6 2 2 6 18 18 18 34 34 34
45472 - 10 10 10 50 50 50 22 22 22 2 2 6
45473 - 2 2 6 2 2 6 2 2 6 10 10 10
45474 - 86 86 86 42 42 42 14 14 14 0 0 0
45475 - 0 0 0 0 0 0 0 0 0 0 0 0
45476 - 0 0 0 0 0 0 0 0 0 0 0 0
45477 - 0 0 0 0 0 0 0 0 0 0 0 0
45478 - 0 0 0 0 0 0 0 0 0 0 0 0
45479 - 0 0 0 0 0 0 0 0 0 0 0 0
45480 - 0 0 0 0 0 0 0 0 0 0 0 0
45481 - 0 0 0 0 0 0 0 0 0 0 0 0
45482 - 0 0 1 0 0 1 0 0 1 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 14 14 14
45488 - 46 46 46 86 86 86 2 2 6 2 2 6
45489 - 38 38 38 116 116 116 94 94 94 22 22 22
45490 - 22 22 22 2 2 6 2 2 6 2 2 6
45491 - 14 14 14 86 86 86 138 138 138 162 162 162
45492 -154 154 154 38 38 38 26 26 26 6 6 6
45493 - 2 2 6 2 2 6 2 2 6 2 2 6
45494 - 86 86 86 46 46 46 14 14 14 0 0 0
45495 - 0 0 0 0 0 0 0 0 0 0 0 0
45496 - 0 0 0 0 0 0 0 0 0 0 0 0
45497 - 0 0 0 0 0 0 0 0 0 0 0 0
45498 - 0 0 0 0 0 0 0 0 0 0 0 0
45499 - 0 0 0 0 0 0 0 0 0 0 0 0
45500 - 0 0 0 0 0 0 0 0 0 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 14 14 14
45508 - 46 46 46 86 86 86 2 2 6 14 14 14
45509 -134 134 134 198 198 198 195 195 195 116 116 116
45510 - 10 10 10 2 2 6 2 2 6 6 6 6
45511 -101 98 89 187 187 187 210 210 210 218 218 218
45512 -214 214 214 134 134 134 14 14 14 6 6 6
45513 - 2 2 6 2 2 6 2 2 6 2 2 6
45514 - 86 86 86 50 50 50 18 18 18 6 6 6
45515 - 0 0 0 0 0 0 0 0 0 0 0 0
45516 - 0 0 0 0 0 0 0 0 0 0 0 0
45517 - 0 0 0 0 0 0 0 0 0 0 0 0
45518 - 0 0 0 0 0 0 0 0 0 0 0 0
45519 - 0 0 0 0 0 0 0 0 0 0 0 0
45520 - 0 0 0 0 0 0 0 0 0 0 0 0
45521 - 0 0 0 0 0 0 0 0 1 0 0 0
45522 - 0 0 1 0 0 1 0 0 1 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 0 14 14 14
45528 - 46 46 46 86 86 86 2 2 6 54 54 54
45529 -218 218 218 195 195 195 226 226 226 246 246 246
45530 - 58 58 58 2 2 6 2 2 6 30 30 30
45531 -210 210 210 253 253 253 174 174 174 123 123 123
45532 -221 221 221 234 234 234 74 74 74 2 2 6
45533 - 2 2 6 2 2 6 2 2 6 2 2 6
45534 - 70 70 70 58 58 58 22 22 22 6 6 6
45535 - 0 0 0 0 0 0 0 0 0 0 0 0
45536 - 0 0 0 0 0 0 0 0 0 0 0 0
45537 - 0 0 0 0 0 0 0 0 0 0 0 0
45538 - 0 0 0 0 0 0 0 0 0 0 0 0
45539 - 0 0 0 0 0 0 0 0 0 0 0 0
45540 - 0 0 0 0 0 0 0 0 0 0 0 0
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 14 14 14
45548 - 46 46 46 82 82 82 2 2 6 106 106 106
45549 -170 170 170 26 26 26 86 86 86 226 226 226
45550 -123 123 123 10 10 10 14 14 14 46 46 46
45551 -231 231 231 190 190 190 6 6 6 70 70 70
45552 - 90 90 90 238 238 238 158 158 158 2 2 6
45553 - 2 2 6 2 2 6 2 2 6 2 2 6
45554 - 70 70 70 58 58 58 22 22 22 6 6 6
45555 - 0 0 0 0 0 0 0 0 0 0 0 0
45556 - 0 0 0 0 0 0 0 0 0 0 0 0
45557 - 0 0 0 0 0 0 0 0 0 0 0 0
45558 - 0 0 0 0 0 0 0 0 0 0 0 0
45559 - 0 0 0 0 0 0 0 0 0 0 0 0
45560 - 0 0 0 0 0 0 0 0 0 0 0 0
45561 - 0 0 0 0 0 0 0 0 1 0 0 0
45562 - 0 0 1 0 0 1 0 0 1 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 0 14 14 14
45568 - 42 42 42 86 86 86 6 6 6 116 116 116
45569 -106 106 106 6 6 6 70 70 70 149 149 149
45570 -128 128 128 18 18 18 38 38 38 54 54 54
45571 -221 221 221 106 106 106 2 2 6 14 14 14
45572 - 46 46 46 190 190 190 198 198 198 2 2 6
45573 - 2 2 6 2 2 6 2 2 6 2 2 6
45574 - 74 74 74 62 62 62 22 22 22 6 6 6
45575 - 0 0 0 0 0 0 0 0 0 0 0 0
45576 - 0 0 0 0 0 0 0 0 0 0 0 0
45577 - 0 0 0 0 0 0 0 0 0 0 0 0
45578 - 0 0 0 0 0 0 0 0 0 0 0 0
45579 - 0 0 0 0 0 0 0 0 0 0 0 0
45580 - 0 0 0 0 0 0 0 0 0 0 0 0
45581 - 0 0 0 0 0 0 0 0 1 0 0 0
45582 - 0 0 1 0 0 0 0 0 1 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 0 14 14 14
45588 - 42 42 42 94 94 94 14 14 14 101 101 101
45589 -128 128 128 2 2 6 18 18 18 116 116 116
45590 -118 98 46 121 92 8 121 92 8 98 78 10
45591 -162 162 162 106 106 106 2 2 6 2 2 6
45592 - 2 2 6 195 195 195 195 195 195 6 6 6
45593 - 2 2 6 2 2 6 2 2 6 2 2 6
45594 - 74 74 74 62 62 62 22 22 22 6 6 6
45595 - 0 0 0 0 0 0 0 0 0 0 0 0
45596 - 0 0 0 0 0 0 0 0 0 0 0 0
45597 - 0 0 0 0 0 0 0 0 0 0 0 0
45598 - 0 0 0 0 0 0 0 0 0 0 0 0
45599 - 0 0 0 0 0 0 0 0 0 0 0 0
45600 - 0 0 0 0 0 0 0 0 0 0 0 0
45601 - 0 0 0 0 0 0 0 0 1 0 0 1
45602 - 0 0 1 0 0 0 0 0 1 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 0 10 10 10
45608 - 38 38 38 90 90 90 14 14 14 58 58 58
45609 -210 210 210 26 26 26 54 38 6 154 114 10
45610 -226 170 11 236 186 11 225 175 15 184 144 12
45611 -215 174 15 175 146 61 37 26 9 2 2 6
45612 - 70 70 70 246 246 246 138 138 138 2 2 6
45613 - 2 2 6 2 2 6 2 2 6 2 2 6
45614 - 70 70 70 66 66 66 26 26 26 6 6 6
45615 - 0 0 0 0 0 0 0 0 0 0 0 0
45616 - 0 0 0 0 0 0 0 0 0 0 0 0
45617 - 0 0 0 0 0 0 0 0 0 0 0 0
45618 - 0 0 0 0 0 0 0 0 0 0 0 0
45619 - 0 0 0 0 0 0 0 0 0 0 0 0
45620 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
45628 - 38 38 38 86 86 86 14 14 14 10 10 10
45629 -195 195 195 188 164 115 192 133 9 225 175 15
45630 -239 182 13 234 190 10 232 195 16 232 200 30
45631 -245 207 45 241 208 19 232 195 16 184 144 12
45632 -218 194 134 211 206 186 42 42 42 2 2 6
45633 - 2 2 6 2 2 6 2 2 6 2 2 6
45634 - 50 50 50 74 74 74 30 30 30 6 6 6
45635 - 0 0 0 0 0 0 0 0 0 0 0 0
45636 - 0 0 0 0 0 0 0 0 0 0 0 0
45637 - 0 0 0 0 0 0 0 0 0 0 0 0
45638 - 0 0 0 0 0 0 0 0 0 0 0 0
45639 - 0 0 0 0 0 0 0 0 0 0 0 0
45640 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
45648 - 34 34 34 86 86 86 14 14 14 2 2 6
45649 -121 87 25 192 133 9 219 162 10 239 182 13
45650 -236 186 11 232 195 16 241 208 19 244 214 54
45651 -246 218 60 246 218 38 246 215 20 241 208 19
45652 -241 208 19 226 184 13 121 87 25 2 2 6
45653 - 2 2 6 2 2 6 2 2 6 2 2 6
45654 - 50 50 50 82 82 82 34 34 34 10 10 10
45655 - 0 0 0 0 0 0 0 0 0 0 0 0
45656 - 0 0 0 0 0 0 0 0 0 0 0 0
45657 - 0 0 0 0 0 0 0 0 0 0 0 0
45658 - 0 0 0 0 0 0 0 0 0 0 0 0
45659 - 0 0 0 0 0 0 0 0 0 0 0 0
45660 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
45668 - 34 34 34 82 82 82 30 30 30 61 42 6
45669 -180 123 7 206 145 10 230 174 11 239 182 13
45670 -234 190 10 238 202 15 241 208 19 246 218 74
45671 -246 218 38 246 215 20 246 215 20 246 215 20
45672 -226 184 13 215 174 15 184 144 12 6 6 6
45673 - 2 2 6 2 2 6 2 2 6 2 2 6
45674 - 26 26 26 94 94 94 42 42 42 14 14 14
45675 - 0 0 0 0 0 0 0 0 0 0 0 0
45676 - 0 0 0 0 0 0 0 0 0 0 0 0
45677 - 0 0 0 0 0 0 0 0 0 0 0 0
45678 - 0 0 0 0 0 0 0 0 0 0 0 0
45679 - 0 0 0 0 0 0 0 0 0 0 0 0
45680 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
45688 - 30 30 30 78 78 78 50 50 50 104 69 6
45689 -192 133 9 216 158 10 236 178 12 236 186 11
45690 -232 195 16 241 208 19 244 214 54 245 215 43
45691 -246 215 20 246 215 20 241 208 19 198 155 10
45692 -200 144 11 216 158 10 156 118 10 2 2 6
45693 - 2 2 6 2 2 6 2 2 6 2 2 6
45694 - 6 6 6 90 90 90 54 54 54 18 18 18
45695 - 6 6 6 0 0 0 0 0 0 0 0 0
45696 - 0 0 0 0 0 0 0 0 0 0 0 0
45697 - 0 0 0 0 0 0 0 0 0 0 0 0
45698 - 0 0 0 0 0 0 0 0 0 0 0 0
45699 - 0 0 0 0 0 0 0 0 0 0 0 0
45700 - 0 0 0 0 0 0 0 0 0 0 0 0
45701 - 0 0 0 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 10 10 10
45708 - 30 30 30 78 78 78 46 46 46 22 22 22
45709 -137 92 6 210 162 10 239 182 13 238 190 10
45710 -238 202 15 241 208 19 246 215 20 246 215 20
45711 -241 208 19 203 166 17 185 133 11 210 150 10
45712 -216 158 10 210 150 10 102 78 10 2 2 6
45713 - 6 6 6 54 54 54 14 14 14 2 2 6
45714 - 2 2 6 62 62 62 74 74 74 30 30 30
45715 - 10 10 10 0 0 0 0 0 0 0 0 0
45716 - 0 0 0 0 0 0 0 0 0 0 0 0
45717 - 0 0 0 0 0 0 0 0 0 0 0 0
45718 - 0 0 0 0 0 0 0 0 0 0 0 0
45719 - 0 0 0 0 0 0 0 0 0 0 0 0
45720 - 0 0 0 0 0 0 0 0 0 0 0 0
45721 - 0 0 0 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 10 10 10
45728 - 34 34 34 78 78 78 50 50 50 6 6 6
45729 - 94 70 30 139 102 15 190 146 13 226 184 13
45730 -232 200 30 232 195 16 215 174 15 190 146 13
45731 -168 122 10 192 133 9 210 150 10 213 154 11
45732 -202 150 34 182 157 106 101 98 89 2 2 6
45733 - 2 2 6 78 78 78 116 116 116 58 58 58
45734 - 2 2 6 22 22 22 90 90 90 46 46 46
45735 - 18 18 18 6 6 6 0 0 0 0 0 0
45736 - 0 0 0 0 0 0 0 0 0 0 0 0
45737 - 0 0 0 0 0 0 0 0 0 0 0 0
45738 - 0 0 0 0 0 0 0 0 0 0 0 0
45739 - 0 0 0 0 0 0 0 0 0 0 0 0
45740 - 0 0 0 0 0 0 0 0 0 0 0 0
45741 - 0 0 0 0 0 0 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 10 10 10
45748 - 38 38 38 86 86 86 50 50 50 6 6 6
45749 -128 128 128 174 154 114 156 107 11 168 122 10
45750 -198 155 10 184 144 12 197 138 11 200 144 11
45751 -206 145 10 206 145 10 197 138 11 188 164 115
45752 -195 195 195 198 198 198 174 174 174 14 14 14
45753 - 2 2 6 22 22 22 116 116 116 116 116 116
45754 - 22 22 22 2 2 6 74 74 74 70 70 70
45755 - 30 30 30 10 10 10 0 0 0 0 0 0
45756 - 0 0 0 0 0 0 0 0 0 0 0 0
45757 - 0 0 0 0 0 0 0 0 0 0 0 0
45758 - 0 0 0 0 0 0 0 0 0 0 0 0
45759 - 0 0 0 0 0 0 0 0 0 0 0 0
45760 - 0 0 0 0 0 0 0 0 0 0 0 0
45761 - 0 0 0 0 0 0 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 6 6 6 18 18 18
45768 - 50 50 50 101 101 101 26 26 26 10 10 10
45769 -138 138 138 190 190 190 174 154 114 156 107 11
45770 -197 138 11 200 144 11 197 138 11 192 133 9
45771 -180 123 7 190 142 34 190 178 144 187 187 187
45772 -202 202 202 221 221 221 214 214 214 66 66 66
45773 - 2 2 6 2 2 6 50 50 50 62 62 62
45774 - 6 6 6 2 2 6 10 10 10 90 90 90
45775 - 50 50 50 18 18 18 6 6 6 0 0 0
45776 - 0 0 0 0 0 0 0 0 0 0 0 0
45777 - 0 0 0 0 0 0 0 0 0 0 0 0
45778 - 0 0 0 0 0 0 0 0 0 0 0 0
45779 - 0 0 0 0 0 0 0 0 0 0 0 0
45780 - 0 0 0 0 0 0 0 0 0 0 0 0
45781 - 0 0 0 0 0 0 0 0 0 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 10 10 10 34 34 34
45788 - 74 74 74 74 74 74 2 2 6 6 6 6
45789 -144 144 144 198 198 198 190 190 190 178 166 146
45790 -154 121 60 156 107 11 156 107 11 168 124 44
45791 -174 154 114 187 187 187 190 190 190 210 210 210
45792 -246 246 246 253 253 253 253 253 253 182 182 182
45793 - 6 6 6 2 2 6 2 2 6 2 2 6
45794 - 2 2 6 2 2 6 2 2 6 62 62 62
45795 - 74 74 74 34 34 34 14 14 14 0 0 0
45796 - 0 0 0 0 0 0 0 0 0 0 0 0
45797 - 0 0 0 0 0 0 0 0 0 0 0 0
45798 - 0 0 0 0 0 0 0 0 0 0 0 0
45799 - 0 0 0 0 0 0 0 0 0 0 0 0
45800 - 0 0 0 0 0 0 0 0 0 0 0 0
45801 - 0 0 0 0 0 0 0 0 0 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 10 10 10 22 22 22 54 54 54
45808 - 94 94 94 18 18 18 2 2 6 46 46 46
45809 -234 234 234 221 221 221 190 190 190 190 190 190
45810 -190 190 190 187 187 187 187 187 187 190 190 190
45811 -190 190 190 195 195 195 214 214 214 242 242 242
45812 -253 253 253 253 253 253 253 253 253 253 253 253
45813 - 82 82 82 2 2 6 2 2 6 2 2 6
45814 - 2 2 6 2 2 6 2 2 6 14 14 14
45815 - 86 86 86 54 54 54 22 22 22 6 6 6
45816 - 0 0 0 0 0 0 0 0 0 0 0 0
45817 - 0 0 0 0 0 0 0 0 0 0 0 0
45818 - 0 0 0 0 0 0 0 0 0 0 0 0
45819 - 0 0 0 0 0 0 0 0 0 0 0 0
45820 - 0 0 0 0 0 0 0 0 0 0 0 0
45821 - 0 0 0 0 0 0 0 0 0 0 0 0
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 - 6 6 6 18 18 18 46 46 46 90 90 90
45828 - 46 46 46 18 18 18 6 6 6 182 182 182
45829 -253 253 253 246 246 246 206 206 206 190 190 190
45830 -190 190 190 190 190 190 190 190 190 190 190 190
45831 -206 206 206 231 231 231 250 250 250 253 253 253
45832 -253 253 253 253 253 253 253 253 253 253 253 253
45833 -202 202 202 14 14 14 2 2 6 2 2 6
45834 - 2 2 6 2 2 6 2 2 6 2 2 6
45835 - 42 42 42 86 86 86 42 42 42 18 18 18
45836 - 6 6 6 0 0 0 0 0 0 0 0 0
45837 - 0 0 0 0 0 0 0 0 0 0 0 0
45838 - 0 0 0 0 0 0 0 0 0 0 0 0
45839 - 0 0 0 0 0 0 0 0 0 0 0 0
45840 - 0 0 0 0 0 0 0 0 0 0 0 0
45841 - 0 0 0 0 0 0 0 0 0 0 0 0
45842 - 0 0 0 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 6 6 6
45847 - 14 14 14 38 38 38 74 74 74 66 66 66
45848 - 2 2 6 6 6 6 90 90 90 250 250 250
45849 -253 253 253 253 253 253 238 238 238 198 198 198
45850 -190 190 190 190 190 190 195 195 195 221 221 221
45851 -246 246 246 253 253 253 253 253 253 253 253 253
45852 -253 253 253 253 253 253 253 253 253 253 253 253
45853 -253 253 253 82 82 82 2 2 6 2 2 6
45854 - 2 2 6 2 2 6 2 2 6 2 2 6
45855 - 2 2 6 78 78 78 70 70 70 34 34 34
45856 - 14 14 14 6 6 6 0 0 0 0 0 0
45857 - 0 0 0 0 0 0 0 0 0 0 0 0
45858 - 0 0 0 0 0 0 0 0 0 0 0 0
45859 - 0 0 0 0 0 0 0 0 0 0 0 0
45860 - 0 0 0 0 0 0 0 0 0 0 0 0
45861 - 0 0 0 0 0 0 0 0 0 0 0 0
45862 - 0 0 0 0 0 0 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 14 14 14
45867 - 34 34 34 66 66 66 78 78 78 6 6 6
45868 - 2 2 6 18 18 18 218 218 218 253 253 253
45869 -253 253 253 253 253 253 253 253 253 246 246 246
45870 -226 226 226 231 231 231 246 246 246 253 253 253
45871 -253 253 253 253 253 253 253 253 253 253 253 253
45872 -253 253 253 253 253 253 253 253 253 253 253 253
45873 -253 253 253 178 178 178 2 2 6 2 2 6
45874 - 2 2 6 2 2 6 2 2 6 2 2 6
45875 - 2 2 6 18 18 18 90 90 90 62 62 62
45876 - 30 30 30 10 10 10 0 0 0 0 0 0
45877 - 0 0 0 0 0 0 0 0 0 0 0 0
45878 - 0 0 0 0 0 0 0 0 0 0 0 0
45879 - 0 0 0 0 0 0 0 0 0 0 0 0
45880 - 0 0 0 0 0 0 0 0 0 0 0 0
45881 - 0 0 0 0 0 0 0 0 0 0 0 0
45882 - 0 0 0 0 0 0 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 10 10 10 26 26 26
45887 - 58 58 58 90 90 90 18 18 18 2 2 6
45888 - 2 2 6 110 110 110 253 253 253 253 253 253
45889 -253 253 253 253 253 253 253 253 253 253 253 253
45890 -250 250 250 253 253 253 253 253 253 253 253 253
45891 -253 253 253 253 253 253 253 253 253 253 253 253
45892 -253 253 253 253 253 253 253 253 253 253 253 253
45893 -253 253 253 231 231 231 18 18 18 2 2 6
45894 - 2 2 6 2 2 6 2 2 6 2 2 6
45895 - 2 2 6 2 2 6 18 18 18 94 94 94
45896 - 54 54 54 26 26 26 10 10 10 0 0 0
45897 - 0 0 0 0 0 0 0 0 0 0 0 0
45898 - 0 0 0 0 0 0 0 0 0 0 0 0
45899 - 0 0 0 0 0 0 0 0 0 0 0 0
45900 - 0 0 0 0 0 0 0 0 0 0 0 0
45901 - 0 0 0 0 0 0 0 0 0 0 0 0
45902 - 0 0 0 0 0 0 0 0 0 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 6 6 6 22 22 22 50 50 50
45907 - 90 90 90 26 26 26 2 2 6 2 2 6
45908 - 14 14 14 195 195 195 250 250 250 253 253 253
45909 -253 253 253 253 253 253 253 253 253 253 253 253
45910 -253 253 253 253 253 253 253 253 253 253 253 253
45911 -253 253 253 253 253 253 253 253 253 253 253 253
45912 -253 253 253 253 253 253 253 253 253 253 253 253
45913 -250 250 250 242 242 242 54 54 54 2 2 6
45914 - 2 2 6 2 2 6 2 2 6 2 2 6
45915 - 2 2 6 2 2 6 2 2 6 38 38 38
45916 - 86 86 86 50 50 50 22 22 22 6 6 6
45917 - 0 0 0 0 0 0 0 0 0 0 0 0
45918 - 0 0 0 0 0 0 0 0 0 0 0 0
45919 - 0 0 0 0 0 0 0 0 0 0 0 0
45920 - 0 0 0 0 0 0 0 0 0 0 0 0
45921 - 0 0 0 0 0 0 0 0 0 0 0 0
45922 - 0 0 0 0 0 0 0 0 0 0 0 0
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 - 6 6 6 14 14 14 38 38 38 82 82 82
45927 - 34 34 34 2 2 6 2 2 6 2 2 6
45928 - 42 42 42 195 195 195 246 246 246 253 253 253
45929 -253 253 253 253 253 253 253 253 253 250 250 250
45930 -242 242 242 242 242 242 250 250 250 253 253 253
45931 -253 253 253 253 253 253 253 253 253 253 253 253
45932 -253 253 253 250 250 250 246 246 246 238 238 238
45933 -226 226 226 231 231 231 101 101 101 6 6 6
45934 - 2 2 6 2 2 6 2 2 6 2 2 6
45935 - 2 2 6 2 2 6 2 2 6 2 2 6
45936 - 38 38 38 82 82 82 42 42 42 14 14 14
45937 - 6 6 6 0 0 0 0 0 0 0 0 0
45938 - 0 0 0 0 0 0 0 0 0 0 0 0
45939 - 0 0 0 0 0 0 0 0 0 0 0 0
45940 - 0 0 0 0 0 0 0 0 0 0 0 0
45941 - 0 0 0 0 0 0 0 0 0 0 0 0
45942 - 0 0 0 0 0 0 0 0 0 0 0 0
45943 - 0 0 0 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 - 10 10 10 26 26 26 62 62 62 66 66 66
45947 - 2 2 6 2 2 6 2 2 6 6 6 6
45948 - 70 70 70 170 170 170 206 206 206 234 234 234
45949 -246 246 246 250 250 250 250 250 250 238 238 238
45950 -226 226 226 231 231 231 238 238 238 250 250 250
45951 -250 250 250 250 250 250 246 246 246 231 231 231
45952 -214 214 214 206 206 206 202 202 202 202 202 202
45953 -198 198 198 202 202 202 182 182 182 18 18 18
45954 - 2 2 6 2 2 6 2 2 6 2 2 6
45955 - 2 2 6 2 2 6 2 2 6 2 2 6
45956 - 2 2 6 62 62 62 66 66 66 30 30 30
45957 - 10 10 10 0 0 0 0 0 0 0 0 0
45958 - 0 0 0 0 0 0 0 0 0 0 0 0
45959 - 0 0 0 0 0 0 0 0 0 0 0 0
45960 - 0 0 0 0 0 0 0 0 0 0 0 0
45961 - 0 0 0 0 0 0 0 0 0 0 0 0
45962 - 0 0 0 0 0 0 0 0 0 0 0 0
45963 - 0 0 0 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 - 14 14 14 42 42 42 82 82 82 18 18 18
45967 - 2 2 6 2 2 6 2 2 6 10 10 10
45968 - 94 94 94 182 182 182 218 218 218 242 242 242
45969 -250 250 250 253 253 253 253 253 253 250 250 250
45970 -234 234 234 253 253 253 253 253 253 253 253 253
45971 -253 253 253 253 253 253 253 253 253 246 246 246
45972 -238 238 238 226 226 226 210 210 210 202 202 202
45973 -195 195 195 195 195 195 210 210 210 158 158 158
45974 - 6 6 6 14 14 14 50 50 50 14 14 14
45975 - 2 2 6 2 2 6 2 2 6 2 2 6
45976 - 2 2 6 6 6 6 86 86 86 46 46 46
45977 - 18 18 18 6 6 6 0 0 0 0 0 0
45978 - 0 0 0 0 0 0 0 0 0 0 0 0
45979 - 0 0 0 0 0 0 0 0 0 0 0 0
45980 - 0 0 0 0 0 0 0 0 0 0 0 0
45981 - 0 0 0 0 0 0 0 0 0 0 0 0
45982 - 0 0 0 0 0 0 0 0 0 0 0 0
45983 - 0 0 0 0 0 0 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 6 6 6
45986 - 22 22 22 54 54 54 70 70 70 2 2 6
45987 - 2 2 6 10 10 10 2 2 6 22 22 22
45988 -166 166 166 231 231 231 250 250 250 253 253 253
45989 -253 253 253 253 253 253 253 253 253 250 250 250
45990 -242 242 242 253 253 253 253 253 253 253 253 253
45991 -253 253 253 253 253 253 253 253 253 253 253 253
45992 -253 253 253 253 253 253 253 253 253 246 246 246
45993 -231 231 231 206 206 206 198 198 198 226 226 226
45994 - 94 94 94 2 2 6 6 6 6 38 38 38
45995 - 30 30 30 2 2 6 2 2 6 2 2 6
45996 - 2 2 6 2 2 6 62 62 62 66 66 66
45997 - 26 26 26 10 10 10 0 0 0 0 0 0
45998 - 0 0 0 0 0 0 0 0 0 0 0 0
45999 - 0 0 0 0 0 0 0 0 0 0 0 0
46000 - 0 0 0 0 0 0 0 0 0 0 0 0
46001 - 0 0 0 0 0 0 0 0 0 0 0 0
46002 - 0 0 0 0 0 0 0 0 0 0 0 0
46003 - 0 0 0 0 0 0 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 10 10 10
46006 - 30 30 30 74 74 74 50 50 50 2 2 6
46007 - 26 26 26 26 26 26 2 2 6 106 106 106
46008 -238 238 238 253 253 253 253 253 253 253 253 253
46009 -253 253 253 253 253 253 253 253 253 253 253 253
46010 -253 253 253 253 253 253 253 253 253 253 253 253
46011 -253 253 253 253 253 253 253 253 253 253 253 253
46012 -253 253 253 253 253 253 253 253 253 253 253 253
46013 -253 253 253 246 246 246 218 218 218 202 202 202
46014 -210 210 210 14 14 14 2 2 6 2 2 6
46015 - 30 30 30 22 22 22 2 2 6 2 2 6
46016 - 2 2 6 2 2 6 18 18 18 86 86 86
46017 - 42 42 42 14 14 14 0 0 0 0 0 0
46018 - 0 0 0 0 0 0 0 0 0 0 0 0
46019 - 0 0 0 0 0 0 0 0 0 0 0 0
46020 - 0 0 0 0 0 0 0 0 0 0 0 0
46021 - 0 0 0 0 0 0 0 0 0 0 0 0
46022 - 0 0 0 0 0 0 0 0 0 0 0 0
46023 - 0 0 0 0 0 0 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 14 14 14
46026 - 42 42 42 90 90 90 22 22 22 2 2 6
46027 - 42 42 42 2 2 6 18 18 18 218 218 218
46028 -253 253 253 253 253 253 253 253 253 253 253 253
46029 -253 253 253 253 253 253 253 253 253 253 253 253
46030 -253 253 253 253 253 253 253 253 253 253 253 253
46031 -253 253 253 253 253 253 253 253 253 253 253 253
46032 -253 253 253 253 253 253 253 253 253 253 253 253
46033 -253 253 253 253 253 253 250 250 250 221 221 221
46034 -218 218 218 101 101 101 2 2 6 14 14 14
46035 - 18 18 18 38 38 38 10 10 10 2 2 6
46036 - 2 2 6 2 2 6 2 2 6 78 78 78
46037 - 58 58 58 22 22 22 6 6 6 0 0 0
46038 - 0 0 0 0 0 0 0 0 0 0 0 0
46039 - 0 0 0 0 0 0 0 0 0 0 0 0
46040 - 0 0 0 0 0 0 0 0 0 0 0 0
46041 - 0 0 0 0 0 0 0 0 0 0 0 0
46042 - 0 0 0 0 0 0 0 0 0 0 0 0
46043 - 0 0 0 0 0 0 0 0 0 0 0 0
46044 - 0 0 0 0 0 0 0 0 0 0 0 0
46045 - 0 0 0 0 0 0 6 6 6 18 18 18
46046 - 54 54 54 82 82 82 2 2 6 26 26 26
46047 - 22 22 22 2 2 6 123 123 123 253 253 253
46048 -253 253 253 253 253 253 253 253 253 253 253 253
46049 -253 253 253 253 253 253 253 253 253 253 253 253
46050 -253 253 253 253 253 253 253 253 253 253 253 253
46051 -253 253 253 253 253 253 253 253 253 253 253 253
46052 -253 253 253 253 253 253 253 253 253 253 253 253
46053 -253 253 253 253 253 253 253 253 253 250 250 250
46054 -238 238 238 198 198 198 6 6 6 38 38 38
46055 - 58 58 58 26 26 26 38 38 38 2 2 6
46056 - 2 2 6 2 2 6 2 2 6 46 46 46
46057 - 78 78 78 30 30 30 10 10 10 0 0 0
46058 - 0 0 0 0 0 0 0 0 0 0 0 0
46059 - 0 0 0 0 0 0 0 0 0 0 0 0
46060 - 0 0 0 0 0 0 0 0 0 0 0 0
46061 - 0 0 0 0 0 0 0 0 0 0 0 0
46062 - 0 0 0 0 0 0 0 0 0 0 0 0
46063 - 0 0 0 0 0 0 0 0 0 0 0 0
46064 - 0 0 0 0 0 0 0 0 0 0 0 0
46065 - 0 0 0 0 0 0 10 10 10 30 30 30
46066 - 74 74 74 58 58 58 2 2 6 42 42 42
46067 - 2 2 6 22 22 22 231 231 231 253 253 253
46068 -253 253 253 253 253 253 253 253 253 253 253 253
46069 -253 253 253 253 253 253 253 253 253 250 250 250
46070 -253 253 253 253 253 253 253 253 253 253 253 253
46071 -253 253 253 253 253 253 253 253 253 253 253 253
46072 -253 253 253 253 253 253 253 253 253 253 253 253
46073 -253 253 253 253 253 253 253 253 253 253 253 253
46074 -253 253 253 246 246 246 46 46 46 38 38 38
46075 - 42 42 42 14 14 14 38 38 38 14 14 14
46076 - 2 2 6 2 2 6 2 2 6 6 6 6
46077 - 86 86 86 46 46 46 14 14 14 0 0 0
46078 - 0 0 0 0 0 0 0 0 0 0 0 0
46079 - 0 0 0 0 0 0 0 0 0 0 0 0
46080 - 0 0 0 0 0 0 0 0 0 0 0 0
46081 - 0 0 0 0 0 0 0 0 0 0 0 0
46082 - 0 0 0 0 0 0 0 0 0 0 0 0
46083 - 0 0 0 0 0 0 0 0 0 0 0 0
46084 - 0 0 0 0 0 0 0 0 0 0 0 0
46085 - 0 0 0 6 6 6 14 14 14 42 42 42
46086 - 90 90 90 18 18 18 18 18 18 26 26 26
46087 - 2 2 6 116 116 116 253 253 253 253 253 253
46088 -253 253 253 253 253 253 253 253 253 253 253 253
46089 -253 253 253 253 253 253 250 250 250 238 238 238
46090 -253 253 253 253 253 253 253 253 253 253 253 253
46091 -253 253 253 253 253 253 253 253 253 253 253 253
46092 -253 253 253 253 253 253 253 253 253 253 253 253
46093 -253 253 253 253 253 253 253 253 253 253 253 253
46094 -253 253 253 253 253 253 94 94 94 6 6 6
46095 - 2 2 6 2 2 6 10 10 10 34 34 34
46096 - 2 2 6 2 2 6 2 2 6 2 2 6
46097 - 74 74 74 58 58 58 22 22 22 6 6 6
46098 - 0 0 0 0 0 0 0 0 0 0 0 0
46099 - 0 0 0 0 0 0 0 0 0 0 0 0
46100 - 0 0 0 0 0 0 0 0 0 0 0 0
46101 - 0 0 0 0 0 0 0 0 0 0 0 0
46102 - 0 0 0 0 0 0 0 0 0 0 0 0
46103 - 0 0 0 0 0 0 0 0 0 0 0 0
46104 - 0 0 0 0 0 0 0 0 0 0 0 0
46105 - 0 0 0 10 10 10 26 26 26 66 66 66
46106 - 82 82 82 2 2 6 38 38 38 6 6 6
46107 - 14 14 14 210 210 210 253 253 253 253 253 253
46108 -253 253 253 253 253 253 253 253 253 253 253 253
46109 -253 253 253 253 253 253 246 246 246 242 242 242
46110 -253 253 253 253 253 253 253 253 253 253 253 253
46111 -253 253 253 253 253 253 253 253 253 253 253 253
46112 -253 253 253 253 253 253 253 253 253 253 253 253
46113 -253 253 253 253 253 253 253 253 253 253 253 253
46114 -253 253 253 253 253 253 144 144 144 2 2 6
46115 - 2 2 6 2 2 6 2 2 6 46 46 46
46116 - 2 2 6 2 2 6 2 2 6 2 2 6
46117 - 42 42 42 74 74 74 30 30 30 10 10 10
46118 - 0 0 0 0 0 0 0 0 0 0 0 0
46119 - 0 0 0 0 0 0 0 0 0 0 0 0
46120 - 0 0 0 0 0 0 0 0 0 0 0 0
46121 - 0 0 0 0 0 0 0 0 0 0 0 0
46122 - 0 0 0 0 0 0 0 0 0 0 0 0
46123 - 0 0 0 0 0 0 0 0 0 0 0 0
46124 - 0 0 0 0 0 0 0 0 0 0 0 0
46125 - 6 6 6 14 14 14 42 42 42 90 90 90
46126 - 26 26 26 6 6 6 42 42 42 2 2 6
46127 - 74 74 74 250 250 250 253 253 253 253 253 253
46128 -253 253 253 253 253 253 253 253 253 253 253 253
46129 -253 253 253 253 253 253 242 242 242 242 242 242
46130 -253 253 253 253 253 253 253 253 253 253 253 253
46131 -253 253 253 253 253 253 253 253 253 253 253 253
46132 -253 253 253 253 253 253 253 253 253 253 253 253
46133 -253 253 253 253 253 253 253 253 253 253 253 253
46134 -253 253 253 253 253 253 182 182 182 2 2 6
46135 - 2 2 6 2 2 6 2 2 6 46 46 46
46136 - 2 2 6 2 2 6 2 2 6 2 2 6
46137 - 10 10 10 86 86 86 38 38 38 10 10 10
46138 - 0 0 0 0 0 0 0 0 0 0 0 0
46139 - 0 0 0 0 0 0 0 0 0 0 0 0
46140 - 0 0 0 0 0 0 0 0 0 0 0 0
46141 - 0 0 0 0 0 0 0 0 0 0 0 0
46142 - 0 0 0 0 0 0 0 0 0 0 0 0
46143 - 0 0 0 0 0 0 0 0 0 0 0 0
46144 - 0 0 0 0 0 0 0 0 0 0 0 0
46145 - 10 10 10 26 26 26 66 66 66 82 82 82
46146 - 2 2 6 22 22 22 18 18 18 2 2 6
46147 -149 149 149 253 253 253 253 253 253 253 253 253
46148 -253 253 253 253 253 253 253 253 253 253 253 253
46149 -253 253 253 253 253 253 234 234 234 242 242 242
46150 -253 253 253 253 253 253 253 253 253 253 253 253
46151 -253 253 253 253 253 253 253 253 253 253 253 253
46152 -253 253 253 253 253 253 253 253 253 253 253 253
46153 -253 253 253 253 253 253 253 253 253 253 253 253
46154 -253 253 253 253 253 253 206 206 206 2 2 6
46155 - 2 2 6 2 2 6 2 2 6 38 38 38
46156 - 2 2 6 2 2 6 2 2 6 2 2 6
46157 - 6 6 6 86 86 86 46 46 46 14 14 14
46158 - 0 0 0 0 0 0 0 0 0 0 0 0
46159 - 0 0 0 0 0 0 0 0 0 0 0 0
46160 - 0 0 0 0 0 0 0 0 0 0 0 0
46161 - 0 0 0 0 0 0 0 0 0 0 0 0
46162 - 0 0 0 0 0 0 0 0 0 0 0 0
46163 - 0 0 0 0 0 0 0 0 0 0 0 0
46164 - 0 0 0 0 0 0 0 0 0 6 6 6
46165 - 18 18 18 46 46 46 86 86 86 18 18 18
46166 - 2 2 6 34 34 34 10 10 10 6 6 6
46167 -210 210 210 253 253 253 253 253 253 253 253 253
46168 -253 253 253 253 253 253 253 253 253 253 253 253
46169 -253 253 253 253 253 253 234 234 234 242 242 242
46170 -253 253 253 253 253 253 253 253 253 253 253 253
46171 -253 253 253 253 253 253 253 253 253 253 253 253
46172 -253 253 253 253 253 253 253 253 253 253 253 253
46173 -253 253 253 253 253 253 253 253 253 253 253 253
46174 -253 253 253 253 253 253 221 221 221 6 6 6
46175 - 2 2 6 2 2 6 6 6 6 30 30 30
46176 - 2 2 6 2 2 6 2 2 6 2 2 6
46177 - 2 2 6 82 82 82 54 54 54 18 18 18
46178 - 6 6 6 0 0 0 0 0 0 0 0 0
46179 - 0 0 0 0 0 0 0 0 0 0 0 0
46180 - 0 0 0 0 0 0 0 0 0 0 0 0
46181 - 0 0 0 0 0 0 0 0 0 0 0 0
46182 - 0 0 0 0 0 0 0 0 0 0 0 0
46183 - 0 0 0 0 0 0 0 0 0 0 0 0
46184 - 0 0 0 0 0 0 0 0 0 10 10 10
46185 - 26 26 26 66 66 66 62 62 62 2 2 6
46186 - 2 2 6 38 38 38 10 10 10 26 26 26
46187 -238 238 238 253 253 253 253 253 253 253 253 253
46188 -253 253 253 253 253 253 253 253 253 253 253 253
46189 -253 253 253 253 253 253 231 231 231 238 238 238
46190 -253 253 253 253 253 253 253 253 253 253 253 253
46191 -253 253 253 253 253 253 253 253 253 253 253 253
46192 -253 253 253 253 253 253 253 253 253 253 253 253
46193 -253 253 253 253 253 253 253 253 253 253 253 253
46194 -253 253 253 253 253 253 231 231 231 6 6 6
46195 - 2 2 6 2 2 6 10 10 10 30 30 30
46196 - 2 2 6 2 2 6 2 2 6 2 2 6
46197 - 2 2 6 66 66 66 58 58 58 22 22 22
46198 - 6 6 6 0 0 0 0 0 0 0 0 0
46199 - 0 0 0 0 0 0 0 0 0 0 0 0
46200 - 0 0 0 0 0 0 0 0 0 0 0 0
46201 - 0 0 0 0 0 0 0 0 0 0 0 0
46202 - 0 0 0 0 0 0 0 0 0 0 0 0
46203 - 0 0 0 0 0 0 0 0 0 0 0 0
46204 - 0 0 0 0 0 0 0 0 0 10 10 10
46205 - 38 38 38 78 78 78 6 6 6 2 2 6
46206 - 2 2 6 46 46 46 14 14 14 42 42 42
46207 -246 246 246 253 253 253 253 253 253 253 253 253
46208 -253 253 253 253 253 253 253 253 253 253 253 253
46209 -253 253 253 253 253 253 231 231 231 242 242 242
46210 -253 253 253 253 253 253 253 253 253 253 253 253
46211 -253 253 253 253 253 253 253 253 253 253 253 253
46212 -253 253 253 253 253 253 253 253 253 253 253 253
46213 -253 253 253 253 253 253 253 253 253 253 253 253
46214 -253 253 253 253 253 253 234 234 234 10 10 10
46215 - 2 2 6 2 2 6 22 22 22 14 14 14
46216 - 2 2 6 2 2 6 2 2 6 2 2 6
46217 - 2 2 6 66 66 66 62 62 62 22 22 22
46218 - 6 6 6 0 0 0 0 0 0 0 0 0
46219 - 0 0 0 0 0 0 0 0 0 0 0 0
46220 - 0 0 0 0 0 0 0 0 0 0 0 0
46221 - 0 0 0 0 0 0 0 0 0 0 0 0
46222 - 0 0 0 0 0 0 0 0 0 0 0 0
46223 - 0 0 0 0 0 0 0 0 0 0 0 0
46224 - 0 0 0 0 0 0 6 6 6 18 18 18
46225 - 50 50 50 74 74 74 2 2 6 2 2 6
46226 - 14 14 14 70 70 70 34 34 34 62 62 62
46227 -250 250 250 253 253 253 253 253 253 253 253 253
46228 -253 253 253 253 253 253 253 253 253 253 253 253
46229 -253 253 253 253 253 253 231 231 231 246 246 246
46230 -253 253 253 253 253 253 253 253 253 253 253 253
46231 -253 253 253 253 253 253 253 253 253 253 253 253
46232 -253 253 253 253 253 253 253 253 253 253 253 253
46233 -253 253 253 253 253 253 253 253 253 253 253 253
46234 -253 253 253 253 253 253 234 234 234 14 14 14
46235 - 2 2 6 2 2 6 30 30 30 2 2 6
46236 - 2 2 6 2 2 6 2 2 6 2 2 6
46237 - 2 2 6 66 66 66 62 62 62 22 22 22
46238 - 6 6 6 0 0 0 0 0 0 0 0 0
46239 - 0 0 0 0 0 0 0 0 0 0 0 0
46240 - 0 0 0 0 0 0 0 0 0 0 0 0
46241 - 0 0 0 0 0 0 0 0 0 0 0 0
46242 - 0 0 0 0 0 0 0 0 0 0 0 0
46243 - 0 0 0 0 0 0 0 0 0 0 0 0
46244 - 0 0 0 0 0 0 6 6 6 18 18 18
46245 - 54 54 54 62 62 62 2 2 6 2 2 6
46246 - 2 2 6 30 30 30 46 46 46 70 70 70
46247 -250 250 250 253 253 253 253 253 253 253 253 253
46248 -253 253 253 253 253 253 253 253 253 253 253 253
46249 -253 253 253 253 253 253 231 231 231 246 246 246
46250 -253 253 253 253 253 253 253 253 253 253 253 253
46251 -253 253 253 253 253 253 253 253 253 253 253 253
46252 -253 253 253 253 253 253 253 253 253 253 253 253
46253 -253 253 253 253 253 253 253 253 253 253 253 253
46254 -253 253 253 253 253 253 226 226 226 10 10 10
46255 - 2 2 6 6 6 6 30 30 30 2 2 6
46256 - 2 2 6 2 2 6 2 2 6 2 2 6
46257 - 2 2 6 66 66 66 58 58 58 22 22 22
46258 - 6 6 6 0 0 0 0 0 0 0 0 0
46259 - 0 0 0 0 0 0 0 0 0 0 0 0
46260 - 0 0 0 0 0 0 0 0 0 0 0 0
46261 - 0 0 0 0 0 0 0 0 0 0 0 0
46262 - 0 0 0 0 0 0 0 0 0 0 0 0
46263 - 0 0 0 0 0 0 0 0 0 0 0 0
46264 - 0 0 0 0 0 0 6 6 6 22 22 22
46265 - 58 58 58 62 62 62 2 2 6 2 2 6
46266 - 2 2 6 2 2 6 30 30 30 78 78 78
46267 -250 250 250 253 253 253 253 253 253 253 253 253
46268 -253 253 253 253 253 253 253 253 253 253 253 253
46269 -253 253 253 253 253 253 231 231 231 246 246 246
46270 -253 253 253 253 253 253 253 253 253 253 253 253
46271 -253 253 253 253 253 253 253 253 253 253 253 253
46272 -253 253 253 253 253 253 253 253 253 253 253 253
46273 -253 253 253 253 253 253 253 253 253 253 253 253
46274 -253 253 253 253 253 253 206 206 206 2 2 6
46275 - 22 22 22 34 34 34 18 14 6 22 22 22
46276 - 26 26 26 18 18 18 6 6 6 2 2 6
46277 - 2 2 6 82 82 82 54 54 54 18 18 18
46278 - 6 6 6 0 0 0 0 0 0 0 0 0
46279 - 0 0 0 0 0 0 0 0 0 0 0 0
46280 - 0 0 0 0 0 0 0 0 0 0 0 0
46281 - 0 0 0 0 0 0 0 0 0 0 0 0
46282 - 0 0 0 0 0 0 0 0 0 0 0 0
46283 - 0 0 0 0 0 0 0 0 0 0 0 0
46284 - 0 0 0 0 0 0 6 6 6 26 26 26
46285 - 62 62 62 106 106 106 74 54 14 185 133 11
46286 -210 162 10 121 92 8 6 6 6 62 62 62
46287 -238 238 238 253 253 253 253 253 253 253 253 253
46288 -253 253 253 253 253 253 253 253 253 253 253 253
46289 -253 253 253 253 253 253 231 231 231 246 246 246
46290 -253 253 253 253 253 253 253 253 253 253 253 253
46291 -253 253 253 253 253 253 253 253 253 253 253 253
46292 -253 253 253 253 253 253 253 253 253 253 253 253
46293 -253 253 253 253 253 253 253 253 253 253 253 253
46294 -253 253 253 253 253 253 158 158 158 18 18 18
46295 - 14 14 14 2 2 6 2 2 6 2 2 6
46296 - 6 6 6 18 18 18 66 66 66 38 38 38
46297 - 6 6 6 94 94 94 50 50 50 18 18 18
46298 - 6 6 6 0 0 0 0 0 0 0 0 0
46299 - 0 0 0 0 0 0 0 0 0 0 0 0
46300 - 0 0 0 0 0 0 0 0 0 0 0 0
46301 - 0 0 0 0 0 0 0 0 0 0 0 0
46302 - 0 0 0 0 0 0 0 0 0 0 0 0
46303 - 0 0 0 0 0 0 0 0 0 6 6 6
46304 - 10 10 10 10 10 10 18 18 18 38 38 38
46305 - 78 78 78 142 134 106 216 158 10 242 186 14
46306 -246 190 14 246 190 14 156 118 10 10 10 10
46307 - 90 90 90 238 238 238 253 253 253 253 253 253
46308 -253 253 253 253 253 253 253 253 253 253 253 253
46309 -253 253 253 253 253 253 231 231 231 250 250 250
46310 -253 253 253 253 253 253 253 253 253 253 253 253
46311 -253 253 253 253 253 253 253 253 253 253 253 253
46312 -253 253 253 253 253 253 253 253 253 253 253 253
46313 -253 253 253 253 253 253 253 253 253 246 230 190
46314 -238 204 91 238 204 91 181 142 44 37 26 9
46315 - 2 2 6 2 2 6 2 2 6 2 2 6
46316 - 2 2 6 2 2 6 38 38 38 46 46 46
46317 - 26 26 26 106 106 106 54 54 54 18 18 18
46318 - 6 6 6 0 0 0 0 0 0 0 0 0
46319 - 0 0 0 0 0 0 0 0 0 0 0 0
46320 - 0 0 0 0 0 0 0 0 0 0 0 0
46321 - 0 0 0 0 0 0 0 0 0 0 0 0
46322 - 0 0 0 0 0 0 0 0 0 0 0 0
46323 - 0 0 0 6 6 6 14 14 14 22 22 22
46324 - 30 30 30 38 38 38 50 50 50 70 70 70
46325 -106 106 106 190 142 34 226 170 11 242 186 14
46326 -246 190 14 246 190 14 246 190 14 154 114 10
46327 - 6 6 6 74 74 74 226 226 226 253 253 253
46328 -253 253 253 253 253 253 253 253 253 253 253 253
46329 -253 253 253 253 253 253 231 231 231 250 250 250
46330 -253 253 253 253 253 253 253 253 253 253 253 253
46331 -253 253 253 253 253 253 253 253 253 253 253 253
46332 -253 253 253 253 253 253 253 253 253 253 253 253
46333 -253 253 253 253 253 253 253 253 253 228 184 62
46334 -241 196 14 241 208 19 232 195 16 38 30 10
46335 - 2 2 6 2 2 6 2 2 6 2 2 6
46336 - 2 2 6 6 6 6 30 30 30 26 26 26
46337 -203 166 17 154 142 90 66 66 66 26 26 26
46338 - 6 6 6 0 0 0 0 0 0 0 0 0
46339 - 0 0 0 0 0 0 0 0 0 0 0 0
46340 - 0 0 0 0 0 0 0 0 0 0 0 0
46341 - 0 0 0 0 0 0 0 0 0 0 0 0
46342 - 0 0 0 0 0 0 0 0 0 0 0 0
46343 - 6 6 6 18 18 18 38 38 38 58 58 58
46344 - 78 78 78 86 86 86 101 101 101 123 123 123
46345 -175 146 61 210 150 10 234 174 13 246 186 14
46346 -246 190 14 246 190 14 246 190 14 238 190 10
46347 -102 78 10 2 2 6 46 46 46 198 198 198
46348 -253 253 253 253 253 253 253 253 253 253 253 253
46349 -253 253 253 253 253 253 234 234 234 242 242 242
46350 -253 253 253 253 253 253 253 253 253 253 253 253
46351 -253 253 253 253 253 253 253 253 253 253 253 253
46352 -253 253 253 253 253 253 253 253 253 253 253 253
46353 -253 253 253 253 253 253 253 253 253 224 178 62
46354 -242 186 14 241 196 14 210 166 10 22 18 6
46355 - 2 2 6 2 2 6 2 2 6 2 2 6
46356 - 2 2 6 2 2 6 6 6 6 121 92 8
46357 -238 202 15 232 195 16 82 82 82 34 34 34
46358 - 10 10 10 0 0 0 0 0 0 0 0 0
46359 - 0 0 0 0 0 0 0 0 0 0 0 0
46360 - 0 0 0 0 0 0 0 0 0 0 0 0
46361 - 0 0 0 0 0 0 0 0 0 0 0 0
46362 - 0 0 0 0 0 0 0 0 0 0 0 0
46363 - 14 14 14 38 38 38 70 70 70 154 122 46
46364 -190 142 34 200 144 11 197 138 11 197 138 11
46365 -213 154 11 226 170 11 242 186 14 246 190 14
46366 -246 190 14 246 190 14 246 190 14 246 190 14
46367 -225 175 15 46 32 6 2 2 6 22 22 22
46368 -158 158 158 250 250 250 253 253 253 253 253 253
46369 -253 253 253 253 253 253 253 253 253 253 253 253
46370 -253 253 253 253 253 253 253 253 253 253 253 253
46371 -253 253 253 253 253 253 253 253 253 253 253 253
46372 -253 253 253 253 253 253 253 253 253 253 253 253
46373 -253 253 253 250 250 250 242 242 242 224 178 62
46374 -239 182 13 236 186 11 213 154 11 46 32 6
46375 - 2 2 6 2 2 6 2 2 6 2 2 6
46376 - 2 2 6 2 2 6 61 42 6 225 175 15
46377 -238 190 10 236 186 11 112 100 78 42 42 42
46378 - 14 14 14 0 0 0 0 0 0 0 0 0
46379 - 0 0 0 0 0 0 0 0 0 0 0 0
46380 - 0 0 0 0 0 0 0 0 0 0 0 0
46381 - 0 0 0 0 0 0 0 0 0 0 0 0
46382 - 0 0 0 0 0 0 0 0 0 6 6 6
46383 - 22 22 22 54 54 54 154 122 46 213 154 11
46384 -226 170 11 230 174 11 226 170 11 226 170 11
46385 -236 178 12 242 186 14 246 190 14 246 190 14
46386 -246 190 14 246 190 14 246 190 14 246 190 14
46387 -241 196 14 184 144 12 10 10 10 2 2 6
46388 - 6 6 6 116 116 116 242 242 242 253 253 253
46389 -253 253 253 253 253 253 253 253 253 253 253 253
46390 -253 253 253 253 253 253 253 253 253 253 253 253
46391 -253 253 253 253 253 253 253 253 253 253 253 253
46392 -253 253 253 253 253 253 253 253 253 253 253 253
46393 -253 253 253 231 231 231 198 198 198 214 170 54
46394 -236 178 12 236 178 12 210 150 10 137 92 6
46395 - 18 14 6 2 2 6 2 2 6 2 2 6
46396 - 6 6 6 70 47 6 200 144 11 236 178 12
46397 -239 182 13 239 182 13 124 112 88 58 58 58
46398 - 22 22 22 6 6 6 0 0 0 0 0 0
46399 - 0 0 0 0 0 0 0 0 0 0 0 0
46400 - 0 0 0 0 0 0 0 0 0 0 0 0
46401 - 0 0 0 0 0 0 0 0 0 0 0 0
46402 - 0 0 0 0 0 0 0 0 0 10 10 10
46403 - 30 30 30 70 70 70 180 133 36 226 170 11
46404 -239 182 13 242 186 14 242 186 14 246 186 14
46405 -246 190 14 246 190 14 246 190 14 246 190 14
46406 -246 190 14 246 190 14 246 190 14 246 190 14
46407 -246 190 14 232 195 16 98 70 6 2 2 6
46408 - 2 2 6 2 2 6 66 66 66 221 221 221
46409 -253 253 253 253 253 253 253 253 253 253 253 253
46410 -253 253 253 253 253 253 253 253 253 253 253 253
46411 -253 253 253 253 253 253 253 253 253 253 253 253
46412 -253 253 253 253 253 253 253 253 253 253 253 253
46413 -253 253 253 206 206 206 198 198 198 214 166 58
46414 -230 174 11 230 174 11 216 158 10 192 133 9
46415 -163 110 8 116 81 8 102 78 10 116 81 8
46416 -167 114 7 197 138 11 226 170 11 239 182 13
46417 -242 186 14 242 186 14 162 146 94 78 78 78
46418 - 34 34 34 14 14 14 6 6 6 0 0 0
46419 - 0 0 0 0 0 0 0 0 0 0 0 0
46420 - 0 0 0 0 0 0 0 0 0 0 0 0
46421 - 0 0 0 0 0 0 0 0 0 0 0 0
46422 - 0 0 0 0 0 0 0 0 0 6 6 6
46423 - 30 30 30 78 78 78 190 142 34 226 170 11
46424 -239 182 13 246 190 14 246 190 14 246 190 14
46425 -246 190 14 246 190 14 246 190 14 246 190 14
46426 -246 190 14 246 190 14 246 190 14 246 190 14
46427 -246 190 14 241 196 14 203 166 17 22 18 6
46428 - 2 2 6 2 2 6 2 2 6 38 38 38
46429 -218 218 218 253 253 253 253 253 253 253 253 253
46430 -253 253 253 253 253 253 253 253 253 253 253 253
46431 -253 253 253 253 253 253 253 253 253 253 253 253
46432 -253 253 253 253 253 253 253 253 253 253 253 253
46433 -250 250 250 206 206 206 198 198 198 202 162 69
46434 -226 170 11 236 178 12 224 166 10 210 150 10
46435 -200 144 11 197 138 11 192 133 9 197 138 11
46436 -210 150 10 226 170 11 242 186 14 246 190 14
46437 -246 190 14 246 186 14 225 175 15 124 112 88
46438 - 62 62 62 30 30 30 14 14 14 6 6 6
46439 - 0 0 0 0 0 0 0 0 0 0 0 0
46440 - 0 0 0 0 0 0 0 0 0 0 0 0
46441 - 0 0 0 0 0 0 0 0 0 0 0 0
46442 - 0 0 0 0 0 0 0 0 0 10 10 10
46443 - 30 30 30 78 78 78 174 135 50 224 166 10
46444 -239 182 13 246 190 14 246 190 14 246 190 14
46445 -246 190 14 246 190 14 246 190 14 246 190 14
46446 -246 190 14 246 190 14 246 190 14 246 190 14
46447 -246 190 14 246 190 14 241 196 14 139 102 15
46448 - 2 2 6 2 2 6 2 2 6 2 2 6
46449 - 78 78 78 250 250 250 253 253 253 253 253 253
46450 -253 253 253 253 253 253 253 253 253 253 253 253
46451 -253 253 253 253 253 253 253 253 253 253 253 253
46452 -253 253 253 253 253 253 253 253 253 253 253 253
46453 -250 250 250 214 214 214 198 198 198 190 150 46
46454 -219 162 10 236 178 12 234 174 13 224 166 10
46455 -216 158 10 213 154 11 213 154 11 216 158 10
46456 -226 170 11 239 182 13 246 190 14 246 190 14
46457 -246 190 14 246 190 14 242 186 14 206 162 42
46458 -101 101 101 58 58 58 30 30 30 14 14 14
46459 - 6 6 6 0 0 0 0 0 0 0 0 0
46460 - 0 0 0 0 0 0 0 0 0 0 0 0
46461 - 0 0 0 0 0 0 0 0 0 0 0 0
46462 - 0 0 0 0 0 0 0 0 0 10 10 10
46463 - 30 30 30 74 74 74 174 135 50 216 158 10
46464 -236 178 12 246 190 14 246 190 14 246 190 14
46465 -246 190 14 246 190 14 246 190 14 246 190 14
46466 -246 190 14 246 190 14 246 190 14 246 190 14
46467 -246 190 14 246 190 14 241 196 14 226 184 13
46468 - 61 42 6 2 2 6 2 2 6 2 2 6
46469 - 22 22 22 238 238 238 253 253 253 253 253 253
46470 -253 253 253 253 253 253 253 253 253 253 253 253
46471 -253 253 253 253 253 253 253 253 253 253 253 253
46472 -253 253 253 253 253 253 253 253 253 253 253 253
46473 -253 253 253 226 226 226 187 187 187 180 133 36
46474 -216 158 10 236 178 12 239 182 13 236 178 12
46475 -230 174 11 226 170 11 226 170 11 230 174 11
46476 -236 178 12 242 186 14 246 190 14 246 190 14
46477 -246 190 14 246 190 14 246 186 14 239 182 13
46478 -206 162 42 106 106 106 66 66 66 34 34 34
46479 - 14 14 14 6 6 6 0 0 0 0 0 0
46480 - 0 0 0 0 0 0 0 0 0 0 0 0
46481 - 0 0 0 0 0 0 0 0 0 0 0 0
46482 - 0 0 0 0 0 0 0 0 0 6 6 6
46483 - 26 26 26 70 70 70 163 133 67 213 154 11
46484 -236 178 12 246 190 14 246 190 14 246 190 14
46485 -246 190 14 246 190 14 246 190 14 246 190 14
46486 -246 190 14 246 190 14 246 190 14 246 190 14
46487 -246 190 14 246 190 14 246 190 14 241 196 14
46488 -190 146 13 18 14 6 2 2 6 2 2 6
46489 - 46 46 46 246 246 246 253 253 253 253 253 253
46490 -253 253 253 253 253 253 253 253 253 253 253 253
46491 -253 253 253 253 253 253 253 253 253 253 253 253
46492 -253 253 253 253 253 253 253 253 253 253 253 253
46493 -253 253 253 221 221 221 86 86 86 156 107 11
46494 -216 158 10 236 178 12 242 186 14 246 186 14
46495 -242 186 14 239 182 13 239 182 13 242 186 14
46496 -242 186 14 246 186 14 246 190 14 246 190 14
46497 -246 190 14 246 190 14 246 190 14 246 190 14
46498 -242 186 14 225 175 15 142 122 72 66 66 66
46499 - 30 30 30 10 10 10 0 0 0 0 0 0
46500 - 0 0 0 0 0 0 0 0 0 0 0 0
46501 - 0 0 0 0 0 0 0 0 0 0 0 0
46502 - 0 0 0 0 0 0 0 0 0 6 6 6
46503 - 26 26 26 70 70 70 163 133 67 210 150 10
46504 -236 178 12 246 190 14 246 190 14 246 190 14
46505 -246 190 14 246 190 14 246 190 14 246 190 14
46506 -246 190 14 246 190 14 246 190 14 246 190 14
46507 -246 190 14 246 190 14 246 190 14 246 190 14
46508 -232 195 16 121 92 8 34 34 34 106 106 106
46509 -221 221 221 253 253 253 253 253 253 253 253 253
46510 -253 253 253 253 253 253 253 253 253 253 253 253
46511 -253 253 253 253 253 253 253 253 253 253 253 253
46512 -253 253 253 253 253 253 253 253 253 253 253 253
46513 -242 242 242 82 82 82 18 14 6 163 110 8
46514 -216 158 10 236 178 12 242 186 14 246 190 14
46515 -246 190 14 246 190 14 246 190 14 246 190 14
46516 -246 190 14 246 190 14 246 190 14 246 190 14
46517 -246 190 14 246 190 14 246 190 14 246 190 14
46518 -246 190 14 246 190 14 242 186 14 163 133 67
46519 - 46 46 46 18 18 18 6 6 6 0 0 0
46520 - 0 0 0 0 0 0 0 0 0 0 0 0
46521 - 0 0 0 0 0 0 0 0 0 0 0 0
46522 - 0 0 0 0 0 0 0 0 0 10 10 10
46523 - 30 30 30 78 78 78 163 133 67 210 150 10
46524 -236 178 12 246 186 14 246 190 14 246 190 14
46525 -246 190 14 246 190 14 246 190 14 246 190 14
46526 -246 190 14 246 190 14 246 190 14 246 190 14
46527 -246 190 14 246 190 14 246 190 14 246 190 14
46528 -241 196 14 215 174 15 190 178 144 253 253 253
46529 -253 253 253 253 253 253 253 253 253 253 253 253
46530 -253 253 253 253 253 253 253 253 253 253 253 253
46531 -253 253 253 253 253 253 253 253 253 253 253 253
46532 -253 253 253 253 253 253 253 253 253 218 218 218
46533 - 58 58 58 2 2 6 22 18 6 167 114 7
46534 -216 158 10 236 178 12 246 186 14 246 190 14
46535 -246 190 14 246 190 14 246 190 14 246 190 14
46536 -246 190 14 246 190 14 246 190 14 246 190 14
46537 -246 190 14 246 190 14 246 190 14 246 190 14
46538 -246 190 14 246 186 14 242 186 14 190 150 46
46539 - 54 54 54 22 22 22 6 6 6 0 0 0
46540 - 0 0 0 0 0 0 0 0 0 0 0 0
46541 - 0 0 0 0 0 0 0 0 0 0 0 0
46542 - 0 0 0 0 0 0 0 0 0 14 14 14
46543 - 38 38 38 86 86 86 180 133 36 213 154 11
46544 -236 178 12 246 186 14 246 190 14 246 190 14
46545 -246 190 14 246 190 14 246 190 14 246 190 14
46546 -246 190 14 246 190 14 246 190 14 246 190 14
46547 -246 190 14 246 190 14 246 190 14 246 190 14
46548 -246 190 14 232 195 16 190 146 13 214 214 214
46549 -253 253 253 253 253 253 253 253 253 253 253 253
46550 -253 253 253 253 253 253 253 253 253 253 253 253
46551 -253 253 253 253 253 253 253 253 253 253 253 253
46552 -253 253 253 250 250 250 170 170 170 26 26 26
46553 - 2 2 6 2 2 6 37 26 9 163 110 8
46554 -219 162 10 239 182 13 246 186 14 246 190 14
46555 -246 190 14 246 190 14 246 190 14 246 190 14
46556 -246 190 14 246 190 14 246 190 14 246 190 14
46557 -246 190 14 246 190 14 246 190 14 246 190 14
46558 -246 186 14 236 178 12 224 166 10 142 122 72
46559 - 46 46 46 18 18 18 6 6 6 0 0 0
46560 - 0 0 0 0 0 0 0 0 0 0 0 0
46561 - 0 0 0 0 0 0 0 0 0 0 0 0
46562 - 0 0 0 0 0 0 6 6 6 18 18 18
46563 - 50 50 50 109 106 95 192 133 9 224 166 10
46564 -242 186 14 246 190 14 246 190 14 246 190 14
46565 -246 190 14 246 190 14 246 190 14 246 190 14
46566 -246 190 14 246 190 14 246 190 14 246 190 14
46567 -246 190 14 246 190 14 246 190 14 246 190 14
46568 -242 186 14 226 184 13 210 162 10 142 110 46
46569 -226 226 226 253 253 253 253 253 253 253 253 253
46570 -253 253 253 253 253 253 253 253 253 253 253 253
46571 -253 253 253 253 253 253 253 253 253 253 253 253
46572 -198 198 198 66 66 66 2 2 6 2 2 6
46573 - 2 2 6 2 2 6 50 34 6 156 107 11
46574 -219 162 10 239 182 13 246 186 14 246 190 14
46575 -246 190 14 246 190 14 246 190 14 246 190 14
46576 -246 190 14 246 190 14 246 190 14 246 190 14
46577 -246 190 14 246 190 14 246 190 14 242 186 14
46578 -234 174 13 213 154 11 154 122 46 66 66 66
46579 - 30 30 30 10 10 10 0 0 0 0 0 0
46580 - 0 0 0 0 0 0 0 0 0 0 0 0
46581 - 0 0 0 0 0 0 0 0 0 0 0 0
46582 - 0 0 0 0 0 0 6 6 6 22 22 22
46583 - 58 58 58 154 121 60 206 145 10 234 174 13
46584 -242 186 14 246 186 14 246 190 14 246 190 14
46585 -246 190 14 246 190 14 246 190 14 246 190 14
46586 -246 190 14 246 190 14 246 190 14 246 190 14
46587 -246 190 14 246 190 14 246 190 14 246 190 14
46588 -246 186 14 236 178 12 210 162 10 163 110 8
46589 - 61 42 6 138 138 138 218 218 218 250 250 250
46590 -253 253 253 253 253 253 253 253 253 250 250 250
46591 -242 242 242 210 210 210 144 144 144 66 66 66
46592 - 6 6 6 2 2 6 2 2 6 2 2 6
46593 - 2 2 6 2 2 6 61 42 6 163 110 8
46594 -216 158 10 236 178 12 246 190 14 246 190 14
46595 -246 190 14 246 190 14 246 190 14 246 190 14
46596 -246 190 14 246 190 14 246 190 14 246 190 14
46597 -246 190 14 239 182 13 230 174 11 216 158 10
46598 -190 142 34 124 112 88 70 70 70 38 38 38
46599 - 18 18 18 6 6 6 0 0 0 0 0 0
46600 - 0 0 0 0 0 0 0 0 0 0 0 0
46601 - 0 0 0 0 0 0 0 0 0 0 0 0
46602 - 0 0 0 0 0 0 6 6 6 22 22 22
46603 - 62 62 62 168 124 44 206 145 10 224 166 10
46604 -236 178 12 239 182 13 242 186 14 242 186 14
46605 -246 186 14 246 190 14 246 190 14 246 190 14
46606 -246 190 14 246 190 14 246 190 14 246 190 14
46607 -246 190 14 246 190 14 246 190 14 246 190 14
46608 -246 190 14 236 178 12 216 158 10 175 118 6
46609 - 80 54 7 2 2 6 6 6 6 30 30 30
46610 - 54 54 54 62 62 62 50 50 50 38 38 38
46611 - 14 14 14 2 2 6 2 2 6 2 2 6
46612 - 2 2 6 2 2 6 2 2 6 2 2 6
46613 - 2 2 6 6 6 6 80 54 7 167 114 7
46614 -213 154 11 236 178 12 246 190 14 246 190 14
46615 -246 190 14 246 190 14 246 190 14 246 190 14
46616 -246 190 14 242 186 14 239 182 13 239 182 13
46617 -230 174 11 210 150 10 174 135 50 124 112 88
46618 - 82 82 82 54 54 54 34 34 34 18 18 18
46619 - 6 6 6 0 0 0 0 0 0 0 0 0
46620 - 0 0 0 0 0 0 0 0 0 0 0 0
46621 - 0 0 0 0 0 0 0 0 0 0 0 0
46622 - 0 0 0 0 0 0 6 6 6 18 18 18
46623 - 50 50 50 158 118 36 192 133 9 200 144 11
46624 -216 158 10 219 162 10 224 166 10 226 170 11
46625 -230 174 11 236 178 12 239 182 13 239 182 13
46626 -242 186 14 246 186 14 246 190 14 246 190 14
46627 -246 190 14 246 190 14 246 190 14 246 190 14
46628 -246 186 14 230 174 11 210 150 10 163 110 8
46629 -104 69 6 10 10 10 2 2 6 2 2 6
46630 - 2 2 6 2 2 6 2 2 6 2 2 6
46631 - 2 2 6 2 2 6 2 2 6 2 2 6
46632 - 2 2 6 2 2 6 2 2 6 2 2 6
46633 - 2 2 6 6 6 6 91 60 6 167 114 7
46634 -206 145 10 230 174 11 242 186 14 246 190 14
46635 -246 190 14 246 190 14 246 186 14 242 186 14
46636 -239 182 13 230 174 11 224 166 10 213 154 11
46637 -180 133 36 124 112 88 86 86 86 58 58 58
46638 - 38 38 38 22 22 22 10 10 10 6 6 6
46639 - 0 0 0 0 0 0 0 0 0 0 0 0
46640 - 0 0 0 0 0 0 0 0 0 0 0 0
46641 - 0 0 0 0 0 0 0 0 0 0 0 0
46642 - 0 0 0 0 0 0 0 0 0 14 14 14
46643 - 34 34 34 70 70 70 138 110 50 158 118 36
46644 -167 114 7 180 123 7 192 133 9 197 138 11
46645 -200 144 11 206 145 10 213 154 11 219 162 10
46646 -224 166 10 230 174 11 239 182 13 242 186 14
46647 -246 186 14 246 186 14 246 186 14 246 186 14
46648 -239 182 13 216 158 10 185 133 11 152 99 6
46649 -104 69 6 18 14 6 2 2 6 2 2 6
46650 - 2 2 6 2 2 6 2 2 6 2 2 6
46651 - 2 2 6 2 2 6 2 2 6 2 2 6
46652 - 2 2 6 2 2 6 2 2 6 2 2 6
46653 - 2 2 6 6 6 6 80 54 7 152 99 6
46654 -192 133 9 219 162 10 236 178 12 239 182 13
46655 -246 186 14 242 186 14 239 182 13 236 178 12
46656 -224 166 10 206 145 10 192 133 9 154 121 60
46657 - 94 94 94 62 62 62 42 42 42 22 22 22
46658 - 14 14 14 6 6 6 0 0 0 0 0 0
46659 - 0 0 0 0 0 0 0 0 0 0 0 0
46660 - 0 0 0 0 0 0 0 0 0 0 0 0
46661 - 0 0 0 0 0 0 0 0 0 0 0 0
46662 - 0 0 0 0 0 0 0 0 0 6 6 6
46663 - 18 18 18 34 34 34 58 58 58 78 78 78
46664 -101 98 89 124 112 88 142 110 46 156 107 11
46665 -163 110 8 167 114 7 175 118 6 180 123 7
46666 -185 133 11 197 138 11 210 150 10 219 162 10
46667 -226 170 11 236 178 12 236 178 12 234 174 13
46668 -219 162 10 197 138 11 163 110 8 130 83 6
46669 - 91 60 6 10 10 10 2 2 6 2 2 6
46670 - 18 18 18 38 38 38 38 38 38 38 38 38
46671 - 38 38 38 38 38 38 38 38 38 38 38 38
46672 - 38 38 38 38 38 38 26 26 26 2 2 6
46673 - 2 2 6 6 6 6 70 47 6 137 92 6
46674 -175 118 6 200 144 11 219 162 10 230 174 11
46675 -234 174 13 230 174 11 219 162 10 210 150 10
46676 -192 133 9 163 110 8 124 112 88 82 82 82
46677 - 50 50 50 30 30 30 14 14 14 6 6 6
46678 - 0 0 0 0 0 0 0 0 0 0 0 0
46679 - 0 0 0 0 0 0 0 0 0 0 0 0
46680 - 0 0 0 0 0 0 0 0 0 0 0 0
46681 - 0 0 0 0 0 0 0 0 0 0 0 0
46682 - 0 0 0 0 0 0 0 0 0 0 0 0
46683 - 6 6 6 14 14 14 22 22 22 34 34 34
46684 - 42 42 42 58 58 58 74 74 74 86 86 86
46685 -101 98 89 122 102 70 130 98 46 121 87 25
46686 -137 92 6 152 99 6 163 110 8 180 123 7
46687 -185 133 11 197 138 11 206 145 10 200 144 11
46688 -180 123 7 156 107 11 130 83 6 104 69 6
46689 - 50 34 6 54 54 54 110 110 110 101 98 89
46690 - 86 86 86 82 82 82 78 78 78 78 78 78
46691 - 78 78 78 78 78 78 78 78 78 78 78 78
46692 - 78 78 78 82 82 82 86 86 86 94 94 94
46693 -106 106 106 101 101 101 86 66 34 124 80 6
46694 -156 107 11 180 123 7 192 133 9 200 144 11
46695 -206 145 10 200 144 11 192 133 9 175 118 6
46696 -139 102 15 109 106 95 70 70 70 42 42 42
46697 - 22 22 22 10 10 10 0 0 0 0 0 0
46698 - 0 0 0 0 0 0 0 0 0 0 0 0
46699 - 0 0 0 0 0 0 0 0 0 0 0 0
46700 - 0 0 0 0 0 0 0 0 0 0 0 0
46701 - 0 0 0 0 0 0 0 0 0 0 0 0
46702 - 0 0 0 0 0 0 0 0 0 0 0 0
46703 - 0 0 0 0 0 0 6 6 6 10 10 10
46704 - 14 14 14 22 22 22 30 30 30 38 38 38
46705 - 50 50 50 62 62 62 74 74 74 90 90 90
46706 -101 98 89 112 100 78 121 87 25 124 80 6
46707 -137 92 6 152 99 6 152 99 6 152 99 6
46708 -138 86 6 124 80 6 98 70 6 86 66 30
46709 -101 98 89 82 82 82 58 58 58 46 46 46
46710 - 38 38 38 34 34 34 34 34 34 34 34 34
46711 - 34 34 34 34 34 34 34 34 34 34 34 34
46712 - 34 34 34 34 34 34 38 38 38 42 42 42
46713 - 54 54 54 82 82 82 94 86 76 91 60 6
46714 -134 86 6 156 107 11 167 114 7 175 118 6
46715 -175 118 6 167 114 7 152 99 6 121 87 25
46716 -101 98 89 62 62 62 34 34 34 18 18 18
46717 - 6 6 6 0 0 0 0 0 0 0 0 0
46718 - 0 0 0 0 0 0 0 0 0 0 0 0
46719 - 0 0 0 0 0 0 0 0 0 0 0 0
46720 - 0 0 0 0 0 0 0 0 0 0 0 0
46721 - 0 0 0 0 0 0 0 0 0 0 0 0
46722 - 0 0 0 0 0 0 0 0 0 0 0 0
46723 - 0 0 0 0 0 0 0 0 0 0 0 0
46724 - 0 0 0 6 6 6 6 6 6 10 10 10
46725 - 18 18 18 22 22 22 30 30 30 42 42 42
46726 - 50 50 50 66 66 66 86 86 86 101 98 89
46727 -106 86 58 98 70 6 104 69 6 104 69 6
46728 -104 69 6 91 60 6 82 62 34 90 90 90
46729 - 62 62 62 38 38 38 22 22 22 14 14 14
46730 - 10 10 10 10 10 10 10 10 10 10 10 10
46731 - 10 10 10 10 10 10 6 6 6 10 10 10
46732 - 10 10 10 10 10 10 10 10 10 14 14 14
46733 - 22 22 22 42 42 42 70 70 70 89 81 66
46734 - 80 54 7 104 69 6 124 80 6 137 92 6
46735 -134 86 6 116 81 8 100 82 52 86 86 86
46736 - 58 58 58 30 30 30 14 14 14 6 6 6
46737 - 0 0 0 0 0 0 0 0 0 0 0 0
46738 - 0 0 0 0 0 0 0 0 0 0 0 0
46739 - 0 0 0 0 0 0 0 0 0 0 0 0
46740 - 0 0 0 0 0 0 0 0 0 0 0 0
46741 - 0 0 0 0 0 0 0 0 0 0 0 0
46742 - 0 0 0 0 0 0 0 0 0 0 0 0
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 6 6 6 10 10 10 14 14 14
46746 - 18 18 18 26 26 26 38 38 38 54 54 54
46747 - 70 70 70 86 86 86 94 86 76 89 81 66
46748 - 89 81 66 86 86 86 74 74 74 50 50 50
46749 - 30 30 30 14 14 14 6 6 6 0 0 0
46750 - 0 0 0 0 0 0 0 0 0 0 0 0
46751 - 0 0 0 0 0 0 0 0 0 0 0 0
46752 - 0 0 0 0 0 0 0 0 0 0 0 0
46753 - 6 6 6 18 18 18 34 34 34 58 58 58
46754 - 82 82 82 89 81 66 89 81 66 89 81 66
46755 - 94 86 66 94 86 76 74 74 74 50 50 50
46756 - 26 26 26 14 14 14 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
46760 - 0 0 0 0 0 0 0 0 0 0 0 0
46761 - 0 0 0 0 0 0 0 0 0 0 0 0
46762 - 0 0 0 0 0 0 0 0 0 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 - 6 6 6 6 6 6 14 14 14 18 18 18
46767 - 30 30 30 38 38 38 46 46 46 54 54 54
46768 - 50 50 50 42 42 42 30 30 30 18 18 18
46769 - 10 10 10 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 - 0 0 0 0 0 0 0 0 0 0 0 0
46773 - 0 0 0 6 6 6 14 14 14 26 26 26
46774 - 38 38 38 50 50 50 58 58 58 58 58 58
46775 - 54 54 54 42 42 42 30 30 30 18 18 18
46776 - 10 10 10 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 0 0 0 0 0 0 0 0 0
46780 - 0 0 0 0 0 0 0 0 0 0 0 0
46781 - 0 0 0 0 0 0 0 0 0 0 0 0
46782 - 0 0 0 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 6 6 6
46787 - 6 6 6 10 10 10 14 14 14 18 18 18
46788 - 18 18 18 14 14 14 10 10 10 6 6 6
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 0 0 0
46793 - 0 0 0 0 0 0 0 0 0 6 6 6
46794 - 14 14 14 18 18 18 22 22 22 22 22 22
46795 - 18 18 18 14 14 14 10 10 10 6 6 6
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 0 0 0
46800 - 0 0 0 0 0 0 0 0 0 0 0 0
46801 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46802 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46803 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46804 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46805 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46806 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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
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 4 4 4 4 4 4 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
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 4 4 4 4 4 4 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
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 4 4 4 4 4 4 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
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 4 4 4 4 4 4 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
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 4 4 4 4 4 4 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
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 3 3 3 0 0 0 0 0 0
46890 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 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 1 1 1 0 0 0
46895 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46896 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
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
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 4 4 4 4 4 4
46901 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46902 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46903 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
46904 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
46905 +5 5 5 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 3 3 3 0 0 0 1 1 1 6 6 6
46909 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
46910 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
46911 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46912 +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 4 4 4 4 4 4 4 4 4 4 4 4
46915 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46916 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46917 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
46918 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
46919 +0 0 0 3 3 3 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 0 0 0 4 4 4 41 54 63 125 124 125
46923 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
46924 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
46925 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
46926 +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 4 4 4 4 4 4 4 4 4 4 4 4
46929 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46930 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
46931 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
46932 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
46933 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 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 5 5 5 5 5 5
46936 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
46937 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
46938 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
46939 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
46940 +4 4 4 4 4 4
46941 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46942 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46943 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46944 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
46945 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
46946 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
46947 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
46948 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46949 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
46950 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
46951 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
46952 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
46953 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
46954 +4 4 4 4 4 4
46955 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46956 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46957 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46958 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
46959 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
46960 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
46961 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
46962 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
46963 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
46964 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
46965 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
46966 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
46967 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
46968 +4 4 4 4 4 4
46969 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46970 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46971 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
46972 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
46973 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
46974 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
46975 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
46976 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
46977 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
46978 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
46979 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
46980 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
46981 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
46982 +4 4 4 4 4 4
46983 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46984 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46985 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
46986 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
46987 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
46988 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
46989 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
46990 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
46991 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
46992 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
46993 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
46994 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
46995 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
46996 +4 4 4 4 4 4
46997 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46998 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46999 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
47000 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
47001 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
47002 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
47003 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
47004 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
47005 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
47006 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
47007 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
47008 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
47009 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
47010 +4 4 4 4 4 4
47011 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47012 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47013 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
47014 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
47015 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
47016 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
47017 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
47018 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
47019 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
47020 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
47021 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
47022 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
47023 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
47024 +4 4 4 4 4 4
47025 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47026 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
47027 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
47028 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
47029 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
47030 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
47031 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
47032 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
47033 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
47034 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
47035 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
47036 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
47037 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
47038 +4 4 4 4 4 4
47039 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47040 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
47041 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
47042 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
47043 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47044 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
47045 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
47046 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
47047 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
47048 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
47049 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
47050 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
47051 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
47052 +0 0 0 4 4 4
47053 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
47054 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
47055 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
47056 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
47057 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
47058 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
47059 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
47060 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
47061 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
47062 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
47063 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
47064 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
47065 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
47066 +2 0 0 0 0 0
47067 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
47068 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
47069 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
47070 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
47071 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
47072 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
47073 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
47074 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
47075 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
47076 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
47077 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
47078 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
47079 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
47080 +37 38 37 0 0 0
47081 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47082 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
47083 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
47084 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
47085 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
47086 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
47087 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
47088 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
47089 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
47090 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
47091 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
47092 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
47093 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
47094 +85 115 134 4 0 0
47095 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
47096 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
47097 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
47098 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
47099 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
47100 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
47101 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
47102 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
47103 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
47104 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
47105 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
47106 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
47107 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
47108 +60 73 81 4 0 0
47109 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
47110 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
47111 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
47112 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
47113 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
47114 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
47115 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
47116 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
47117 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
47118 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
47119 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
47120 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
47121 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
47122 +16 19 21 4 0 0
47123 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
47124 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
47125 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
47126 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
47127 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
47128 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
47129 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
47130 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
47131 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
47132 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
47133 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
47134 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
47135 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
47136 +4 0 0 4 3 3
47137 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
47138 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
47139 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
47140 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
47141 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
47142 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
47143 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
47144 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
47145 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
47146 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
47147 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
47148 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
47149 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
47150 +3 2 2 4 4 4
47151 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
47152 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
47153 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
47154 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47155 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
47156 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
47157 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
47158 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
47159 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
47160 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
47161 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
47162 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
47163 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
47164 +4 4 4 4 4 4
47165 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
47166 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
47167 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
47168 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
47169 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
47170 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
47171 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
47172 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
47173 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
47174 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
47175 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
47176 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
47177 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
47178 +4 4 4 4 4 4
47179 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
47180 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
47181 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
47182 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
47183 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
47184 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47185 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
47186 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
47187 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
47188 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
47189 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
47190 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
47191 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
47192 +5 5 5 5 5 5
47193 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
47194 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
47195 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
47196 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
47197 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
47198 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47199 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
47200 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
47201 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
47202 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
47203 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
47204 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
47205 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47206 +5 5 5 4 4 4
47207 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
47208 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
47209 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
47210 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
47211 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47212 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
47213 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
47214 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
47215 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
47216 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
47217 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
47218 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47219 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47220 +4 4 4 4 4 4
47221 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
47222 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
47223 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
47224 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
47225 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
47226 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47227 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47228 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
47229 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
47230 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
47231 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
47232 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
47233 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47234 +4 4 4 4 4 4
47235 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
47236 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
47237 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
47238 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
47239 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47240 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
47241 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
47242 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
47243 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
47244 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
47245 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
47246 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47247 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47248 +4 4 4 4 4 4
47249 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
47250 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
47251 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
47252 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
47253 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47254 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47255 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47256 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
47257 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
47258 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
47259 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
47260 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47261 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47262 +4 4 4 4 4 4
47263 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
47264 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
47265 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
47266 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
47267 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47268 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
47269 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47270 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
47271 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
47272 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
47273 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47274 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47275 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47276 +4 4 4 4 4 4
47277 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
47278 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
47279 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
47280 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
47281 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47282 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
47283 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
47284 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
47285 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
47286 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
47287 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
47288 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47289 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47290 +4 4 4 4 4 4
47291 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
47292 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
47293 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
47294 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
47295 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47296 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
47297 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
47298 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
47299 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
47300 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
47301 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
47302 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47303 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47304 +4 4 4 4 4 4
47305 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
47306 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
47307 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
47308 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47309 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
47310 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
47311 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
47312 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
47313 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
47314 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
47315 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47316 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47317 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47318 +4 4 4 4 4 4
47319 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
47320 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
47321 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
47322 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47323 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47324 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
47325 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
47326 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
47327 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
47328 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
47329 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47330 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47331 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47332 +4 4 4 4 4 4
47333 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
47334 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
47335 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47336 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47337 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47338 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
47339 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
47340 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
47341 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
47342 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
47343 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47344 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47345 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47346 +4 4 4 4 4 4
47347 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
47348 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
47349 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47350 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47351 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47352 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
47353 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
47354 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
47355 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47356 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47357 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47358 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47359 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47360 +4 4 4 4 4 4
47361 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47362 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
47363 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47364 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
47365 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
47366 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
47367 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
47368 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
47369 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47370 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47371 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47372 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47373 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47374 +4 4 4 4 4 4
47375 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47376 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
47377 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47378 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
47379 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47380 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
47381 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
47382 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
47383 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47384 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47385 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47386 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47387 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47388 +4 4 4 4 4 4
47389 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
47390 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
47391 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47392 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
47393 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
47394 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
47395 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
47396 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
47397 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47398 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47399 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47400 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47401 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47402 +4 4 4 4 4 4
47403 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
47404 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
47405 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47406 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
47407 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
47408 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
47409 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
47410 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
47411 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47412 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47413 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47414 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47415 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47416 +4 4 4 4 4 4
47417 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47418 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
47419 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47420 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
47421 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
47422 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
47423 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
47424 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
47425 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47426 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47427 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47428 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47429 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47430 +4 4 4 4 4 4
47431 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
47432 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
47433 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47434 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
47435 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
47436 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
47437 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
47438 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
47439 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
47440 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47441 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47442 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47443 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47444 +4 4 4 4 4 4
47445 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47446 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
47447 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
47448 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
47449 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
47450 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
47451 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
47452 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
47453 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47454 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47455 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47456 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47457 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47458 +4 4 4 4 4 4
47459 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47460 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
47461 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47462 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
47463 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
47464 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
47465 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
47466 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
47467 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47468 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47469 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47470 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47471 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47472 +4 4 4 4 4 4
47473 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47474 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
47475 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
47476 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
47477 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
47478 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
47479 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47480 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
47481 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47482 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47483 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47484 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47485 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47486 +4 4 4 4 4 4
47487 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47488 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
47489 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
47490 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47491 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
47492 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
47493 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47494 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
47495 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47496 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47497 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47498 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47499 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47500 +4 4 4 4 4 4
47501 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47502 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
47503 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
47504 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
47505 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
47506 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
47507 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
47508 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
47509 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
47510 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47511 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47512 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47513 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47514 +4 4 4 4 4 4
47515 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47516 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
47517 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
47518 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
47519 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
47520 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
47521 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
47522 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
47523 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
47524 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47525 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47526 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47527 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47528 +4 4 4 4 4 4
47529 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
47530 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
47531 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
47532 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
47533 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47534 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
47535 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
47536 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
47537 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
47538 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47539 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47540 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47541 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47542 +4 4 4 4 4 4
47543 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47544 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
47545 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
47546 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
47547 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
47548 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
47549 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
47550 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
47551 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
47552 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47553 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47554 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47555 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47556 +4 4 4 4 4 4
47557 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
47558 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
47559 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
47560 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
47561 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
47562 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
47563 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
47564 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
47565 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
47566 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
47567 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47568 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47569 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47570 +4 4 4 4 4 4
47571 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
47572 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47573 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
47574 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
47575 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
47576 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
47577 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
47578 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
47579 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
47580 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
47581 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47582 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47583 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47584 +4 4 4 4 4 4
47585 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
47586 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47587 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
47588 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
47589 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
47590 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
47591 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47592 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
47593 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
47594 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
47595 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47596 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47597 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47598 +4 4 4 4 4 4
47599 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
47600 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
47601 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
47602 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
47603 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
47604 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
47605 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
47606 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
47607 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
47608 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
47609 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47610 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47611 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47612 +4 4 4 4 4 4
47613 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
47614 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
47615 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47616 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
47617 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
47618 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
47619 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
47620 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
47621 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
47622 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
47623 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47624 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47625 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47626 +4 4 4 4 4 4
47627 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47628 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
47629 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
47630 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
47631 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
47632 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
47633 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
47634 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
47635 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
47636 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47637 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47638 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47639 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47640 +4 4 4 4 4 4
47641 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
47642 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
47643 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
47644 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
47645 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
47646 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
47647 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
47648 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
47649 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
47650 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47651 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47652 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47653 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47654 +4 4 4 4 4 4
47655 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
47656 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
47657 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
47658 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
47659 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
47660 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
47661 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
47662 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
47663 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47664 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47665 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47666 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47667 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47668 +4 4 4 4 4 4
47669 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
47670 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47671 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
47672 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47673 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
47674 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
47675 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
47676 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
47677 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
47678 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47679 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47680 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47681 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47682 +4 4 4 4 4 4
47683 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
47684 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
47685 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
47686 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
47687 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
47688 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
47689 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
47690 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
47691 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
47692 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47693 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47694 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47695 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47696 +4 4 4 4 4 4
47697 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47698 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
47699 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
47700 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
47701 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
47702 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
47703 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
47704 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
47705 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47706 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47707 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47708 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47709 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47710 +4 4 4 4 4 4
47711 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
47712 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
47713 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47714 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
47715 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
47716 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
47717 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
47718 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
47719 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47720 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47721 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47722 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47723 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47724 +4 4 4 4 4 4
47725 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47726 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
47727 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
47728 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
47729 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
47730 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
47731 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
47732 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47733 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47734 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47735 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47736 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47737 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47738 +4 4 4 4 4 4
47739 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47740 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
47741 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47742 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
47743 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
47744 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
47745 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
47746 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
47747 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47748 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47749 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47750 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47751 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47752 +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 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
47755 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
47756 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
47757 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
47758 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
47759 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
47760 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
47761 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47762 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47763 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47764 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47765 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47766 +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 5 5 5 5 5 5 5 5 5
47769 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
47770 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47771 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
47772 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
47773 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
47774 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47775 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47776 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47777 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47778 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47779 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47780 +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 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47784 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
47785 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
47786 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
47787 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
47788 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47789 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47790 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47791 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47792 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47793 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47794 +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 5 5 5
47798 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47799 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
47800 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
47801 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
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 4 4 4
47804 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47805 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47806 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47807 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47808 +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 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47813 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47814 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
47815 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47819 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47820 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47821 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47822 +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 5 5 5 4 3 3 5 5 5 6 6 6
47827 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47828 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47829 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47833 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47834 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47835 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47836 +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 5 5 5 4 3 3 5 5 5
47841 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
47842 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
47843 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4
47847 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47848 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47849 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47850 +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 5 5 5
47855 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
47856 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47857 +6 6 6 4 3 3 5 5 5 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 4 4 4
47861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47862 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47863 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47864 +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 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
47870 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
47871 +4 3 3 5 5 5 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47876 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47877 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47878 +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 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
47884 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
47885 +5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47890 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47891 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47892 +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 5 5 5 4 3 3 6 6 6
47898 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
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 4 4 4 4 4 4 4 4 4
47904 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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
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 5 5 5 4 3 3
47912 +5 5 5 4 3 3 5 5 5 5 5 5 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 4 4 4 4 4 4
47918 +4 4 4 4 4 4 4 4 4 4 4 4 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
47921 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
47922 index fe92eed..106e085 100644
47923 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
47924 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
47925 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
47926 struct mb862xxfb_par *par = info->par;
47927
47928 if (info->var.bits_per_pixel == 32) {
47929 - info->fbops->fb_fillrect = cfb_fillrect;
47930 - info->fbops->fb_copyarea = cfb_copyarea;
47931 - info->fbops->fb_imageblit = cfb_imageblit;
47932 + pax_open_kernel();
47933 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47934 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47935 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47936 + pax_close_kernel();
47937 } else {
47938 outreg(disp, GC_L0EM, 3);
47939 - info->fbops->fb_fillrect = mb86290fb_fillrect;
47940 - info->fbops->fb_copyarea = mb86290fb_copyarea;
47941 - info->fbops->fb_imageblit = mb86290fb_imageblit;
47942 + pax_open_kernel();
47943 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
47944 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
47945 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
47946 + pax_close_kernel();
47947 }
47948 outreg(draw, GDC_REG_DRAW_BASE, 0);
47949 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
47950 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
47951 index ff22871..b129bed 100644
47952 --- a/drivers/video/nvidia/nvidia.c
47953 +++ b/drivers/video/nvidia/nvidia.c
47954 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
47955 info->fix.line_length = (info->var.xres_virtual *
47956 info->var.bits_per_pixel) >> 3;
47957 if (info->var.accel_flags) {
47958 - info->fbops->fb_imageblit = nvidiafb_imageblit;
47959 - info->fbops->fb_fillrect = nvidiafb_fillrect;
47960 - info->fbops->fb_copyarea = nvidiafb_copyarea;
47961 - info->fbops->fb_sync = nvidiafb_sync;
47962 + pax_open_kernel();
47963 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
47964 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
47965 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
47966 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
47967 + pax_close_kernel();
47968 info->pixmap.scan_align = 4;
47969 info->flags &= ~FBINFO_HWACCEL_DISABLED;
47970 info->flags |= FBINFO_READS_FAST;
47971 NVResetGraphics(info);
47972 } else {
47973 - info->fbops->fb_imageblit = cfb_imageblit;
47974 - info->fbops->fb_fillrect = cfb_fillrect;
47975 - info->fbops->fb_copyarea = cfb_copyarea;
47976 - info->fbops->fb_sync = NULL;
47977 + pax_open_kernel();
47978 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47979 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47980 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47981 + *(void **)&info->fbops->fb_sync = NULL;
47982 + pax_close_kernel();
47983 info->pixmap.scan_align = 1;
47984 info->flags |= FBINFO_HWACCEL_DISABLED;
47985 info->flags &= ~FBINFO_READS_FAST;
47986 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
47987 info->pixmap.size = 8 * 1024;
47988 info->pixmap.flags = FB_PIXMAP_SYSTEM;
47989
47990 - if (!hwcur)
47991 - info->fbops->fb_cursor = NULL;
47992 + if (!hwcur) {
47993 + pax_open_kernel();
47994 + *(void **)&info->fbops->fb_cursor = NULL;
47995 + pax_close_kernel();
47996 + }
47997
47998 info->var.accel_flags = (!noaccel);
47999
48000 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
48001 index 76d9053..dec2bfd 100644
48002 --- a/drivers/video/s1d13xxxfb.c
48003 +++ b/drivers/video/s1d13xxxfb.c
48004 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
48005
48006 switch(prod_id) {
48007 case S1D13506_PROD_ID: /* activate acceleration */
48008 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
48009 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
48010 + pax_open_kernel();
48011 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
48012 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
48013 + pax_close_kernel();
48014 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
48015 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
48016 break;
48017 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
48018 index 97bd662..39fab85 100644
48019 --- a/drivers/video/smscufx.c
48020 +++ b/drivers/video/smscufx.c
48021 @@ -1171,7 +1171,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
48022 fb_deferred_io_cleanup(info);
48023 kfree(info->fbdefio);
48024 info->fbdefio = NULL;
48025 - info->fbops->fb_mmap = ufx_ops_mmap;
48026 + pax_open_kernel();
48027 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
48028 + pax_close_kernel();
48029 }
48030
48031 pr_debug("released /dev/fb%d user=%d count=%d",
48032 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
48033 index 86d449e..8e04dc5 100644
48034 --- a/drivers/video/udlfb.c
48035 +++ b/drivers/video/udlfb.c
48036 @@ -619,11 +619,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
48037 dlfb_urb_completion(urb);
48038
48039 error:
48040 - atomic_add(bytes_sent, &dev->bytes_sent);
48041 - atomic_add(bytes_identical, &dev->bytes_identical);
48042 - atomic_add(width*height*2, &dev->bytes_rendered);
48043 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
48044 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
48045 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
48046 end_cycles = get_cycles();
48047 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
48048 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
48049 >> 10)), /* Kcycles */
48050 &dev->cpu_kcycles_used);
48051
48052 @@ -744,11 +744,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
48053 dlfb_urb_completion(urb);
48054
48055 error:
48056 - atomic_add(bytes_sent, &dev->bytes_sent);
48057 - atomic_add(bytes_identical, &dev->bytes_identical);
48058 - atomic_add(bytes_rendered, &dev->bytes_rendered);
48059 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
48060 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
48061 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
48062 end_cycles = get_cycles();
48063 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
48064 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
48065 >> 10)), /* Kcycles */
48066 &dev->cpu_kcycles_used);
48067 }
48068 @@ -989,7 +989,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
48069 fb_deferred_io_cleanup(info);
48070 kfree(info->fbdefio);
48071 info->fbdefio = NULL;
48072 - info->fbops->fb_mmap = dlfb_ops_mmap;
48073 + pax_open_kernel();
48074 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
48075 + pax_close_kernel();
48076 }
48077
48078 pr_warn("released /dev/fb%d user=%d count=%d\n",
48079 @@ -1372,7 +1374,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
48080 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48081 struct dlfb_data *dev = fb_info->par;
48082 return snprintf(buf, PAGE_SIZE, "%u\n",
48083 - atomic_read(&dev->bytes_rendered));
48084 + atomic_read_unchecked(&dev->bytes_rendered));
48085 }
48086
48087 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48088 @@ -1380,7 +1382,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48089 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48090 struct dlfb_data *dev = fb_info->par;
48091 return snprintf(buf, PAGE_SIZE, "%u\n",
48092 - atomic_read(&dev->bytes_identical));
48093 + atomic_read_unchecked(&dev->bytes_identical));
48094 }
48095
48096 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48097 @@ -1388,7 +1390,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48098 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48099 struct dlfb_data *dev = fb_info->par;
48100 return snprintf(buf, PAGE_SIZE, "%u\n",
48101 - atomic_read(&dev->bytes_sent));
48102 + atomic_read_unchecked(&dev->bytes_sent));
48103 }
48104
48105 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
48106 @@ -1396,7 +1398,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
48107 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48108 struct dlfb_data *dev = fb_info->par;
48109 return snprintf(buf, PAGE_SIZE, "%u\n",
48110 - atomic_read(&dev->cpu_kcycles_used));
48111 + atomic_read_unchecked(&dev->cpu_kcycles_used));
48112 }
48113
48114 static ssize_t edid_show(
48115 @@ -1456,10 +1458,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
48116 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48117 struct dlfb_data *dev = fb_info->par;
48118
48119 - atomic_set(&dev->bytes_rendered, 0);
48120 - atomic_set(&dev->bytes_identical, 0);
48121 - atomic_set(&dev->bytes_sent, 0);
48122 - atomic_set(&dev->cpu_kcycles_used, 0);
48123 + atomic_set_unchecked(&dev->bytes_rendered, 0);
48124 + atomic_set_unchecked(&dev->bytes_identical, 0);
48125 + atomic_set_unchecked(&dev->bytes_sent, 0);
48126 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
48127
48128 return count;
48129 }
48130 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
48131 index b75db01..ad2f34a 100644
48132 --- a/drivers/video/uvesafb.c
48133 +++ b/drivers/video/uvesafb.c
48134 @@ -19,6 +19,7 @@
48135 #include <linux/io.h>
48136 #include <linux/mutex.h>
48137 #include <linux/slab.h>
48138 +#include <linux/moduleloader.h>
48139 #include <video/edid.h>
48140 #include <video/uvesafb.h>
48141 #ifdef CONFIG_X86
48142 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
48143 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
48144 par->pmi_setpal = par->ypan = 0;
48145 } else {
48146 +
48147 +#ifdef CONFIG_PAX_KERNEXEC
48148 +#ifdef CONFIG_MODULES
48149 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
48150 +#endif
48151 + if (!par->pmi_code) {
48152 + par->pmi_setpal = par->ypan = 0;
48153 + return 0;
48154 + }
48155 +#endif
48156 +
48157 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
48158 + task->t.regs.edi);
48159 +
48160 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48161 + pax_open_kernel();
48162 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
48163 + pax_close_kernel();
48164 +
48165 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
48166 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
48167 +#else
48168 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
48169 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
48170 +#endif
48171 +
48172 printk(KERN_INFO "uvesafb: protected mode interface info at "
48173 "%04x:%04x\n",
48174 (u16)task->t.regs.es, (u16)task->t.regs.edi);
48175 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
48176 par->ypan = ypan;
48177
48178 if (par->pmi_setpal || par->ypan) {
48179 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
48180 if (__supported_pte_mask & _PAGE_NX) {
48181 par->pmi_setpal = par->ypan = 0;
48182 printk(KERN_WARNING "uvesafb: NX protection is actively."
48183 "We have better not to use the PMI.\n");
48184 - } else {
48185 + } else
48186 +#endif
48187 uvesafb_vbe_getpmi(task, par);
48188 - }
48189 }
48190 #else
48191 /* The protected mode interface is not available on non-x86. */
48192 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48193 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
48194
48195 /* Disable blanking if the user requested so. */
48196 - if (!blank)
48197 - info->fbops->fb_blank = NULL;
48198 + if (!blank) {
48199 + pax_open_kernel();
48200 + *(void **)&info->fbops->fb_blank = NULL;
48201 + pax_close_kernel();
48202 + }
48203
48204 /*
48205 * Find out how much IO memory is required for the mode with
48206 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48207 info->flags = FBINFO_FLAG_DEFAULT |
48208 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
48209
48210 - if (!par->ypan)
48211 - info->fbops->fb_pan_display = NULL;
48212 + if (!par->ypan) {
48213 + pax_open_kernel();
48214 + *(void **)&info->fbops->fb_pan_display = NULL;
48215 + pax_close_kernel();
48216 + }
48217 }
48218
48219 static void uvesafb_init_mtrr(struct fb_info *info)
48220 @@ -1836,6 +1866,11 @@ out:
48221 if (par->vbe_modes)
48222 kfree(par->vbe_modes);
48223
48224 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48225 + if (par->pmi_code)
48226 + module_free_exec(NULL, par->pmi_code);
48227 +#endif
48228 +
48229 framebuffer_release(info);
48230 return err;
48231 }
48232 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
48233 kfree(par->vbe_state_orig);
48234 if (par->vbe_state_saved)
48235 kfree(par->vbe_state_saved);
48236 +
48237 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48238 + if (par->pmi_code)
48239 + module_free_exec(NULL, par->pmi_code);
48240 +#endif
48241 +
48242 }
48243
48244 framebuffer_release(info);
48245 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
48246 index 501b340..d80aa17 100644
48247 --- a/drivers/video/vesafb.c
48248 +++ b/drivers/video/vesafb.c
48249 @@ -9,6 +9,7 @@
48250 */
48251
48252 #include <linux/module.h>
48253 +#include <linux/moduleloader.h>
48254 #include <linux/kernel.h>
48255 #include <linux/errno.h>
48256 #include <linux/string.h>
48257 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
48258 static int vram_total __initdata; /* Set total amount of memory */
48259 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
48260 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
48261 -static void (*pmi_start)(void) __read_mostly;
48262 -static void (*pmi_pal) (void) __read_mostly;
48263 +static void (*pmi_start)(void) __read_only;
48264 +static void (*pmi_pal) (void) __read_only;
48265 static int depth __read_mostly;
48266 static int vga_compat __read_mostly;
48267 /* --------------------------------------------------------------------- */
48268 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
48269 unsigned int size_vmode;
48270 unsigned int size_remap;
48271 unsigned int size_total;
48272 + void *pmi_code = NULL;
48273
48274 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
48275 return -ENODEV;
48276 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
48277 size_remap = size_total;
48278 vesafb_fix.smem_len = size_remap;
48279
48280 -#ifndef __i386__
48281 - screen_info.vesapm_seg = 0;
48282 -#endif
48283 -
48284 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
48285 printk(KERN_WARNING
48286 "vesafb: cannot reserve video memory at 0x%lx\n",
48287 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
48288 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
48289 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
48290
48291 +#ifdef __i386__
48292 +
48293 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48294 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
48295 + if (!pmi_code)
48296 +#elif !defined(CONFIG_PAX_KERNEXEC)
48297 + if (0)
48298 +#endif
48299 +
48300 +#endif
48301 + screen_info.vesapm_seg = 0;
48302 +
48303 if (screen_info.vesapm_seg) {
48304 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
48305 - screen_info.vesapm_seg,screen_info.vesapm_off);
48306 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
48307 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
48308 }
48309
48310 if (screen_info.vesapm_seg < 0xc000)
48311 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
48312
48313 if (ypan || pmi_setpal) {
48314 unsigned short *pmi_base;
48315 +
48316 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
48317 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
48318 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
48319 +
48320 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48321 + pax_open_kernel();
48322 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
48323 +#else
48324 + pmi_code = pmi_base;
48325 +#endif
48326 +
48327 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
48328 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
48329 +
48330 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48331 + pmi_start = ktva_ktla(pmi_start);
48332 + pmi_pal = ktva_ktla(pmi_pal);
48333 + pax_close_kernel();
48334 +#endif
48335 +
48336 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
48337 if (pmi_base[3]) {
48338 printk(KERN_INFO "vesafb: pmi: ports = ");
48339 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48340 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
48341 (ypan ? FBINFO_HWACCEL_YPAN : 0);
48342
48343 - if (!ypan)
48344 - info->fbops->fb_pan_display = NULL;
48345 + if (!ypan) {
48346 + pax_open_kernel();
48347 + *(void **)&info->fbops->fb_pan_display = NULL;
48348 + pax_close_kernel();
48349 + }
48350
48351 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
48352 err = -ENOMEM;
48353 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48354 info->node, info->fix.id);
48355 return 0;
48356 err:
48357 +
48358 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48359 + module_free_exec(NULL, pmi_code);
48360 +#endif
48361 +
48362 if (info->screen_base)
48363 iounmap(info->screen_base);
48364 framebuffer_release(info);
48365 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
48366 index 88714ae..16c2e11 100644
48367 --- a/drivers/video/via/via_clock.h
48368 +++ b/drivers/video/via/via_clock.h
48369 @@ -56,7 +56,7 @@ struct via_clock {
48370
48371 void (*set_engine_pll_state)(u8 state);
48372 void (*set_engine_pll)(struct via_pll_config config);
48373 -};
48374 +} __no_const;
48375
48376
48377 static inline u32 get_pll_internal_frequency(u32 ref_freq,
48378 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
48379 index fef20db..d28b1ab 100644
48380 --- a/drivers/xen/xenfs/xenstored.c
48381 +++ b/drivers/xen/xenfs/xenstored.c
48382 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
48383 static int xsd_kva_open(struct inode *inode, struct file *file)
48384 {
48385 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
48386 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48387 + NULL);
48388 +#else
48389 xen_store_interface);
48390 +#endif
48391 +
48392 if (!file->private_data)
48393 return -ENOMEM;
48394 return 0;
48395 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
48396 index 890bed5..17ae73e 100644
48397 --- a/fs/9p/vfs_inode.c
48398 +++ b/fs/9p/vfs_inode.c
48399 @@ -1329,7 +1329,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
48400 void
48401 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48402 {
48403 - char *s = nd_get_link(nd);
48404 + const char *s = nd_get_link(nd);
48405
48406 p9_debug(P9_DEBUG_VFS, " %s %s\n",
48407 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
48408 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
48409 index 0efd152..b5802ad 100644
48410 --- a/fs/Kconfig.binfmt
48411 +++ b/fs/Kconfig.binfmt
48412 @@ -89,7 +89,7 @@ config HAVE_AOUT
48413
48414 config BINFMT_AOUT
48415 tristate "Kernel support for a.out and ECOFF binaries"
48416 - depends on HAVE_AOUT
48417 + depends on HAVE_AOUT && BROKEN
48418 ---help---
48419 A.out (Assembler.OUTput) is a set of formats for libraries and
48420 executables used in the earliest versions of UNIX. Linux used
48421 diff --git a/fs/aio.c b/fs/aio.c
48422 index 71f613c..9d01f1f 100644
48423 --- a/fs/aio.c
48424 +++ b/fs/aio.c
48425 @@ -111,7 +111,7 @@ static int aio_setup_ring(struct kioctx *ctx)
48426 size += sizeof(struct io_event) * nr_events;
48427 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
48428
48429 - if (nr_pages < 0)
48430 + if (nr_pages <= 0)
48431 return -EINVAL;
48432
48433 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
48434 @@ -1373,18 +1373,19 @@ static ssize_t aio_fsync(struct kiocb *iocb)
48435 static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
48436 {
48437 ssize_t ret;
48438 + struct iovec iovstack;
48439
48440 #ifdef CONFIG_COMPAT
48441 if (compat)
48442 ret = compat_rw_copy_check_uvector(type,
48443 (struct compat_iovec __user *)kiocb->ki_buf,
48444 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
48445 + kiocb->ki_nbytes, 1, &iovstack,
48446 &kiocb->ki_iovec);
48447 else
48448 #endif
48449 ret = rw_copy_check_uvector(type,
48450 (struct iovec __user *)kiocb->ki_buf,
48451 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
48452 + kiocb->ki_nbytes, 1, &iovstack,
48453 &kiocb->ki_iovec);
48454 if (ret < 0)
48455 goto out;
48456 @@ -1393,6 +1394,10 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
48457 if (ret < 0)
48458 goto out;
48459
48460 + if (kiocb->ki_iovec == &iovstack) {
48461 + kiocb->ki_inline_vec = iovstack;
48462 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
48463 + }
48464 kiocb->ki_nr_segs = kiocb->ki_nbytes;
48465 kiocb->ki_cur_seg = 0;
48466 /* ki_nbytes/left now reflect bytes instead of segs */
48467 diff --git a/fs/attr.c b/fs/attr.c
48468 index 1449adb..a2038c2 100644
48469 --- a/fs/attr.c
48470 +++ b/fs/attr.c
48471 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
48472 unsigned long limit;
48473
48474 limit = rlimit(RLIMIT_FSIZE);
48475 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
48476 if (limit != RLIM_INFINITY && offset > limit)
48477 goto out_sig;
48478 if (offset > inode->i_sb->s_maxbytes)
48479 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
48480 index 03bc1d3..6205356 100644
48481 --- a/fs/autofs4/waitq.c
48482 +++ b/fs/autofs4/waitq.c
48483 @@ -61,7 +61,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
48484 {
48485 unsigned long sigpipe, flags;
48486 mm_segment_t fs;
48487 - const char *data = (const char *)addr;
48488 + const char __user *data = (const char __force_user *)addr;
48489 ssize_t wr = 0;
48490
48491 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
48492 @@ -348,6 +348,10 @@ static int validate_request(struct autofs_wait_queue **wait,
48493 return 1;
48494 }
48495
48496 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48497 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
48498 +#endif
48499 +
48500 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48501 enum autofs_notify notify)
48502 {
48503 @@ -381,7 +385,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48504
48505 /* If this is a direct mount request create a dummy name */
48506 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
48507 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48508 + /* this name does get written to userland via autofs4_write() */
48509 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
48510 +#else
48511 qstr.len = sprintf(name, "%p", dentry);
48512 +#endif
48513 else {
48514 qstr.len = autofs4_getpath(sbi, dentry, &name);
48515 if (!qstr.len) {
48516 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
48517 index 2722387..c8dd2a7 100644
48518 --- a/fs/befs/endian.h
48519 +++ b/fs/befs/endian.h
48520 @@ -11,7 +11,7 @@
48521
48522 #include <asm/byteorder.h>
48523
48524 -static inline u64
48525 +static inline u64 __intentional_overflow(-1)
48526 fs64_to_cpu(const struct super_block *sb, fs64 n)
48527 {
48528 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48529 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
48530 return (__force fs64)cpu_to_be64(n);
48531 }
48532
48533 -static inline u32
48534 +static inline u32 __intentional_overflow(-1)
48535 fs32_to_cpu(const struct super_block *sb, fs32 n)
48536 {
48537 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48538 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
48539 index 2b3bda8..6a2d4be 100644
48540 --- a/fs/befs/linuxvfs.c
48541 +++ b/fs/befs/linuxvfs.c
48542 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48543 {
48544 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
48545 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
48546 - char *link = nd_get_link(nd);
48547 + const char *link = nd_get_link(nd);
48548 if (!IS_ERR(link))
48549 kfree(link);
48550 }
48551 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
48552 index 6043567..16a9239 100644
48553 --- a/fs/binfmt_aout.c
48554 +++ b/fs/binfmt_aout.c
48555 @@ -16,6 +16,7 @@
48556 #include <linux/string.h>
48557 #include <linux/fs.h>
48558 #include <linux/file.h>
48559 +#include <linux/security.h>
48560 #include <linux/stat.h>
48561 #include <linux/fcntl.h>
48562 #include <linux/ptrace.h>
48563 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
48564 #endif
48565 # define START_STACK(u) ((void __user *)u.start_stack)
48566
48567 + memset(&dump, 0, sizeof(dump));
48568 +
48569 fs = get_fs();
48570 set_fs(KERNEL_DS);
48571 has_dumped = 1;
48572 @@ -70,10 +73,12 @@ static int aout_core_dump(struct coredump_params *cprm)
48573
48574 /* If the size of the dump file exceeds the rlimit, then see what would happen
48575 if we wrote the stack, but not the data area. */
48576 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
48577 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
48578 dump.u_dsize = 0;
48579
48580 /* Make sure we have enough room to write the stack and data areas. */
48581 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
48582 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
48583 dump.u_ssize = 0;
48584
48585 @@ -234,6 +239,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
48586 rlim = rlimit(RLIMIT_DATA);
48587 if (rlim >= RLIM_INFINITY)
48588 rlim = ~0;
48589 +
48590 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
48591 if (ex.a_data + ex.a_bss > rlim)
48592 return -ENOMEM;
48593
48594 @@ -268,6 +275,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
48595
48596 install_exec_creds(bprm);
48597
48598 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48599 + current->mm->pax_flags = 0UL;
48600 +#endif
48601 +
48602 +#ifdef CONFIG_PAX_PAGEEXEC
48603 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
48604 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
48605 +
48606 +#ifdef CONFIG_PAX_EMUTRAMP
48607 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
48608 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
48609 +#endif
48610 +
48611 +#ifdef CONFIG_PAX_MPROTECT
48612 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
48613 + current->mm->pax_flags |= MF_PAX_MPROTECT;
48614 +#endif
48615 +
48616 + }
48617 +#endif
48618 +
48619 if (N_MAGIC(ex) == OMAGIC) {
48620 unsigned long text_addr, map_size;
48621 loff_t pos;
48622 @@ -333,7 +361,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
48623 }
48624
48625 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
48626 - PROT_READ | PROT_WRITE | PROT_EXEC,
48627 + PROT_READ | PROT_WRITE,
48628 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
48629 fd_offset + ex.a_text);
48630 if (error != N_DATADDR(ex)) {
48631 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
48632 index 0c42cdb..b62581e9 100644
48633 --- a/fs/binfmt_elf.c
48634 +++ b/fs/binfmt_elf.c
48635 @@ -33,6 +33,7 @@
48636 #include <linux/elf.h>
48637 #include <linux/utsname.h>
48638 #include <linux/coredump.h>
48639 +#include <linux/xattr.h>
48640 #include <asm/uaccess.h>
48641 #include <asm/param.h>
48642 #include <asm/page.h>
48643 @@ -59,6 +60,10 @@ static int elf_core_dump(struct coredump_params *cprm);
48644 #define elf_core_dump NULL
48645 #endif
48646
48647 +#ifdef CONFIG_PAX_MPROTECT
48648 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
48649 +#endif
48650 +
48651 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
48652 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
48653 #else
48654 @@ -78,6 +83,11 @@ static struct linux_binfmt elf_format = {
48655 .load_binary = load_elf_binary,
48656 .load_shlib = load_elf_library,
48657 .core_dump = elf_core_dump,
48658 +
48659 +#ifdef CONFIG_PAX_MPROTECT
48660 + .handle_mprotect= elf_handle_mprotect,
48661 +#endif
48662 +
48663 .min_coredump = ELF_EXEC_PAGESIZE,
48664 };
48665
48666 @@ -85,6 +95,8 @@ static struct linux_binfmt elf_format = {
48667
48668 static int set_brk(unsigned long start, unsigned long end)
48669 {
48670 + unsigned long e = end;
48671 +
48672 start = ELF_PAGEALIGN(start);
48673 end = ELF_PAGEALIGN(end);
48674 if (end > start) {
48675 @@ -93,7 +105,7 @@ static int set_brk(unsigned long start, unsigned long end)
48676 if (BAD_ADDR(addr))
48677 return addr;
48678 }
48679 - current->mm->start_brk = current->mm->brk = end;
48680 + current->mm->start_brk = current->mm->brk = e;
48681 return 0;
48682 }
48683
48684 @@ -154,12 +166,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48685 elf_addr_t __user *u_rand_bytes;
48686 const char *k_platform = ELF_PLATFORM;
48687 const char *k_base_platform = ELF_BASE_PLATFORM;
48688 - unsigned char k_rand_bytes[16];
48689 + u32 k_rand_bytes[4];
48690 int items;
48691 elf_addr_t *elf_info;
48692 int ei_index = 0;
48693 const struct cred *cred = current_cred();
48694 struct vm_area_struct *vma;
48695 + unsigned long saved_auxv[AT_VECTOR_SIZE];
48696
48697 /*
48698 * In some cases (e.g. Hyper-Threading), we want to avoid L1
48699 @@ -201,8 +214,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48700 * Generate 16 random bytes for userspace PRNG seeding.
48701 */
48702 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
48703 - u_rand_bytes = (elf_addr_t __user *)
48704 - STACK_ALLOC(p, sizeof(k_rand_bytes));
48705 + srandom32(k_rand_bytes[0] ^ random32());
48706 + srandom32(k_rand_bytes[1] ^ random32());
48707 + srandom32(k_rand_bytes[2] ^ random32());
48708 + srandom32(k_rand_bytes[3] ^ random32());
48709 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
48710 + u_rand_bytes = (elf_addr_t __user *) p;
48711 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
48712 return -EFAULT;
48713
48714 @@ -314,9 +331,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48715 return -EFAULT;
48716 current->mm->env_end = p;
48717
48718 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
48719 +
48720 /* Put the elf_info on the stack in the right place. */
48721 sp = (elf_addr_t __user *)envp + 1;
48722 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
48723 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
48724 return -EFAULT;
48725 return 0;
48726 }
48727 @@ -380,15 +399,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
48728 an ELF header */
48729
48730 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48731 - struct file *interpreter, unsigned long *interp_map_addr,
48732 - unsigned long no_base)
48733 + struct file *interpreter, unsigned long no_base)
48734 {
48735 struct elf_phdr *elf_phdata;
48736 struct elf_phdr *eppnt;
48737 - unsigned long load_addr = 0;
48738 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
48739 int load_addr_set = 0;
48740 unsigned long last_bss = 0, elf_bss = 0;
48741 - unsigned long error = ~0UL;
48742 + unsigned long error = -EINVAL;
48743 unsigned long total_size;
48744 int retval, i, size;
48745
48746 @@ -434,6 +452,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48747 goto out_close;
48748 }
48749
48750 +#ifdef CONFIG_PAX_SEGMEXEC
48751 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
48752 + pax_task_size = SEGMEXEC_TASK_SIZE;
48753 +#endif
48754 +
48755 eppnt = elf_phdata;
48756 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
48757 if (eppnt->p_type == PT_LOAD) {
48758 @@ -457,8 +480,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48759 map_addr = elf_map(interpreter, load_addr + vaddr,
48760 eppnt, elf_prot, elf_type, total_size);
48761 total_size = 0;
48762 - if (!*interp_map_addr)
48763 - *interp_map_addr = map_addr;
48764 error = map_addr;
48765 if (BAD_ADDR(map_addr))
48766 goto out_close;
48767 @@ -477,8 +498,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48768 k = load_addr + eppnt->p_vaddr;
48769 if (BAD_ADDR(k) ||
48770 eppnt->p_filesz > eppnt->p_memsz ||
48771 - eppnt->p_memsz > TASK_SIZE ||
48772 - TASK_SIZE - eppnt->p_memsz < k) {
48773 + eppnt->p_memsz > pax_task_size ||
48774 + pax_task_size - eppnt->p_memsz < k) {
48775 error = -ENOMEM;
48776 goto out_close;
48777 }
48778 @@ -530,6 +551,315 @@ out:
48779 return error;
48780 }
48781
48782 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48783 +#ifdef CONFIG_PAX_SOFTMODE
48784 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
48785 +{
48786 + unsigned long pax_flags = 0UL;
48787 +
48788 +#ifdef CONFIG_PAX_PAGEEXEC
48789 + if (elf_phdata->p_flags & PF_PAGEEXEC)
48790 + pax_flags |= MF_PAX_PAGEEXEC;
48791 +#endif
48792 +
48793 +#ifdef CONFIG_PAX_SEGMEXEC
48794 + if (elf_phdata->p_flags & PF_SEGMEXEC)
48795 + pax_flags |= MF_PAX_SEGMEXEC;
48796 +#endif
48797 +
48798 +#ifdef CONFIG_PAX_EMUTRAMP
48799 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48800 + pax_flags |= MF_PAX_EMUTRAMP;
48801 +#endif
48802 +
48803 +#ifdef CONFIG_PAX_MPROTECT
48804 + if (elf_phdata->p_flags & PF_MPROTECT)
48805 + pax_flags |= MF_PAX_MPROTECT;
48806 +#endif
48807 +
48808 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48809 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
48810 + pax_flags |= MF_PAX_RANDMMAP;
48811 +#endif
48812 +
48813 + return pax_flags;
48814 +}
48815 +#endif
48816 +
48817 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
48818 +{
48819 + unsigned long pax_flags = 0UL;
48820 +
48821 +#ifdef CONFIG_PAX_PAGEEXEC
48822 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
48823 + pax_flags |= MF_PAX_PAGEEXEC;
48824 +#endif
48825 +
48826 +#ifdef CONFIG_PAX_SEGMEXEC
48827 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
48828 + pax_flags |= MF_PAX_SEGMEXEC;
48829 +#endif
48830 +
48831 +#ifdef CONFIG_PAX_EMUTRAMP
48832 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
48833 + pax_flags |= MF_PAX_EMUTRAMP;
48834 +#endif
48835 +
48836 +#ifdef CONFIG_PAX_MPROTECT
48837 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
48838 + pax_flags |= MF_PAX_MPROTECT;
48839 +#endif
48840 +
48841 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48842 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
48843 + pax_flags |= MF_PAX_RANDMMAP;
48844 +#endif
48845 +
48846 + return pax_flags;
48847 +}
48848 +#endif
48849 +
48850 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48851 +#ifdef CONFIG_PAX_SOFTMODE
48852 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
48853 +{
48854 + unsigned long pax_flags = 0UL;
48855 +
48856 +#ifdef CONFIG_PAX_PAGEEXEC
48857 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
48858 + pax_flags |= MF_PAX_PAGEEXEC;
48859 +#endif
48860 +
48861 +#ifdef CONFIG_PAX_SEGMEXEC
48862 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
48863 + pax_flags |= MF_PAX_SEGMEXEC;
48864 +#endif
48865 +
48866 +#ifdef CONFIG_PAX_EMUTRAMP
48867 + if (pax_flags_softmode & MF_PAX_EMUTRAMP)
48868 + pax_flags |= MF_PAX_EMUTRAMP;
48869 +#endif
48870 +
48871 +#ifdef CONFIG_PAX_MPROTECT
48872 + if (pax_flags_softmode & MF_PAX_MPROTECT)
48873 + pax_flags |= MF_PAX_MPROTECT;
48874 +#endif
48875 +
48876 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48877 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
48878 + pax_flags |= MF_PAX_RANDMMAP;
48879 +#endif
48880 +
48881 + return pax_flags;
48882 +}
48883 +#endif
48884 +
48885 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
48886 +{
48887 + unsigned long pax_flags = 0UL;
48888 +
48889 +#ifdef CONFIG_PAX_PAGEEXEC
48890 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
48891 + pax_flags |= MF_PAX_PAGEEXEC;
48892 +#endif
48893 +
48894 +#ifdef CONFIG_PAX_SEGMEXEC
48895 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
48896 + pax_flags |= MF_PAX_SEGMEXEC;
48897 +#endif
48898 +
48899 +#ifdef CONFIG_PAX_EMUTRAMP
48900 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
48901 + pax_flags |= MF_PAX_EMUTRAMP;
48902 +#endif
48903 +
48904 +#ifdef CONFIG_PAX_MPROTECT
48905 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
48906 + pax_flags |= MF_PAX_MPROTECT;
48907 +#endif
48908 +
48909 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48910 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
48911 + pax_flags |= MF_PAX_RANDMMAP;
48912 +#endif
48913 +
48914 + return pax_flags;
48915 +}
48916 +#endif
48917 +
48918 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48919 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
48920 +{
48921 + unsigned long pax_flags = 0UL;
48922 +
48923 +#ifdef CONFIG_PAX_EI_PAX
48924 +
48925 +#ifdef CONFIG_PAX_PAGEEXEC
48926 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
48927 + pax_flags |= MF_PAX_PAGEEXEC;
48928 +#endif
48929 +
48930 +#ifdef CONFIG_PAX_SEGMEXEC
48931 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
48932 + pax_flags |= MF_PAX_SEGMEXEC;
48933 +#endif
48934 +
48935 +#ifdef CONFIG_PAX_EMUTRAMP
48936 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
48937 + pax_flags |= MF_PAX_EMUTRAMP;
48938 +#endif
48939 +
48940 +#ifdef CONFIG_PAX_MPROTECT
48941 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
48942 + pax_flags |= MF_PAX_MPROTECT;
48943 +#endif
48944 +
48945 +#ifdef CONFIG_PAX_ASLR
48946 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
48947 + pax_flags |= MF_PAX_RANDMMAP;
48948 +#endif
48949 +
48950 +#else
48951 +
48952 +#ifdef CONFIG_PAX_PAGEEXEC
48953 + pax_flags |= MF_PAX_PAGEEXEC;
48954 +#endif
48955 +
48956 +#ifdef CONFIG_PAX_SEGMEXEC
48957 + pax_flags |= MF_PAX_SEGMEXEC;
48958 +#endif
48959 +
48960 +#ifdef CONFIG_PAX_MPROTECT
48961 + pax_flags |= MF_PAX_MPROTECT;
48962 +#endif
48963 +
48964 +#ifdef CONFIG_PAX_RANDMMAP
48965 + if (randomize_va_space)
48966 + pax_flags |= MF_PAX_RANDMMAP;
48967 +#endif
48968 +
48969 +#endif
48970 +
48971 + return pax_flags;
48972 +}
48973 +
48974 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
48975 +{
48976 +
48977 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48978 + unsigned long i;
48979 +
48980 + for (i = 0UL; i < elf_ex->e_phnum; i++)
48981 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
48982 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
48983 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
48984 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
48985 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
48986 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
48987 + return ~0UL;
48988 +
48989 +#ifdef CONFIG_PAX_SOFTMODE
48990 + if (pax_softmode)
48991 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
48992 + else
48993 +#endif
48994 +
48995 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
48996 + break;
48997 + }
48998 +#endif
48999 +
49000 + return ~0UL;
49001 +}
49002 +
49003 +static unsigned long pax_parse_xattr_pax(struct file * const file)
49004 +{
49005 +
49006 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
49007 + ssize_t xattr_size, i;
49008 + unsigned char xattr_value[5];
49009 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
49010 +
49011 + xattr_size = vfs_getxattr(file->f_path.dentry, XATTR_NAME_PAX_FLAGS, xattr_value, sizeof xattr_value);
49012 + if (xattr_size <= 0 || xattr_size > 5)
49013 + return ~0UL;
49014 +
49015 + for (i = 0; i < xattr_size; i++)
49016 + switch (xattr_value[i]) {
49017 + default:
49018 + return ~0UL;
49019 +
49020 +#define parse_flag(option1, option2, flag) \
49021 + case option1: \
49022 + if (pax_flags_hardmode & MF_PAX_##flag) \
49023 + return ~0UL; \
49024 + pax_flags_hardmode |= MF_PAX_##flag; \
49025 + break; \
49026 + case option2: \
49027 + if (pax_flags_softmode & MF_PAX_##flag) \
49028 + return ~0UL; \
49029 + pax_flags_softmode |= MF_PAX_##flag; \
49030 + break;
49031 +
49032 + parse_flag('p', 'P', PAGEEXEC);
49033 + parse_flag('e', 'E', EMUTRAMP);
49034 + parse_flag('m', 'M', MPROTECT);
49035 + parse_flag('r', 'R', RANDMMAP);
49036 + parse_flag('s', 'S', SEGMEXEC);
49037 +
49038 +#undef parse_flag
49039 + }
49040 +
49041 + if (pax_flags_hardmode & pax_flags_softmode)
49042 + return ~0UL;
49043 +
49044 +#ifdef CONFIG_PAX_SOFTMODE
49045 + if (pax_softmode)
49046 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
49047 + else
49048 +#endif
49049 +
49050 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
49051 +#else
49052 + return ~0UL;
49053 +#endif
49054 +
49055 +}
49056 +
49057 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
49058 +{
49059 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
49060 +
49061 + pax_flags = pax_parse_ei_pax(elf_ex);
49062 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
49063 + xattr_pax_flags = pax_parse_xattr_pax(file);
49064 +
49065 + if (pt_pax_flags == ~0UL)
49066 + pt_pax_flags = xattr_pax_flags;
49067 + else if (xattr_pax_flags == ~0UL)
49068 + xattr_pax_flags = pt_pax_flags;
49069 + if (pt_pax_flags != xattr_pax_flags)
49070 + return -EINVAL;
49071 + if (pt_pax_flags != ~0UL)
49072 + pax_flags = pt_pax_flags;
49073 +
49074 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
49075 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49076 + if ((__supported_pte_mask & _PAGE_NX))
49077 + pax_flags &= ~MF_PAX_SEGMEXEC;
49078 + else
49079 + pax_flags &= ~MF_PAX_PAGEEXEC;
49080 + }
49081 +#endif
49082 +
49083 + if (0 > pax_check_flags(&pax_flags))
49084 + return -EINVAL;
49085 +
49086 + current->mm->pax_flags = pax_flags;
49087 + return 0;
49088 +}
49089 +#endif
49090 +
49091 /*
49092 * These are the functions used to load ELF style executables and shared
49093 * libraries. There is no binary dependent code anywhere else.
49094 @@ -546,6 +876,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
49095 {
49096 unsigned int random_variable = 0;
49097
49098 +#ifdef CONFIG_PAX_RANDUSTACK
49099 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
49100 + return stack_top - current->mm->delta_stack;
49101 +#endif
49102 +
49103 if ((current->flags & PF_RANDOMIZE) &&
49104 !(current->personality & ADDR_NO_RANDOMIZE)) {
49105 random_variable = get_random_int() & STACK_RND_MASK;
49106 @@ -564,7 +899,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
49107 unsigned long load_addr = 0, load_bias = 0;
49108 int load_addr_set = 0;
49109 char * elf_interpreter = NULL;
49110 - unsigned long error;
49111 + unsigned long error = 0;
49112 struct elf_phdr *elf_ppnt, *elf_phdata;
49113 unsigned long elf_bss, elf_brk;
49114 int retval, i;
49115 @@ -574,12 +909,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
49116 unsigned long start_code, end_code, start_data, end_data;
49117 unsigned long reloc_func_desc __maybe_unused = 0;
49118 int executable_stack = EXSTACK_DEFAULT;
49119 - unsigned long def_flags = 0;
49120 struct pt_regs *regs = current_pt_regs();
49121 struct {
49122 struct elfhdr elf_ex;
49123 struct elfhdr interp_elf_ex;
49124 } *loc;
49125 + unsigned long pax_task_size = TASK_SIZE;
49126
49127 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
49128 if (!loc) {
49129 @@ -715,11 +1050,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
49130 goto out_free_dentry;
49131
49132 /* OK, This is the point of no return */
49133 - current->mm->def_flags = def_flags;
49134 +
49135 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49136 + current->mm->pax_flags = 0UL;
49137 +#endif
49138 +
49139 +#ifdef CONFIG_PAX_DLRESOLVE
49140 + current->mm->call_dl_resolve = 0UL;
49141 +#endif
49142 +
49143 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
49144 + current->mm->call_syscall = 0UL;
49145 +#endif
49146 +
49147 +#ifdef CONFIG_PAX_ASLR
49148 + current->mm->delta_mmap = 0UL;
49149 + current->mm->delta_stack = 0UL;
49150 +#endif
49151 +
49152 + current->mm->def_flags = 0;
49153 +
49154 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49155 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
49156 + send_sig(SIGKILL, current, 0);
49157 + goto out_free_dentry;
49158 + }
49159 +#endif
49160 +
49161 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
49162 + pax_set_initial_flags(bprm);
49163 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
49164 + if (pax_set_initial_flags_func)
49165 + (pax_set_initial_flags_func)(bprm);
49166 +#endif
49167 +
49168 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
49169 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
49170 + current->mm->context.user_cs_limit = PAGE_SIZE;
49171 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
49172 + }
49173 +#endif
49174 +
49175 +#ifdef CONFIG_PAX_SEGMEXEC
49176 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
49177 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
49178 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
49179 + pax_task_size = SEGMEXEC_TASK_SIZE;
49180 + current->mm->def_flags |= VM_NOHUGEPAGE;
49181 + }
49182 +#endif
49183 +
49184 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
49185 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49186 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
49187 + put_cpu();
49188 + }
49189 +#endif
49190
49191 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
49192 may depend on the personality. */
49193 SET_PERSONALITY(loc->elf_ex);
49194 +
49195 +#ifdef CONFIG_PAX_ASLR
49196 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49197 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
49198 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
49199 + }
49200 +#endif
49201 +
49202 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
49203 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49204 + executable_stack = EXSTACK_DISABLE_X;
49205 + current->personality &= ~READ_IMPLIES_EXEC;
49206 + } else
49207 +#endif
49208 +
49209 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
49210 current->personality |= READ_IMPLIES_EXEC;
49211
49212 @@ -810,6 +1215,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
49213 #else
49214 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
49215 #endif
49216 +
49217 +#ifdef CONFIG_PAX_RANDMMAP
49218 + /* PaX: randomize base address at the default exe base if requested */
49219 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
49220 +#ifdef CONFIG_SPARC64
49221 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
49222 +#else
49223 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
49224 +#endif
49225 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
49226 + elf_flags |= MAP_FIXED;
49227 + }
49228 +#endif
49229 +
49230 }
49231
49232 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
49233 @@ -842,9 +1261,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
49234 * allowed task size. Note that p_filesz must always be
49235 * <= p_memsz so it is only necessary to check p_memsz.
49236 */
49237 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49238 - elf_ppnt->p_memsz > TASK_SIZE ||
49239 - TASK_SIZE - elf_ppnt->p_memsz < k) {
49240 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49241 + elf_ppnt->p_memsz > pax_task_size ||
49242 + pax_task_size - elf_ppnt->p_memsz < k) {
49243 /* set_brk can never work. Avoid overflows. */
49244 send_sig(SIGKILL, current, 0);
49245 retval = -EINVAL;
49246 @@ -883,17 +1302,44 @@ static int load_elf_binary(struct linux_binprm *bprm)
49247 goto out_free_dentry;
49248 }
49249 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
49250 - send_sig(SIGSEGV, current, 0);
49251 - retval = -EFAULT; /* Nobody gets to see this, but.. */
49252 - goto out_free_dentry;
49253 + /*
49254 + * This bss-zeroing can fail if the ELF
49255 + * file specifies odd protections. So
49256 + * we don't check the return value
49257 + */
49258 }
49259
49260 +#ifdef CONFIG_PAX_RANDMMAP
49261 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49262 + unsigned long start, size, flags, vm_flags;
49263 +
49264 + start = ELF_PAGEALIGN(elf_brk);
49265 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
49266 + flags = MAP_FIXED | MAP_PRIVATE;
49267 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
49268 +
49269 + down_write(&current->mm->mmap_sem);
49270 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
49271 + retval = -ENOMEM;
49272 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
49273 +// if (current->personality & ADDR_NO_RANDOMIZE)
49274 +// vm_flags |= VM_READ | VM_MAYREAD;
49275 + start = mmap_region(NULL, start, PAGE_ALIGN(size), flags, vm_flags, 0);
49276 + retval = IS_ERR_VALUE(start) ? start : 0;
49277 + }
49278 + up_write(&current->mm->mmap_sem);
49279 + if (retval == 0)
49280 + retval = set_brk(start + size, start + size + PAGE_SIZE);
49281 + if (retval < 0) {
49282 + send_sig(SIGKILL, current, 0);
49283 + goto out_free_dentry;
49284 + }
49285 + }
49286 +#endif
49287 +
49288 if (elf_interpreter) {
49289 - unsigned long interp_map_addr = 0;
49290 -
49291 elf_entry = load_elf_interp(&loc->interp_elf_ex,
49292 interpreter,
49293 - &interp_map_addr,
49294 load_bias);
49295 if (!IS_ERR((void *)elf_entry)) {
49296 /*
49297 @@ -1115,7 +1561,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
49298 * Decide what to dump of a segment, part, all or none.
49299 */
49300 static unsigned long vma_dump_size(struct vm_area_struct *vma,
49301 - unsigned long mm_flags)
49302 + unsigned long mm_flags, long signr)
49303 {
49304 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
49305
49306 @@ -1152,7 +1598,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
49307 if (vma->vm_file == NULL)
49308 return 0;
49309
49310 - if (FILTER(MAPPED_PRIVATE))
49311 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
49312 goto whole;
49313
49314 /*
49315 @@ -1374,9 +1820,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
49316 {
49317 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
49318 int i = 0;
49319 - do
49320 + do {
49321 i += 2;
49322 - while (auxv[i - 2] != AT_NULL);
49323 + } while (auxv[i - 2] != AT_NULL);
49324 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
49325 }
49326
49327 @@ -2006,14 +2452,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
49328 }
49329
49330 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
49331 - unsigned long mm_flags)
49332 + struct coredump_params *cprm)
49333 {
49334 struct vm_area_struct *vma;
49335 size_t size = 0;
49336
49337 for (vma = first_vma(current, gate_vma); vma != NULL;
49338 vma = next_vma(vma, gate_vma))
49339 - size += vma_dump_size(vma, mm_flags);
49340 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49341 return size;
49342 }
49343
49344 @@ -2107,7 +2553,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49345
49346 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
49347
49348 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
49349 + offset += elf_core_vma_data_size(gate_vma, cprm);
49350 offset += elf_core_extra_data_size();
49351 e_shoff = offset;
49352
49353 @@ -2121,10 +2567,12 @@ static int elf_core_dump(struct coredump_params *cprm)
49354 offset = dataoff;
49355
49356 size += sizeof(*elf);
49357 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49358 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
49359 goto end_coredump;
49360
49361 size += sizeof(*phdr4note);
49362 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49363 if (size > cprm->limit
49364 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
49365 goto end_coredump;
49366 @@ -2138,7 +2586,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49367 phdr.p_offset = offset;
49368 phdr.p_vaddr = vma->vm_start;
49369 phdr.p_paddr = 0;
49370 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
49371 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49372 phdr.p_memsz = vma->vm_end - vma->vm_start;
49373 offset += phdr.p_filesz;
49374 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
49375 @@ -2149,6 +2597,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49376 phdr.p_align = ELF_EXEC_PAGESIZE;
49377
49378 size += sizeof(phdr);
49379 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49380 if (size > cprm->limit
49381 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
49382 goto end_coredump;
49383 @@ -2173,7 +2622,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49384 unsigned long addr;
49385 unsigned long end;
49386
49387 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
49388 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49389
49390 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
49391 struct page *page;
49392 @@ -2182,6 +2631,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49393 page = get_dump_page(addr);
49394 if (page) {
49395 void *kaddr = kmap(page);
49396 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
49397 stop = ((size += PAGE_SIZE) > cprm->limit) ||
49398 !dump_write(cprm->file, kaddr,
49399 PAGE_SIZE);
49400 @@ -2199,6 +2649,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49401
49402 if (e_phnum == PN_XNUM) {
49403 size += sizeof(*shdr4extnum);
49404 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49405 if (size > cprm->limit
49406 || !dump_write(cprm->file, shdr4extnum,
49407 sizeof(*shdr4extnum)))
49408 @@ -2219,6 +2670,97 @@ out:
49409
49410 #endif /* CONFIG_ELF_CORE */
49411
49412 +#ifdef CONFIG_PAX_MPROTECT
49413 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
49414 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
49415 + * we'll remove VM_MAYWRITE for good on RELRO segments.
49416 + *
49417 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
49418 + * basis because we want to allow the common case and not the special ones.
49419 + */
49420 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
49421 +{
49422 + struct elfhdr elf_h;
49423 + struct elf_phdr elf_p;
49424 + unsigned long i;
49425 + unsigned long oldflags;
49426 + bool is_textrel_rw, is_textrel_rx, is_relro;
49427 +
49428 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
49429 + return;
49430 +
49431 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
49432 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
49433 +
49434 +#ifdef CONFIG_PAX_ELFRELOCS
49435 + /* possible TEXTREL */
49436 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
49437 + 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);
49438 +#else
49439 + is_textrel_rw = false;
49440 + is_textrel_rx = false;
49441 +#endif
49442 +
49443 + /* possible RELRO */
49444 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
49445 +
49446 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
49447 + return;
49448 +
49449 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
49450 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
49451 +
49452 +#ifdef CONFIG_PAX_ETEXECRELOCS
49453 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49454 +#else
49455 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
49456 +#endif
49457 +
49458 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49459 + !elf_check_arch(&elf_h) ||
49460 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
49461 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
49462 + return;
49463 +
49464 + for (i = 0UL; i < elf_h.e_phnum; i++) {
49465 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
49466 + return;
49467 + switch (elf_p.p_type) {
49468 + case PT_DYNAMIC:
49469 + if (!is_textrel_rw && !is_textrel_rx)
49470 + continue;
49471 + i = 0UL;
49472 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
49473 + elf_dyn dyn;
49474 +
49475 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
49476 + return;
49477 + if (dyn.d_tag == DT_NULL)
49478 + return;
49479 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
49480 + gr_log_textrel(vma);
49481 + if (is_textrel_rw)
49482 + vma->vm_flags |= VM_MAYWRITE;
49483 + else
49484 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
49485 + vma->vm_flags &= ~VM_MAYWRITE;
49486 + return;
49487 + }
49488 + i++;
49489 + }
49490 + return;
49491 +
49492 + case PT_GNU_RELRO:
49493 + if (!is_relro)
49494 + continue;
49495 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
49496 + vma->vm_flags &= ~VM_MAYWRITE;
49497 + return;
49498 + }
49499 + }
49500 +}
49501 +#endif
49502 +
49503 static int __init init_elf_binfmt(void)
49504 {
49505 register_binfmt(&elf_format);
49506 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
49507 index b563719..3868998 100644
49508 --- a/fs/binfmt_flat.c
49509 +++ b/fs/binfmt_flat.c
49510 @@ -562,7 +562,9 @@ static int load_flat_file(struct linux_binprm * bprm,
49511 realdatastart = (unsigned long) -ENOMEM;
49512 printk("Unable to allocate RAM for process data, errno %d\n",
49513 (int)-realdatastart);
49514 + down_write(&current->mm->mmap_sem);
49515 vm_munmap(textpos, text_len);
49516 + up_write(&current->mm->mmap_sem);
49517 ret = realdatastart;
49518 goto err;
49519 }
49520 @@ -586,8 +588,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49521 }
49522 if (IS_ERR_VALUE(result)) {
49523 printk("Unable to read data+bss, errno %d\n", (int)-result);
49524 + down_write(&current->mm->mmap_sem);
49525 vm_munmap(textpos, text_len);
49526 vm_munmap(realdatastart, len);
49527 + up_write(&current->mm->mmap_sem);
49528 ret = result;
49529 goto err;
49530 }
49531 @@ -654,8 +658,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49532 }
49533 if (IS_ERR_VALUE(result)) {
49534 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
49535 + down_write(&current->mm->mmap_sem);
49536 vm_munmap(textpos, text_len + data_len + extra +
49537 MAX_SHARED_LIBS * sizeof(unsigned long));
49538 + up_write(&current->mm->mmap_sem);
49539 ret = result;
49540 goto err;
49541 }
49542 diff --git a/fs/bio.c b/fs/bio.c
49543 index b96fc6c..431d628 100644
49544 --- a/fs/bio.c
49545 +++ b/fs/bio.c
49546 @@ -818,7 +818,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
49547 /*
49548 * Overflow, abort
49549 */
49550 - if (end < start)
49551 + if (end < start || end - start > INT_MAX - nr_pages)
49552 return ERR_PTR(-EINVAL);
49553
49554 nr_pages += end - start;
49555 @@ -952,7 +952,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
49556 /*
49557 * Overflow, abort
49558 */
49559 - if (end < start)
49560 + if (end < start || end - start > INT_MAX - nr_pages)
49561 return ERR_PTR(-EINVAL);
49562
49563 nr_pages += end - start;
49564 @@ -1214,7 +1214,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
49565 const int read = bio_data_dir(bio) == READ;
49566 struct bio_map_data *bmd = bio->bi_private;
49567 int i;
49568 - char *p = bmd->sgvecs[0].iov_base;
49569 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
49570
49571 __bio_for_each_segment(bvec, bio, i, 0) {
49572 char *addr = page_address(bvec->bv_page);
49573 diff --git a/fs/block_dev.c b/fs/block_dev.c
49574 index 883dc49..f27794a 100644
49575 --- a/fs/block_dev.c
49576 +++ b/fs/block_dev.c
49577 @@ -652,7 +652,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
49578 else if (bdev->bd_contains == bdev)
49579 return true; /* is a whole device which isn't held */
49580
49581 - else if (whole->bd_holder == bd_may_claim)
49582 + else if (whole->bd_holder == (void *)bd_may_claim)
49583 return true; /* is a partition of a device that is being partitioned */
49584 else if (whole->bd_holder != NULL)
49585 return false; /* is a partition of a held device */
49586 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
49587 index ce1c169..1ef484f 100644
49588 --- a/fs/btrfs/ctree.c
49589 +++ b/fs/btrfs/ctree.c
49590 @@ -1036,9 +1036,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
49591 free_extent_buffer(buf);
49592 add_root_to_dirty_list(root);
49593 } else {
49594 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
49595 - parent_start = parent->start;
49596 - else
49597 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
49598 + if (parent)
49599 + parent_start = parent->start;
49600 + else
49601 + parent_start = 0;
49602 + } else
49603 parent_start = 0;
49604
49605 WARN_ON(trans->transid != btrfs_header_generation(parent));
49606 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
49607 index 7c4e6cc..27bd5c2 100644
49608 --- a/fs/btrfs/inode.c
49609 +++ b/fs/btrfs/inode.c
49610 @@ -7314,7 +7314,7 @@ fail:
49611 return -ENOMEM;
49612 }
49613
49614 -static int btrfs_getattr(struct vfsmount *mnt,
49615 +int btrfs_getattr(struct vfsmount *mnt,
49616 struct dentry *dentry, struct kstat *stat)
49617 {
49618 struct inode *inode = dentry->d_inode;
49619 @@ -7328,6 +7328,14 @@ static int btrfs_getattr(struct vfsmount *mnt,
49620 return 0;
49621 }
49622
49623 +EXPORT_SYMBOL(btrfs_getattr);
49624 +
49625 +dev_t get_btrfs_dev_from_inode(struct inode *inode)
49626 +{
49627 + return BTRFS_I(inode)->root->anon_dev;
49628 +}
49629 +EXPORT_SYMBOL(get_btrfs_dev_from_inode);
49630 +
49631 /*
49632 * If a file is moved, it will inherit the cow and compression flags of the new
49633 * directory.
49634 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
49635 index 338f259..b657640 100644
49636 --- a/fs/btrfs/ioctl.c
49637 +++ b/fs/btrfs/ioctl.c
49638 @@ -3033,9 +3033,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49639 for (i = 0; i < num_types; i++) {
49640 struct btrfs_space_info *tmp;
49641
49642 + /* Don't copy in more than we allocated */
49643 if (!slot_count)
49644 break;
49645
49646 + slot_count--;
49647 +
49648 info = NULL;
49649 rcu_read_lock();
49650 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
49651 @@ -3057,10 +3060,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49652 memcpy(dest, &space, sizeof(space));
49653 dest++;
49654 space_args.total_spaces++;
49655 - slot_count--;
49656 }
49657 - if (!slot_count)
49658 - break;
49659 }
49660 up_read(&info->groups_sem);
49661 }
49662 diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
49663 index 300e09a..9fe4539 100644
49664 --- a/fs/btrfs/relocation.c
49665 +++ b/fs/btrfs/relocation.c
49666 @@ -1269,7 +1269,7 @@ static int __update_reloc_root(struct btrfs_root *root, int del)
49667 }
49668 spin_unlock(&rc->reloc_root_tree.lock);
49669
49670 - BUG_ON((struct btrfs_root *)node->data != root);
49671 + BUG_ON(!node || (struct btrfs_root *)node->data != root);
49672
49673 if (!del) {
49674 spin_lock(&rc->reloc_root_tree.lock);
49675 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
49676 index d8982e9..29a85fa 100644
49677 --- a/fs/btrfs/super.c
49678 +++ b/fs/btrfs/super.c
49679 @@ -267,7 +267,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
49680 function, line, errstr);
49681 return;
49682 }
49683 - ACCESS_ONCE(trans->transaction->aborted) = errno;
49684 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
49685 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
49686 }
49687 /*
49688 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
49689 index 622f469..e8d2d55 100644
49690 --- a/fs/cachefiles/bind.c
49691 +++ b/fs/cachefiles/bind.c
49692 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
49693 args);
49694
49695 /* start by checking things over */
49696 - ASSERT(cache->fstop_percent >= 0 &&
49697 - cache->fstop_percent < cache->fcull_percent &&
49698 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
49699 cache->fcull_percent < cache->frun_percent &&
49700 cache->frun_percent < 100);
49701
49702 - ASSERT(cache->bstop_percent >= 0 &&
49703 - cache->bstop_percent < cache->bcull_percent &&
49704 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
49705 cache->bcull_percent < cache->brun_percent &&
49706 cache->brun_percent < 100);
49707
49708 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
49709 index 0a1467b..6a53245 100644
49710 --- a/fs/cachefiles/daemon.c
49711 +++ b/fs/cachefiles/daemon.c
49712 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
49713 if (n > buflen)
49714 return -EMSGSIZE;
49715
49716 - if (copy_to_user(_buffer, buffer, n) != 0)
49717 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
49718 return -EFAULT;
49719
49720 return n;
49721 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
49722 if (test_bit(CACHEFILES_DEAD, &cache->flags))
49723 return -EIO;
49724
49725 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
49726 + if (datalen > PAGE_SIZE - 1)
49727 return -EOPNOTSUPP;
49728
49729 /* drag the command string into the kernel so we can parse it */
49730 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
49731 if (args[0] != '%' || args[1] != '\0')
49732 return -EINVAL;
49733
49734 - if (fstop < 0 || fstop >= cache->fcull_percent)
49735 + if (fstop >= cache->fcull_percent)
49736 return cachefiles_daemon_range_error(cache, args);
49737
49738 cache->fstop_percent = fstop;
49739 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
49740 if (args[0] != '%' || args[1] != '\0')
49741 return -EINVAL;
49742
49743 - if (bstop < 0 || bstop >= cache->bcull_percent)
49744 + if (bstop >= cache->bcull_percent)
49745 return cachefiles_daemon_range_error(cache, args);
49746
49747 cache->bstop_percent = bstop;
49748 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
49749 index 4938251..7e01445 100644
49750 --- a/fs/cachefiles/internal.h
49751 +++ b/fs/cachefiles/internal.h
49752 @@ -59,7 +59,7 @@ struct cachefiles_cache {
49753 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
49754 struct rb_root active_nodes; /* active nodes (can't be culled) */
49755 rwlock_t active_lock; /* lock for active_nodes */
49756 - atomic_t gravecounter; /* graveyard uniquifier */
49757 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
49758 unsigned frun_percent; /* when to stop culling (% files) */
49759 unsigned fcull_percent; /* when to start culling (% files) */
49760 unsigned fstop_percent; /* when to stop allocating (% files) */
49761 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
49762 * proc.c
49763 */
49764 #ifdef CONFIG_CACHEFILES_HISTOGRAM
49765 -extern atomic_t cachefiles_lookup_histogram[HZ];
49766 -extern atomic_t cachefiles_mkdir_histogram[HZ];
49767 -extern atomic_t cachefiles_create_histogram[HZ];
49768 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49769 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49770 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
49771
49772 extern int __init cachefiles_proc_init(void);
49773 extern void cachefiles_proc_cleanup(void);
49774 static inline
49775 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
49776 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
49777 {
49778 unsigned long jif = jiffies - start_jif;
49779 if (jif >= HZ)
49780 jif = HZ - 1;
49781 - atomic_inc(&histogram[jif]);
49782 + atomic_inc_unchecked(&histogram[jif]);
49783 }
49784
49785 #else
49786 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
49787 index 8c01c5fc..15f982e 100644
49788 --- a/fs/cachefiles/namei.c
49789 +++ b/fs/cachefiles/namei.c
49790 @@ -317,7 +317,7 @@ try_again:
49791 /* first step is to make up a grave dentry in the graveyard */
49792 sprintf(nbuffer, "%08x%08x",
49793 (uint32_t) get_seconds(),
49794 - (uint32_t) atomic_inc_return(&cache->gravecounter));
49795 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
49796
49797 /* do the multiway lock magic */
49798 trap = lock_rename(cache->graveyard, dir);
49799 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
49800 index eccd339..4c1d995 100644
49801 --- a/fs/cachefiles/proc.c
49802 +++ b/fs/cachefiles/proc.c
49803 @@ -14,9 +14,9 @@
49804 #include <linux/seq_file.h>
49805 #include "internal.h"
49806
49807 -atomic_t cachefiles_lookup_histogram[HZ];
49808 -atomic_t cachefiles_mkdir_histogram[HZ];
49809 -atomic_t cachefiles_create_histogram[HZ];
49810 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49811 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49812 +atomic_unchecked_t cachefiles_create_histogram[HZ];
49813
49814 /*
49815 * display the latency histogram
49816 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
49817 return 0;
49818 default:
49819 index = (unsigned long) v - 3;
49820 - x = atomic_read(&cachefiles_lookup_histogram[index]);
49821 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
49822 - z = atomic_read(&cachefiles_create_histogram[index]);
49823 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
49824 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
49825 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
49826 if (x == 0 && y == 0 && z == 0)
49827 return 0;
49828
49829 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
49830 index 4809922..aab2c39 100644
49831 --- a/fs/cachefiles/rdwr.c
49832 +++ b/fs/cachefiles/rdwr.c
49833 @@ -965,7 +965,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
49834 old_fs = get_fs();
49835 set_fs(KERNEL_DS);
49836 ret = file->f_op->write(
49837 - file, (const void __user *) data, len, &pos);
49838 + file, (const void __force_user *) data, len, &pos);
49839 set_fs(old_fs);
49840 kunmap(page);
49841 if (ret != len)
49842 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
49843 index 8c1aabe..bbf856a 100644
49844 --- a/fs/ceph/dir.c
49845 +++ b/fs/ceph/dir.c
49846 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
49847 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
49848 struct ceph_mds_client *mdsc = fsc->mdsc;
49849 unsigned frag = fpos_frag(filp->f_pos);
49850 - int off = fpos_off(filp->f_pos);
49851 + unsigned int off = fpos_off(filp->f_pos);
49852 int err;
49853 u32 ftype;
49854 struct ceph_mds_reply_info_parsed *rinfo;
49855 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
49856 index d9ea6ed..1e6c8ac 100644
49857 --- a/fs/cifs/cifs_debug.c
49858 +++ b/fs/cifs/cifs_debug.c
49859 @@ -267,8 +267,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49860
49861 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
49862 #ifdef CONFIG_CIFS_STATS2
49863 - atomic_set(&totBufAllocCount, 0);
49864 - atomic_set(&totSmBufAllocCount, 0);
49865 + atomic_set_unchecked(&totBufAllocCount, 0);
49866 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49867 #endif /* CONFIG_CIFS_STATS2 */
49868 spin_lock(&cifs_tcp_ses_lock);
49869 list_for_each(tmp1, &cifs_tcp_ses_list) {
49870 @@ -281,7 +281,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49871 tcon = list_entry(tmp3,
49872 struct cifs_tcon,
49873 tcon_list);
49874 - atomic_set(&tcon->num_smbs_sent, 0);
49875 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
49876 if (server->ops->clear_stats)
49877 server->ops->clear_stats(tcon);
49878 }
49879 @@ -313,8 +313,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49880 smBufAllocCount.counter, cifs_min_small);
49881 #ifdef CONFIG_CIFS_STATS2
49882 seq_printf(m, "Total Large %d Small %d Allocations\n",
49883 - atomic_read(&totBufAllocCount),
49884 - atomic_read(&totSmBufAllocCount));
49885 + atomic_read_unchecked(&totBufAllocCount),
49886 + atomic_read_unchecked(&totSmBufAllocCount));
49887 #endif /* CONFIG_CIFS_STATS2 */
49888
49889 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
49890 @@ -343,7 +343,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49891 if (tcon->need_reconnect)
49892 seq_puts(m, "\tDISCONNECTED ");
49893 seq_printf(m, "\nSMBs: %d",
49894 - atomic_read(&tcon->num_smbs_sent));
49895 + atomic_read_unchecked(&tcon->num_smbs_sent));
49896 if (server->ops->print_stats)
49897 server->ops->print_stats(m, tcon);
49898 }
49899 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
49900 index b9db388..9a73d6d 100644
49901 --- a/fs/cifs/cifsfs.c
49902 +++ b/fs/cifs/cifsfs.c
49903 @@ -1026,7 +1026,7 @@ cifs_init_request_bufs(void)
49904 /* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */
49905 cifs_req_cachep = kmem_cache_create("cifs_request",
49906 CIFSMaxBufSize + max_hdr_size, 0,
49907 - SLAB_HWCACHE_ALIGN, NULL);
49908 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
49909 if (cifs_req_cachep == NULL)
49910 return -ENOMEM;
49911
49912 @@ -1053,7 +1053,7 @@ cifs_init_request_bufs(void)
49913 efficient to alloc 1 per page off the slab compared to 17K (5page)
49914 alloc of large cifs buffers even when page debugging is on */
49915 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
49916 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
49917 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
49918 NULL);
49919 if (cifs_sm_req_cachep == NULL) {
49920 mempool_destroy(cifs_req_poolp);
49921 @@ -1138,8 +1138,8 @@ init_cifs(void)
49922 atomic_set(&bufAllocCount, 0);
49923 atomic_set(&smBufAllocCount, 0);
49924 #ifdef CONFIG_CIFS_STATS2
49925 - atomic_set(&totBufAllocCount, 0);
49926 - atomic_set(&totSmBufAllocCount, 0);
49927 + atomic_set_unchecked(&totBufAllocCount, 0);
49928 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49929 #endif /* CONFIG_CIFS_STATS2 */
49930
49931 atomic_set(&midCount, 0);
49932 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
49933 index e6899ce..d6b2920 100644
49934 --- a/fs/cifs/cifsglob.h
49935 +++ b/fs/cifs/cifsglob.h
49936 @@ -751,35 +751,35 @@ struct cifs_tcon {
49937 __u16 Flags; /* optional support bits */
49938 enum statusEnum tidStatus;
49939 #ifdef CONFIG_CIFS_STATS
49940 - atomic_t num_smbs_sent;
49941 + atomic_unchecked_t num_smbs_sent;
49942 union {
49943 struct {
49944 - atomic_t num_writes;
49945 - atomic_t num_reads;
49946 - atomic_t num_flushes;
49947 - atomic_t num_oplock_brks;
49948 - atomic_t num_opens;
49949 - atomic_t num_closes;
49950 - atomic_t num_deletes;
49951 - atomic_t num_mkdirs;
49952 - atomic_t num_posixopens;
49953 - atomic_t num_posixmkdirs;
49954 - atomic_t num_rmdirs;
49955 - atomic_t num_renames;
49956 - atomic_t num_t2renames;
49957 - atomic_t num_ffirst;
49958 - atomic_t num_fnext;
49959 - atomic_t num_fclose;
49960 - atomic_t num_hardlinks;
49961 - atomic_t num_symlinks;
49962 - atomic_t num_locks;
49963 - atomic_t num_acl_get;
49964 - atomic_t num_acl_set;
49965 + atomic_unchecked_t num_writes;
49966 + atomic_unchecked_t num_reads;
49967 + atomic_unchecked_t num_flushes;
49968 + atomic_unchecked_t num_oplock_brks;
49969 + atomic_unchecked_t num_opens;
49970 + atomic_unchecked_t num_closes;
49971 + atomic_unchecked_t num_deletes;
49972 + atomic_unchecked_t num_mkdirs;
49973 + atomic_unchecked_t num_posixopens;
49974 + atomic_unchecked_t num_posixmkdirs;
49975 + atomic_unchecked_t num_rmdirs;
49976 + atomic_unchecked_t num_renames;
49977 + atomic_unchecked_t num_t2renames;
49978 + atomic_unchecked_t num_ffirst;
49979 + atomic_unchecked_t num_fnext;
49980 + atomic_unchecked_t num_fclose;
49981 + atomic_unchecked_t num_hardlinks;
49982 + atomic_unchecked_t num_symlinks;
49983 + atomic_unchecked_t num_locks;
49984 + atomic_unchecked_t num_acl_get;
49985 + atomic_unchecked_t num_acl_set;
49986 } cifs_stats;
49987 #ifdef CONFIG_CIFS_SMB2
49988 struct {
49989 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49990 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49991 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49992 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49993 } smb2_stats;
49994 #endif /* CONFIG_CIFS_SMB2 */
49995 } stats;
49996 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
49997 }
49998
49999 #ifdef CONFIG_CIFS_STATS
50000 -#define cifs_stats_inc atomic_inc
50001 +#define cifs_stats_inc atomic_inc_unchecked
50002
50003 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
50004 unsigned int bytes)
50005 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
50006 /* Various Debug counters */
50007 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
50008 #ifdef CONFIG_CIFS_STATS2
50009 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
50010 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
50011 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
50012 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
50013 #endif
50014 GLOBAL_EXTERN atomic_t smBufAllocCount;
50015 GLOBAL_EXTERN atomic_t midCount;
50016 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
50017 index 51dc2fb..1e12a33 100644
50018 --- a/fs/cifs/link.c
50019 +++ b/fs/cifs/link.c
50020 @@ -616,7 +616,7 @@ symlink_exit:
50021
50022 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
50023 {
50024 - char *p = nd_get_link(nd);
50025 + const char *p = nd_get_link(nd);
50026 if (!IS_ERR(p))
50027 kfree(p);
50028 }
50029 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
50030 index 3a00c0d..42d901c 100644
50031 --- a/fs/cifs/misc.c
50032 +++ b/fs/cifs/misc.c
50033 @@ -169,7 +169,7 @@ cifs_buf_get(void)
50034 memset(ret_buf, 0, buf_size + 3);
50035 atomic_inc(&bufAllocCount);
50036 #ifdef CONFIG_CIFS_STATS2
50037 - atomic_inc(&totBufAllocCount);
50038 + atomic_inc_unchecked(&totBufAllocCount);
50039 #endif /* CONFIG_CIFS_STATS2 */
50040 }
50041
50042 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
50043 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
50044 atomic_inc(&smBufAllocCount);
50045 #ifdef CONFIG_CIFS_STATS2
50046 - atomic_inc(&totSmBufAllocCount);
50047 + atomic_inc_unchecked(&totSmBufAllocCount);
50048 #endif /* CONFIG_CIFS_STATS2 */
50049
50050 }
50051 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
50052 index 47bc5a8..10decbe 100644
50053 --- a/fs/cifs/smb1ops.c
50054 +++ b/fs/cifs/smb1ops.c
50055 @@ -586,27 +586,27 @@ static void
50056 cifs_clear_stats(struct cifs_tcon *tcon)
50057 {
50058 #ifdef CONFIG_CIFS_STATS
50059 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
50060 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
50061 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
50062 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
50063 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
50064 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
50065 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
50066 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
50067 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
50068 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
50069 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
50070 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
50071 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
50072 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
50073 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
50074 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
50075 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
50076 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
50077 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
50078 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
50079 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
50080 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
50081 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
50082 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
50083 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
50084 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
50085 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
50086 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
50087 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
50088 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
50089 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
50090 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
50091 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
50092 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
50093 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
50094 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
50095 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
50096 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
50097 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
50098 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
50099 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
50100 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
50101 #endif
50102 }
50103
50104 @@ -615,36 +615,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50105 {
50106 #ifdef CONFIG_CIFS_STATS
50107 seq_printf(m, " Oplocks breaks: %d",
50108 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
50109 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
50110 seq_printf(m, "\nReads: %d Bytes: %llu",
50111 - atomic_read(&tcon->stats.cifs_stats.num_reads),
50112 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
50113 (long long)(tcon->bytes_read));
50114 seq_printf(m, "\nWrites: %d Bytes: %llu",
50115 - atomic_read(&tcon->stats.cifs_stats.num_writes),
50116 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
50117 (long long)(tcon->bytes_written));
50118 seq_printf(m, "\nFlushes: %d",
50119 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
50120 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
50121 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
50122 - atomic_read(&tcon->stats.cifs_stats.num_locks),
50123 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
50124 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
50125 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
50126 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
50127 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
50128 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
50129 - atomic_read(&tcon->stats.cifs_stats.num_opens),
50130 - atomic_read(&tcon->stats.cifs_stats.num_closes),
50131 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
50132 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
50133 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
50134 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
50135 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
50136 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
50137 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
50138 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
50139 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
50140 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
50141 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
50142 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
50143 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
50144 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
50145 seq_printf(m, "\nRenames: %d T2 Renames %d",
50146 - atomic_read(&tcon->stats.cifs_stats.num_renames),
50147 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
50148 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
50149 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
50150 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
50151 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
50152 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
50153 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
50154 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
50155 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
50156 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
50157 #endif
50158 }
50159
50160 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
50161 index bceffe7..cd1ae59 100644
50162 --- a/fs/cifs/smb2ops.c
50163 +++ b/fs/cifs/smb2ops.c
50164 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
50165 #ifdef CONFIG_CIFS_STATS
50166 int i;
50167 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
50168 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50169 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50170 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50171 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50172 }
50173 #endif
50174 }
50175 @@ -284,66 +284,66 @@ static void
50176 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50177 {
50178 #ifdef CONFIG_CIFS_STATS
50179 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50180 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50181 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50182 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50183 seq_printf(m, "\nNegotiates: %d sent %d failed",
50184 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
50185 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
50186 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
50187 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
50188 seq_printf(m, "\nSessionSetups: %d sent %d failed",
50189 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
50190 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
50191 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
50192 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
50193 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
50194 seq_printf(m, "\nLogoffs: %d sent %d failed",
50195 - atomic_read(&sent[SMB2_LOGOFF_HE]),
50196 - atomic_read(&failed[SMB2_LOGOFF_HE]));
50197 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
50198 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
50199 seq_printf(m, "\nTreeConnects: %d sent %d failed",
50200 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
50201 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
50202 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
50203 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
50204 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
50205 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
50206 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
50207 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
50208 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
50209 seq_printf(m, "\nCreates: %d sent %d failed",
50210 - atomic_read(&sent[SMB2_CREATE_HE]),
50211 - atomic_read(&failed[SMB2_CREATE_HE]));
50212 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
50213 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
50214 seq_printf(m, "\nCloses: %d sent %d failed",
50215 - atomic_read(&sent[SMB2_CLOSE_HE]),
50216 - atomic_read(&failed[SMB2_CLOSE_HE]));
50217 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
50218 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
50219 seq_printf(m, "\nFlushes: %d sent %d failed",
50220 - atomic_read(&sent[SMB2_FLUSH_HE]),
50221 - atomic_read(&failed[SMB2_FLUSH_HE]));
50222 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
50223 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
50224 seq_printf(m, "\nReads: %d sent %d failed",
50225 - atomic_read(&sent[SMB2_READ_HE]),
50226 - atomic_read(&failed[SMB2_READ_HE]));
50227 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
50228 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
50229 seq_printf(m, "\nWrites: %d sent %d failed",
50230 - atomic_read(&sent[SMB2_WRITE_HE]),
50231 - atomic_read(&failed[SMB2_WRITE_HE]));
50232 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
50233 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
50234 seq_printf(m, "\nLocks: %d sent %d failed",
50235 - atomic_read(&sent[SMB2_LOCK_HE]),
50236 - atomic_read(&failed[SMB2_LOCK_HE]));
50237 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
50238 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
50239 seq_printf(m, "\nIOCTLs: %d sent %d failed",
50240 - atomic_read(&sent[SMB2_IOCTL_HE]),
50241 - atomic_read(&failed[SMB2_IOCTL_HE]));
50242 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
50243 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
50244 seq_printf(m, "\nCancels: %d sent %d failed",
50245 - atomic_read(&sent[SMB2_CANCEL_HE]),
50246 - atomic_read(&failed[SMB2_CANCEL_HE]));
50247 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
50248 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
50249 seq_printf(m, "\nEchos: %d sent %d failed",
50250 - atomic_read(&sent[SMB2_ECHO_HE]),
50251 - atomic_read(&failed[SMB2_ECHO_HE]));
50252 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
50253 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
50254 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
50255 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
50256 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
50257 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
50258 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
50259 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
50260 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
50261 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
50262 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
50263 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
50264 seq_printf(m, "\nQueryInfos: %d sent %d failed",
50265 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
50266 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
50267 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
50268 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
50269 seq_printf(m, "\nSetInfos: %d sent %d failed",
50270 - atomic_read(&sent[SMB2_SET_INFO_HE]),
50271 - atomic_read(&failed[SMB2_SET_INFO_HE]));
50272 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
50273 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
50274 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
50275 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
50276 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
50277 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
50278 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
50279 #endif
50280 }
50281
50282 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
50283 index 41d9d07..dbb4772 100644
50284 --- a/fs/cifs/smb2pdu.c
50285 +++ b/fs/cifs/smb2pdu.c
50286 @@ -1761,8 +1761,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
50287 default:
50288 cERROR(1, "info level %u isn't supported",
50289 srch_inf->info_level);
50290 - rc = -EINVAL;
50291 - goto qdir_exit;
50292 + return -EINVAL;
50293 }
50294
50295 req->FileIndex = cpu_to_le32(index);
50296 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
50297 index 958ae0e..505c9d0 100644
50298 --- a/fs/coda/cache.c
50299 +++ b/fs/coda/cache.c
50300 @@ -24,7 +24,7 @@
50301 #include "coda_linux.h"
50302 #include "coda_cache.h"
50303
50304 -static atomic_t permission_epoch = ATOMIC_INIT(0);
50305 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
50306
50307 /* replace or extend an acl cache hit */
50308 void coda_cache_enter(struct inode *inode, int mask)
50309 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
50310 struct coda_inode_info *cii = ITOC(inode);
50311
50312 spin_lock(&cii->c_lock);
50313 - cii->c_cached_epoch = atomic_read(&permission_epoch);
50314 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
50315 if (cii->c_uid != current_fsuid()) {
50316 cii->c_uid = current_fsuid();
50317 cii->c_cached_perm = mask;
50318 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
50319 {
50320 struct coda_inode_info *cii = ITOC(inode);
50321 spin_lock(&cii->c_lock);
50322 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
50323 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
50324 spin_unlock(&cii->c_lock);
50325 }
50326
50327 /* remove all acl caches */
50328 void coda_cache_clear_all(struct super_block *sb)
50329 {
50330 - atomic_inc(&permission_epoch);
50331 + atomic_inc_unchecked(&permission_epoch);
50332 }
50333
50334
50335 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
50336 spin_lock(&cii->c_lock);
50337 hit = (mask & cii->c_cached_perm) == mask &&
50338 cii->c_uid == current_fsuid() &&
50339 - cii->c_cached_epoch == atomic_read(&permission_epoch);
50340 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
50341 spin_unlock(&cii->c_lock);
50342
50343 return hit;
50344 diff --git a/fs/compat.c b/fs/compat.c
50345 index a06dcbc..dacb6d3 100644
50346 --- a/fs/compat.c
50347 +++ b/fs/compat.c
50348 @@ -54,7 +54,7 @@
50349 #include <asm/ioctls.h>
50350 #include "internal.h"
50351
50352 -int compat_log = 1;
50353 +int compat_log = 0;
50354
50355 int compat_printk(const char *fmt, ...)
50356 {
50357 @@ -490,7 +490,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
50358
50359 set_fs(KERNEL_DS);
50360 /* The __user pointer cast is valid because of the set_fs() */
50361 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
50362 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
50363 set_fs(oldfs);
50364 /* truncating is ok because it's a user address */
50365 if (!ret)
50366 @@ -548,7 +548,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
50367 goto out;
50368
50369 ret = -EINVAL;
50370 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
50371 + if (nr_segs > UIO_MAXIOV)
50372 goto out;
50373 if (nr_segs > fast_segs) {
50374 ret = -ENOMEM;
50375 @@ -835,6 +835,7 @@ struct compat_old_linux_dirent {
50376
50377 struct compat_readdir_callback {
50378 struct compat_old_linux_dirent __user *dirent;
50379 + struct file * file;
50380 int result;
50381 };
50382
50383 @@ -852,6 +853,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
50384 buf->result = -EOVERFLOW;
50385 return -EOVERFLOW;
50386 }
50387 +
50388 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50389 + return 0;
50390 +
50391 buf->result++;
50392 dirent = buf->dirent;
50393 if (!access_ok(VERIFY_WRITE, dirent,
50394 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
50395
50396 buf.result = 0;
50397 buf.dirent = dirent;
50398 + buf.file = f.file;
50399
50400 error = vfs_readdir(f.file, compat_fillonedir, &buf);
50401 if (buf.result)
50402 @@ -901,6 +907,7 @@ struct compat_linux_dirent {
50403 struct compat_getdents_callback {
50404 struct compat_linux_dirent __user *current_dir;
50405 struct compat_linux_dirent __user *previous;
50406 + struct file * file;
50407 int count;
50408 int error;
50409 };
50410 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
50411 buf->error = -EOVERFLOW;
50412 return -EOVERFLOW;
50413 }
50414 +
50415 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50416 + return 0;
50417 +
50418 dirent = buf->previous;
50419 if (dirent) {
50420 if (__put_user(offset, &dirent->d_off))
50421 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50422 buf.previous = NULL;
50423 buf.count = count;
50424 buf.error = 0;
50425 + buf.file = f.file;
50426
50427 error = vfs_readdir(f.file, compat_filldir, &buf);
50428 if (error >= 0)
50429 @@ -987,6 +999,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50430 struct compat_getdents_callback64 {
50431 struct linux_dirent64 __user *current_dir;
50432 struct linux_dirent64 __user *previous;
50433 + struct file * file;
50434 int count;
50435 int error;
50436 };
50437 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
50438 buf->error = -EINVAL; /* only used if we fail.. */
50439 if (reclen > buf->count)
50440 return -EINVAL;
50441 +
50442 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50443 + return 0;
50444 +
50445 dirent = buf->previous;
50446
50447 if (dirent) {
50448 @@ -1052,13 +1069,14 @@ asmlinkage long compat_sys_getdents64(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_filldir64, &buf);
50455 if (error >= 0)
50456 error = buf.error;
50457 lastdirent = buf.previous;
50458 if (lastdirent) {
50459 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
50460 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
50461 if (__put_user_unaligned(d_off, &lastdirent->d_off))
50462 error = -EFAULT;
50463 else
50464 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
50465 index a81147e..20bf2b5 100644
50466 --- a/fs/compat_binfmt_elf.c
50467 +++ b/fs/compat_binfmt_elf.c
50468 @@ -30,11 +30,13 @@
50469 #undef elf_phdr
50470 #undef elf_shdr
50471 #undef elf_note
50472 +#undef elf_dyn
50473 #undef elf_addr_t
50474 #define elfhdr elf32_hdr
50475 #define elf_phdr elf32_phdr
50476 #define elf_shdr elf32_shdr
50477 #define elf_note elf32_note
50478 +#define elf_dyn Elf32_Dyn
50479 #define elf_addr_t Elf32_Addr
50480
50481 /*
50482 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
50483 index e2f57a0..3c78771 100644
50484 --- a/fs/compat_ioctl.c
50485 +++ b/fs/compat_ioctl.c
50486 @@ -623,7 +623,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
50487 return -EFAULT;
50488 if (__get_user(udata, &ss32->iomem_base))
50489 return -EFAULT;
50490 - ss.iomem_base = compat_ptr(udata);
50491 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
50492 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
50493 __get_user(ss.port_high, &ss32->port_high))
50494 return -EFAULT;
50495 @@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
50496 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
50497 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
50498 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
50499 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50500 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50501 return -EFAULT;
50502
50503 return ioctl_preallocate(file, p);
50504 @@ -1620,8 +1620,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
50505 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
50506 {
50507 unsigned int a, b;
50508 - a = *(unsigned int *)p;
50509 - b = *(unsigned int *)q;
50510 + a = *(const unsigned int *)p;
50511 + b = *(const unsigned int *)q;
50512 if (a > b)
50513 return 1;
50514 if (a < b)
50515 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
50516 index 712b10f..c33c4ca 100644
50517 --- a/fs/configfs/dir.c
50518 +++ b/fs/configfs/dir.c
50519 @@ -1037,10 +1037,11 @@ static int configfs_dump(struct configfs_dirent *sd, int level)
50520 static int configfs_depend_prep(struct dentry *origin,
50521 struct config_item *target)
50522 {
50523 - struct configfs_dirent *child_sd, *sd = origin->d_fsdata;
50524 + struct configfs_dirent *child_sd, *sd;
50525 int ret = 0;
50526
50527 - BUG_ON(!origin || !sd);
50528 + BUG_ON(!origin || !origin->d_fsdata);
50529 + sd = origin->d_fsdata;
50530
50531 if (sd->s_element == target) /* Boo-yah */
50532 goto out;
50533 @@ -1564,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50534 }
50535 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
50536 struct configfs_dirent *next;
50537 - const char * name;
50538 + const unsigned char * name;
50539 + char d_name[sizeof(next->s_dentry->d_iname)];
50540 int len;
50541 struct inode *inode = NULL;
50542
50543 @@ -1574,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50544 continue;
50545
50546 name = configfs_get_name(next);
50547 - len = strlen(name);
50548 + if (next->s_dentry && name == next->s_dentry->d_iname) {
50549 + len = next->s_dentry->d_name.len;
50550 + memcpy(d_name, name, len);
50551 + name = d_name;
50552 + } else
50553 + len = strlen(name);
50554
50555 /*
50556 * We'll have a dentry and an inode for
50557 diff --git a/fs/coredump.c b/fs/coredump.c
50558 index 1774932..5812106 100644
50559 --- a/fs/coredump.c
50560 +++ b/fs/coredump.c
50561 @@ -52,7 +52,7 @@ struct core_name {
50562 char *corename;
50563 int used, size;
50564 };
50565 -static atomic_t call_count = ATOMIC_INIT(1);
50566 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
50567
50568 /* The maximal length of core_pattern is also specified in sysctl.c */
50569
50570 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
50571 {
50572 char *old_corename = cn->corename;
50573
50574 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
50575 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
50576 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
50577
50578 if (!cn->corename) {
50579 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
50580 int pid_in_pattern = 0;
50581 int err = 0;
50582
50583 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
50584 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
50585 cn->corename = kmalloc(cn->size, GFP_KERNEL);
50586 cn->used = 0;
50587
50588 @@ -414,17 +414,17 @@ static void wait_for_dump_helpers(struct file *file)
50589 pipe = file->f_path.dentry->d_inode->i_pipe;
50590
50591 pipe_lock(pipe);
50592 - pipe->readers++;
50593 - pipe->writers--;
50594 + atomic_inc(&pipe->readers);
50595 + atomic_dec(&pipe->writers);
50596
50597 - while ((pipe->readers > 1) && (!signal_pending(current))) {
50598 + while ((atomic_read(&pipe->readers) > 1) && (!signal_pending(current))) {
50599 wake_up_interruptible_sync(&pipe->wait);
50600 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
50601 pipe_wait(pipe);
50602 }
50603
50604 - pipe->readers--;
50605 - pipe->writers++;
50606 + atomic_dec(&pipe->readers);
50607 + atomic_inc(&pipe->writers);
50608 pipe_unlock(pipe);
50609
50610 }
50611 @@ -471,7 +471,8 @@ void do_coredump(siginfo_t *siginfo)
50612 int ispipe;
50613 struct files_struct *displaced;
50614 bool need_nonrelative = false;
50615 - static atomic_t core_dump_count = ATOMIC_INIT(0);
50616 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
50617 + long signr = siginfo->si_signo;
50618 struct coredump_params cprm = {
50619 .siginfo = siginfo,
50620 .regs = signal_pt_regs(),
50621 @@ -484,7 +485,10 @@ void do_coredump(siginfo_t *siginfo)
50622 .mm_flags = mm->flags,
50623 };
50624
50625 - audit_core_dumps(siginfo->si_signo);
50626 + audit_core_dumps(signr);
50627 +
50628 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
50629 + gr_handle_brute_attach(cprm.mm_flags);
50630
50631 binfmt = mm->binfmt;
50632 if (!binfmt || !binfmt->core_dump)
50633 @@ -508,7 +512,7 @@ void do_coredump(siginfo_t *siginfo)
50634 need_nonrelative = true;
50635 }
50636
50637 - retval = coredump_wait(siginfo->si_signo, &core_state);
50638 + retval = coredump_wait(signr, &core_state);
50639 if (retval < 0)
50640 goto fail_creds;
50641
50642 @@ -556,7 +560,7 @@ void do_coredump(siginfo_t *siginfo)
50643 }
50644 cprm.limit = RLIM_INFINITY;
50645
50646 - dump_count = atomic_inc_return(&core_dump_count);
50647 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
50648 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
50649 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
50650 task_tgid_vnr(current), current->comm);
50651 @@ -583,6 +587,8 @@ void do_coredump(siginfo_t *siginfo)
50652 } else {
50653 struct inode *inode;
50654
50655 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
50656 +
50657 if (cprm.limit < binfmt->min_coredump)
50658 goto fail_unlock;
50659
50660 @@ -640,7 +646,7 @@ close_fail:
50661 filp_close(cprm.file, NULL);
50662 fail_dropcount:
50663 if (ispipe)
50664 - atomic_dec(&core_dump_count);
50665 + atomic_dec_unchecked(&core_dump_count);
50666 fail_unlock:
50667 kfree(cn.corename);
50668 fail_corename:
50669 @@ -659,7 +665,7 @@ fail:
50670 */
50671 int dump_write(struct file *file, const void *addr, int nr)
50672 {
50673 - return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
50674 + return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
50675 }
50676 EXPORT_SYMBOL(dump_write);
50677
50678 diff --git a/fs/dcache.c b/fs/dcache.c
50679 index c3bbf85..5b71101 100644
50680 --- a/fs/dcache.c
50681 +++ b/fs/dcache.c
50682 @@ -3139,7 +3139,7 @@ void __init vfs_caches_init(unsigned long mempages)
50683 mempages -= reserve;
50684
50685 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
50686 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
50687 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
50688
50689 dcache_init();
50690 inode_init();
50691 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
50692 index a5f12b7..4ee8a6f 100644
50693 --- a/fs/debugfs/inode.c
50694 +++ b/fs/debugfs/inode.c
50695 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
50696 */
50697 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
50698 {
50699 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
50700 + return __create_file(name, S_IFDIR | S_IRWXU,
50701 +#else
50702 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
50703 +#endif
50704 parent, NULL, NULL);
50705 }
50706 EXPORT_SYMBOL_GPL(debugfs_create_dir);
50707 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
50708 index cc7709e..7e7211f 100644
50709 --- a/fs/ecryptfs/inode.c
50710 +++ b/fs/ecryptfs/inode.c
50711 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
50712 old_fs = get_fs();
50713 set_fs(get_ds());
50714 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
50715 - (char __user *)lower_buf,
50716 + (char __force_user *)lower_buf,
50717 PATH_MAX);
50718 set_fs(old_fs);
50719 if (rc < 0)
50720 @@ -706,7 +706,7 @@ out:
50721 static void
50722 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
50723 {
50724 - char *buf = nd_get_link(nd);
50725 + const char *buf = nd_get_link(nd);
50726 if (!IS_ERR(buf)) {
50727 /* Free the char* */
50728 kfree(buf);
50729 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
50730 index 412e6ed..d8263e8 100644
50731 --- a/fs/ecryptfs/miscdev.c
50732 +++ b/fs/ecryptfs/miscdev.c
50733 @@ -80,13 +80,6 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
50734 int rc;
50735
50736 mutex_lock(&ecryptfs_daemon_hash_mux);
50737 - rc = try_module_get(THIS_MODULE);
50738 - if (rc == 0) {
50739 - rc = -EIO;
50740 - printk(KERN_ERR "%s: Error attempting to increment module use "
50741 - "count; rc = [%d]\n", __func__, rc);
50742 - goto out_unlock_daemon_list;
50743 - }
50744 rc = ecryptfs_find_daemon_by_euid(&daemon);
50745 if (!rc) {
50746 rc = -EINVAL;
50747 @@ -96,7 +89,7 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
50748 if (rc) {
50749 printk(KERN_ERR "%s: Error attempting to spawn daemon; "
50750 "rc = [%d]\n", __func__, rc);
50751 - goto out_module_put_unlock_daemon_list;
50752 + goto out_unlock_daemon_list;
50753 }
50754 mutex_lock(&daemon->mux);
50755 if (daemon->flags & ECRYPTFS_DAEMON_MISCDEV_OPEN) {
50756 @@ -108,9 +101,6 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
50757 atomic_inc(&ecryptfs_num_miscdev_opens);
50758 out_unlock_daemon:
50759 mutex_unlock(&daemon->mux);
50760 -out_module_put_unlock_daemon_list:
50761 - if (rc)
50762 - module_put(THIS_MODULE);
50763 out_unlock_daemon_list:
50764 mutex_unlock(&ecryptfs_daemon_hash_mux);
50765 return rc;
50766 @@ -147,7 +137,6 @@ ecryptfs_miscdev_release(struct inode *inode, struct file *file)
50767 "bug.\n", __func__, rc);
50768 BUG();
50769 }
50770 - module_put(THIS_MODULE);
50771 return rc;
50772 }
50773
50774 @@ -315,7 +304,7 @@ check_list:
50775 goto out_unlock_msg_ctx;
50776 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
50777 if (msg_ctx->msg) {
50778 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
50779 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
50780 goto out_unlock_msg_ctx;
50781 i += packet_length_size;
50782 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
50783 @@ -471,6 +460,7 @@ out_free:
50784
50785
50786 static const struct file_operations ecryptfs_miscdev_fops = {
50787 + .owner = THIS_MODULE,
50788 .open = ecryptfs_miscdev_open,
50789 .poll = ecryptfs_miscdev_poll,
50790 .read = ecryptfs_miscdev_read,
50791 diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
50792 index b2a34a1..162fa69 100644
50793 --- a/fs/ecryptfs/read_write.c
50794 +++ b/fs/ecryptfs/read_write.c
50795 @@ -48,7 +48,7 @@ int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data,
50796 return -EIO;
50797 fs_save = get_fs();
50798 set_fs(get_ds());
50799 - rc = vfs_write(lower_file, data, size, &offset);
50800 + rc = vfs_write(lower_file, (const char __force_user *)data, size, &offset);
50801 set_fs(fs_save);
50802 mark_inode_dirty_sync(ecryptfs_inode);
50803 return rc;
50804 @@ -244,7 +244,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
50805 return -EIO;
50806 fs_save = get_fs();
50807 set_fs(get_ds());
50808 - rc = vfs_read(lower_file, data, size, &offset);
50809 + rc = vfs_read(lower_file, (char __force_user *)data, size, &offset);
50810 set_fs(fs_save);
50811 return rc;
50812 }
50813 diff --git a/fs/exec.c b/fs/exec.c
50814 index 20df02c..1b1d946 100644
50815 --- a/fs/exec.c
50816 +++ b/fs/exec.c
50817 @@ -55,6 +55,17 @@
50818 #include <linux/pipe_fs_i.h>
50819 #include <linux/oom.h>
50820 #include <linux/compat.h>
50821 +#include <linux/random.h>
50822 +#include <linux/seq_file.h>
50823 +#include <linux/coredump.h>
50824 +#include <linux/mman.h>
50825 +
50826 +#ifdef CONFIG_PAX_REFCOUNT
50827 +#include <linux/kallsyms.h>
50828 +#include <linux/kdebug.h>
50829 +#endif
50830 +
50831 +#include <trace/events/fs.h>
50832
50833 #include <asm/uaccess.h>
50834 #include <asm/mmu_context.h>
50835 @@ -66,6 +77,18 @@
50836
50837 #include <trace/events/sched.h>
50838
50839 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
50840 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
50841 +{
50842 + 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");
50843 +}
50844 +#endif
50845 +
50846 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
50847 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
50848 +EXPORT_SYMBOL(pax_set_initial_flags_func);
50849 +#endif
50850 +
50851 int suid_dumpable = 0;
50852
50853 static LIST_HEAD(formats);
50854 @@ -75,8 +98,8 @@ void __register_binfmt(struct linux_binfmt * fmt, int insert)
50855 {
50856 BUG_ON(!fmt);
50857 write_lock(&binfmt_lock);
50858 - insert ? list_add(&fmt->lh, &formats) :
50859 - list_add_tail(&fmt->lh, &formats);
50860 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
50861 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
50862 write_unlock(&binfmt_lock);
50863 }
50864
50865 @@ -85,7 +108,7 @@ EXPORT_SYMBOL(__register_binfmt);
50866 void unregister_binfmt(struct linux_binfmt * fmt)
50867 {
50868 write_lock(&binfmt_lock);
50869 - list_del(&fmt->lh);
50870 + pax_list_del((struct list_head *)&fmt->lh);
50871 write_unlock(&binfmt_lock);
50872 }
50873
50874 @@ -180,18 +203,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50875 int write)
50876 {
50877 struct page *page;
50878 - int ret;
50879
50880 -#ifdef CONFIG_STACK_GROWSUP
50881 - if (write) {
50882 - ret = expand_downwards(bprm->vma, pos);
50883 - if (ret < 0)
50884 - return NULL;
50885 - }
50886 -#endif
50887 - ret = get_user_pages(current, bprm->mm, pos,
50888 - 1, write, 1, &page, NULL);
50889 - if (ret <= 0)
50890 + if (0 > expand_downwards(bprm->vma, pos))
50891 + return NULL;
50892 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
50893 return NULL;
50894
50895 if (write) {
50896 @@ -207,6 +222,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50897 if (size <= ARG_MAX)
50898 return page;
50899
50900 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50901 + // only allow 512KB for argv+env on suid/sgid binaries
50902 + // to prevent easy ASLR exhaustion
50903 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
50904 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
50905 + (size > (512 * 1024))) {
50906 + put_page(page);
50907 + return NULL;
50908 + }
50909 +#endif
50910 +
50911 /*
50912 * Limit to 1/4-th the stack size for the argv+env strings.
50913 * This ensures that:
50914 @@ -266,6 +292,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50915 vma->vm_end = STACK_TOP_MAX;
50916 vma->vm_start = vma->vm_end - PAGE_SIZE;
50917 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
50918 +
50919 +#ifdef CONFIG_PAX_SEGMEXEC
50920 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
50921 +#endif
50922 +
50923 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
50924 INIT_LIST_HEAD(&vma->anon_vma_chain);
50925
50926 @@ -276,6 +307,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50927 mm->stack_vm = mm->total_vm = 1;
50928 up_write(&mm->mmap_sem);
50929 bprm->p = vma->vm_end - sizeof(void *);
50930 +
50931 +#ifdef CONFIG_PAX_RANDUSTACK
50932 + if (randomize_va_space)
50933 + bprm->p ^= random32() & ~PAGE_MASK;
50934 +#endif
50935 +
50936 return 0;
50937 err:
50938 up_write(&mm->mmap_sem);
50939 @@ -396,7 +433,7 @@ struct user_arg_ptr {
50940 } ptr;
50941 };
50942
50943 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50944 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50945 {
50946 const char __user *native;
50947
50948 @@ -405,14 +442,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50949 compat_uptr_t compat;
50950
50951 if (get_user(compat, argv.ptr.compat + nr))
50952 - return ERR_PTR(-EFAULT);
50953 + return (const char __force_user *)ERR_PTR(-EFAULT);
50954
50955 return compat_ptr(compat);
50956 }
50957 #endif
50958
50959 if (get_user(native, argv.ptr.native + nr))
50960 - return ERR_PTR(-EFAULT);
50961 + return (const char __force_user *)ERR_PTR(-EFAULT);
50962
50963 return native;
50964 }
50965 @@ -431,7 +468,7 @@ static int count(struct user_arg_ptr argv, int max)
50966 if (!p)
50967 break;
50968
50969 - if (IS_ERR(p))
50970 + if (IS_ERR((const char __force_kernel *)p))
50971 return -EFAULT;
50972
50973 if (i >= max)
50974 @@ -466,7 +503,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
50975
50976 ret = -EFAULT;
50977 str = get_user_arg_ptr(argv, argc);
50978 - if (IS_ERR(str))
50979 + if (IS_ERR((const char __force_kernel *)str))
50980 goto out;
50981
50982 len = strnlen_user(str, MAX_ARG_STRLEN);
50983 @@ -548,7 +585,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
50984 int r;
50985 mm_segment_t oldfs = get_fs();
50986 struct user_arg_ptr argv = {
50987 - .ptr.native = (const char __user *const __user *)__argv,
50988 + .ptr.native = (const char __force_user *const __force_user *)__argv,
50989 };
50990
50991 set_fs(KERNEL_DS);
50992 @@ -583,7 +620,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50993 unsigned long new_end = old_end - shift;
50994 struct mmu_gather tlb;
50995
50996 - BUG_ON(new_start > new_end);
50997 + if (new_start >= new_end || new_start < mmap_min_addr)
50998 + return -ENOMEM;
50999
51000 /*
51001 * ensure there are no vmas between where we want to go
51002 @@ -592,6 +630,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
51003 if (vma != find_vma(mm, new_start))
51004 return -EFAULT;
51005
51006 +#ifdef CONFIG_PAX_SEGMEXEC
51007 + BUG_ON(pax_find_mirror_vma(vma));
51008 +#endif
51009 +
51010 /*
51011 * cover the whole range: [new_start, old_end)
51012 */
51013 @@ -672,10 +714,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
51014 stack_top = arch_align_stack(stack_top);
51015 stack_top = PAGE_ALIGN(stack_top);
51016
51017 - if (unlikely(stack_top < mmap_min_addr) ||
51018 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
51019 - return -ENOMEM;
51020 -
51021 stack_shift = vma->vm_end - stack_top;
51022
51023 bprm->p -= stack_shift;
51024 @@ -687,8 +725,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
51025 bprm->exec -= stack_shift;
51026
51027 down_write(&mm->mmap_sem);
51028 +
51029 + /* Move stack pages down in memory. */
51030 + if (stack_shift) {
51031 + ret = shift_arg_pages(vma, stack_shift);
51032 + if (ret)
51033 + goto out_unlock;
51034 + }
51035 +
51036 vm_flags = VM_STACK_FLAGS;
51037
51038 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51039 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
51040 + vm_flags &= ~VM_EXEC;
51041 +
51042 +#ifdef CONFIG_PAX_MPROTECT
51043 + if (mm->pax_flags & MF_PAX_MPROTECT)
51044 + vm_flags &= ~VM_MAYEXEC;
51045 +#endif
51046 +
51047 + }
51048 +#endif
51049 +
51050 /*
51051 * Adjust stack execute permissions; explicitly enable for
51052 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
51053 @@ -707,13 +765,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
51054 goto out_unlock;
51055 BUG_ON(prev != vma);
51056
51057 - /* Move stack pages down in memory. */
51058 - if (stack_shift) {
51059 - ret = shift_arg_pages(vma, stack_shift);
51060 - if (ret)
51061 - goto out_unlock;
51062 - }
51063 -
51064 /* mprotect_fixup is overkill to remove the temporary stack flags */
51065 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
51066
51067 @@ -737,6 +788,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
51068 #endif
51069 current->mm->start_stack = bprm->p;
51070 ret = expand_stack(vma, stack_base);
51071 +
51072 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
51073 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
51074 + unsigned long size, flags, vm_flags;
51075 +
51076 + size = STACK_TOP - vma->vm_end;
51077 + flags = MAP_FIXED | MAP_PRIVATE;
51078 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
51079 +
51080 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, flags, vm_flags, 0);
51081 +
51082 +#ifdef CONFIG_X86
51083 + if (!ret) {
51084 + size = mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
51085 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), flags, vm_flags, 0);
51086 + }
51087 +#endif
51088 +
51089 + }
51090 +#endif
51091 +
51092 if (ret)
51093 ret = -EFAULT;
51094
51095 @@ -772,6 +844,8 @@ struct file *open_exec(const char *name)
51096
51097 fsnotify_open(file);
51098
51099 + trace_open_exec(name);
51100 +
51101 err = deny_write_access(file);
51102 if (err)
51103 goto exit;
51104 @@ -795,7 +869,7 @@ int kernel_read(struct file *file, loff_t offset,
51105 old_fs = get_fs();
51106 set_fs(get_ds());
51107 /* The cast to a user pointer is valid due to the set_fs() */
51108 - result = vfs_read(file, (void __user *)addr, count, &pos);
51109 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
51110 set_fs(old_fs);
51111 return result;
51112 }
51113 @@ -1247,7 +1321,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
51114 }
51115 rcu_read_unlock();
51116
51117 - if (p->fs->users > n_fs) {
51118 + if (atomic_read(&p->fs->users) > n_fs) {
51119 bprm->unsafe |= LSM_UNSAFE_SHARE;
51120 } else {
51121 res = -EAGAIN;
51122 @@ -1447,6 +1521,31 @@ int search_binary_handler(struct linux_binprm *bprm)
51123
51124 EXPORT_SYMBOL(search_binary_handler);
51125
51126 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51127 +static DEFINE_PER_CPU(u64, exec_counter);
51128 +static int __init init_exec_counters(void)
51129 +{
51130 + unsigned int cpu;
51131 +
51132 + for_each_possible_cpu(cpu) {
51133 + per_cpu(exec_counter, cpu) = (u64)cpu;
51134 + }
51135 +
51136 + return 0;
51137 +}
51138 +early_initcall(init_exec_counters);
51139 +static inline void increment_exec_counter(void)
51140 +{
51141 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
51142 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
51143 +}
51144 +#else
51145 +static inline void increment_exec_counter(void) {}
51146 +#endif
51147 +
51148 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
51149 + struct user_arg_ptr argv);
51150 +
51151 /*
51152 * sys_execve() executes a new program.
51153 */
51154 @@ -1454,6 +1553,11 @@ static int do_execve_common(const char *filename,
51155 struct user_arg_ptr argv,
51156 struct user_arg_ptr envp)
51157 {
51158 +#ifdef CONFIG_GRKERNSEC
51159 + struct file *old_exec_file;
51160 + struct acl_subject_label *old_acl;
51161 + struct rlimit old_rlim[RLIM_NLIMITS];
51162 +#endif
51163 struct linux_binprm *bprm;
51164 struct file *file;
51165 struct files_struct *displaced;
51166 @@ -1461,6 +1565,8 @@ static int do_execve_common(const char *filename,
51167 int retval;
51168 const struct cred *cred = current_cred();
51169
51170 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current->cred->user->processes), 1);
51171 +
51172 /*
51173 * We move the actual failure in case of RLIMIT_NPROC excess from
51174 * set*uid() to execve() because too many poorly written programs
51175 @@ -1501,12 +1607,27 @@ static int do_execve_common(const char *filename,
51176 if (IS_ERR(file))
51177 goto out_unmark;
51178
51179 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
51180 + retval = -EPERM;
51181 + goto out_file;
51182 + }
51183 +
51184 sched_exec();
51185
51186 bprm->file = file;
51187 bprm->filename = filename;
51188 bprm->interp = filename;
51189
51190 + if (gr_process_user_ban()) {
51191 + retval = -EPERM;
51192 + goto out_file;
51193 + }
51194 +
51195 + if (!gr_acl_handle_execve(file->f_dentry, file->f_vfsmnt)) {
51196 + retval = -EACCES;
51197 + goto out_file;
51198 + }
51199 +
51200 retval = bprm_mm_init(bprm);
51201 if (retval)
51202 goto out_file;
51203 @@ -1523,24 +1644,65 @@ static int do_execve_common(const char *filename,
51204 if (retval < 0)
51205 goto out;
51206
51207 +#ifdef CONFIG_GRKERNSEC
51208 + old_acl = current->acl;
51209 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
51210 + old_exec_file = current->exec_file;
51211 + get_file(file);
51212 + current->exec_file = file;
51213 +#endif
51214 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51215 + /* limit suid stack to 8MB
51216 + * we saved the old limits above and will restore them if this exec fails
51217 + */
51218 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
51219 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
51220 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
51221 +#endif
51222 +
51223 + if (!gr_tpe_allow(file)) {
51224 + retval = -EACCES;
51225 + goto out_fail;
51226 + }
51227 +
51228 + if (gr_check_crash_exec(file)) {
51229 + retval = -EACCES;
51230 + goto out_fail;
51231 + }
51232 +
51233 + retval = gr_set_proc_label(file->f_dentry, file->f_vfsmnt,
51234 + bprm->unsafe);
51235 + if (retval < 0)
51236 + goto out_fail;
51237 +
51238 retval = copy_strings_kernel(1, &bprm->filename, bprm);
51239 if (retval < 0)
51240 - goto out;
51241 + goto out_fail;
51242
51243 bprm->exec = bprm->p;
51244 retval = copy_strings(bprm->envc, envp, bprm);
51245 if (retval < 0)
51246 - goto out;
51247 + goto out_fail;
51248
51249 retval = copy_strings(bprm->argc, argv, bprm);
51250 if (retval < 0)
51251 - goto out;
51252 + goto out_fail;
51253 +
51254 + gr_log_chroot_exec(file->f_dentry, file->f_vfsmnt);
51255 +
51256 + gr_handle_exec_args(bprm, argv);
51257
51258 retval = search_binary_handler(bprm);
51259 if (retval < 0)
51260 - goto out;
51261 + goto out_fail;
51262 +#ifdef CONFIG_GRKERNSEC
51263 + if (old_exec_file)
51264 + fput(old_exec_file);
51265 +#endif
51266
51267 /* execve succeeded */
51268 +
51269 + increment_exec_counter();
51270 current->fs->in_exec = 0;
51271 current->in_execve = 0;
51272 acct_update_integrals(current);
51273 @@ -1549,6 +1711,14 @@ static int do_execve_common(const char *filename,
51274 put_files_struct(displaced);
51275 return retval;
51276
51277 +out_fail:
51278 +#ifdef CONFIG_GRKERNSEC
51279 + current->acl = old_acl;
51280 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
51281 + fput(current->exec_file);
51282 + current->exec_file = old_exec_file;
51283 +#endif
51284 +
51285 out:
51286 if (bprm->mm) {
51287 acct_arg_size(bprm, 0);
51288 @@ -1697,3 +1867,253 @@ asmlinkage long compat_sys_execve(const char __user * filename,
51289 return error;
51290 }
51291 #endif
51292 +
51293 +int pax_check_flags(unsigned long *flags)
51294 +{
51295 + int retval = 0;
51296 +
51297 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
51298 + if (*flags & MF_PAX_SEGMEXEC)
51299 + {
51300 + *flags &= ~MF_PAX_SEGMEXEC;
51301 + retval = -EINVAL;
51302 + }
51303 +#endif
51304 +
51305 + if ((*flags & MF_PAX_PAGEEXEC)
51306 +
51307 +#ifdef CONFIG_PAX_PAGEEXEC
51308 + && (*flags & MF_PAX_SEGMEXEC)
51309 +#endif
51310 +
51311 + )
51312 + {
51313 + *flags &= ~MF_PAX_PAGEEXEC;
51314 + retval = -EINVAL;
51315 + }
51316 +
51317 + if ((*flags & MF_PAX_MPROTECT)
51318 +
51319 +#ifdef CONFIG_PAX_MPROTECT
51320 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51321 +#endif
51322 +
51323 + )
51324 + {
51325 + *flags &= ~MF_PAX_MPROTECT;
51326 + retval = -EINVAL;
51327 + }
51328 +
51329 + if ((*flags & MF_PAX_EMUTRAMP)
51330 +
51331 +#ifdef CONFIG_PAX_EMUTRAMP
51332 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51333 +#endif
51334 +
51335 + )
51336 + {
51337 + *flags &= ~MF_PAX_EMUTRAMP;
51338 + retval = -EINVAL;
51339 + }
51340 +
51341 + return retval;
51342 +}
51343 +
51344 +EXPORT_SYMBOL(pax_check_flags);
51345 +
51346 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51347 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
51348 +{
51349 + struct task_struct *tsk = current;
51350 + struct mm_struct *mm = current->mm;
51351 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
51352 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
51353 + char *path_exec = NULL;
51354 + char *path_fault = NULL;
51355 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
51356 + siginfo_t info = { };
51357 +
51358 + if (buffer_exec && buffer_fault) {
51359 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
51360 +
51361 + down_read(&mm->mmap_sem);
51362 + vma = mm->mmap;
51363 + while (vma && (!vma_exec || !vma_fault)) {
51364 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
51365 + vma_exec = vma;
51366 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
51367 + vma_fault = vma;
51368 + vma = vma->vm_next;
51369 + }
51370 + if (vma_exec) {
51371 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
51372 + if (IS_ERR(path_exec))
51373 + path_exec = "<path too long>";
51374 + else {
51375 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
51376 + if (path_exec) {
51377 + *path_exec = 0;
51378 + path_exec = buffer_exec;
51379 + } else
51380 + path_exec = "<path too long>";
51381 + }
51382 + }
51383 + if (vma_fault) {
51384 + start = vma_fault->vm_start;
51385 + end = vma_fault->vm_end;
51386 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
51387 + if (vma_fault->vm_file) {
51388 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
51389 + if (IS_ERR(path_fault))
51390 + path_fault = "<path too long>";
51391 + else {
51392 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
51393 + if (path_fault) {
51394 + *path_fault = 0;
51395 + path_fault = buffer_fault;
51396 + } else
51397 + path_fault = "<path too long>";
51398 + }
51399 + } else
51400 + path_fault = "<anonymous mapping>";
51401 + }
51402 + up_read(&mm->mmap_sem);
51403 + }
51404 + if (tsk->signal->curr_ip)
51405 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
51406 + else
51407 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
51408 + 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),
51409 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
51410 + free_page((unsigned long)buffer_exec);
51411 + free_page((unsigned long)buffer_fault);
51412 + pax_report_insns(regs, pc, sp);
51413 + info.si_signo = SIGKILL;
51414 + info.si_errno = 0;
51415 + info.si_code = SI_KERNEL;
51416 + info.si_pid = 0;
51417 + info.si_uid = 0;
51418 + do_coredump(&info);
51419 +}
51420 +#endif
51421 +
51422 +#ifdef CONFIG_PAX_REFCOUNT
51423 +void pax_report_refcount_overflow(struct pt_regs *regs)
51424 +{
51425 + if (current->signal->curr_ip)
51426 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
51427 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
51428 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51429 + else
51430 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
51431 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51432 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
51433 + show_regs(regs);
51434 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
51435 +}
51436 +#endif
51437 +
51438 +#ifdef CONFIG_PAX_USERCOPY
51439 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
51440 +static noinline int check_stack_object(const void *obj, unsigned long len)
51441 +{
51442 + const void * const stack = task_stack_page(current);
51443 + const void * const stackend = stack + THREAD_SIZE;
51444 +
51445 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51446 + const void *frame = NULL;
51447 + const void *oldframe;
51448 +#endif
51449 +
51450 + if (obj + len < obj)
51451 + return -1;
51452 +
51453 + if (obj + len <= stack || stackend <= obj)
51454 + return 0;
51455 +
51456 + if (obj < stack || stackend < obj + len)
51457 + return -1;
51458 +
51459 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51460 + oldframe = __builtin_frame_address(1);
51461 + if (oldframe)
51462 + frame = __builtin_frame_address(2);
51463 + /*
51464 + low ----------------------------------------------> high
51465 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
51466 + ^----------------^
51467 + allow copies only within here
51468 + */
51469 + while (stack <= frame && frame < stackend) {
51470 + /* if obj + len extends past the last frame, this
51471 + check won't pass and the next frame will be 0,
51472 + causing us to bail out and correctly report
51473 + the copy as invalid
51474 + */
51475 + if (obj + len <= frame)
51476 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
51477 + oldframe = frame;
51478 + frame = *(const void * const *)frame;
51479 + }
51480 + return -1;
51481 +#else
51482 + return 1;
51483 +#endif
51484 +}
51485 +
51486 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
51487 +{
51488 + if (current->signal->curr_ip)
51489 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51490 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51491 + else
51492 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51493 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51494 + dump_stack();
51495 + gr_handle_kernel_exploit();
51496 + do_group_exit(SIGKILL);
51497 +}
51498 +#endif
51499 +
51500 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
51501 +{
51502 +
51503 +#ifdef CONFIG_PAX_USERCOPY
51504 + const char *type;
51505 +
51506 + if (!n)
51507 + return;
51508 +
51509 + type = check_heap_object(ptr, n);
51510 + if (!type) {
51511 + if (check_stack_object(ptr, n) != -1)
51512 + return;
51513 + type = "<process stack>";
51514 + }
51515 +
51516 + pax_report_usercopy(ptr, n, to_user, type);
51517 +#endif
51518 +
51519 +}
51520 +EXPORT_SYMBOL(__check_object_size);
51521 +
51522 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
51523 +void pax_track_stack(void)
51524 +{
51525 + unsigned long sp = (unsigned long)&sp;
51526 + if (sp < current_thread_info()->lowest_stack &&
51527 + sp > (unsigned long)task_stack_page(current))
51528 + current_thread_info()->lowest_stack = sp;
51529 +}
51530 +EXPORT_SYMBOL(pax_track_stack);
51531 +#endif
51532 +
51533 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
51534 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
51535 +{
51536 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
51537 + dump_stack();
51538 + do_group_exit(SIGKILL);
51539 +}
51540 +EXPORT_SYMBOL(report_size_overflow);
51541 +#endif
51542 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
51543 index 2616d0e..2ffdec9 100644
51544 --- a/fs/ext2/balloc.c
51545 +++ b/fs/ext2/balloc.c
51546 @@ -1190,10 +1190,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
51547
51548 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51549 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51550 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51551 + if (free_blocks < root_blocks + 1 &&
51552 !uid_eq(sbi->s_resuid, current_fsuid()) &&
51553 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51554 - !in_group_p (sbi->s_resgid))) {
51555 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51556 return 0;
51557 }
51558 return 1;
51559 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
51560 index 22548f5..41521d8 100644
51561 --- a/fs/ext3/balloc.c
51562 +++ b/fs/ext3/balloc.c
51563 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
51564
51565 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51566 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51567 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51568 + if (free_blocks < root_blocks + 1 &&
51569 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
51570 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51571 - !in_group_p (sbi->s_resgid))) {
51572 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51573 return 0;
51574 }
51575 return 1;
51576 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
51577 index 92e68b3..115d987 100644
51578 --- a/fs/ext4/balloc.c
51579 +++ b/fs/ext4/balloc.c
51580 @@ -505,8 +505,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
51581 /* Hm, nope. Are (enough) root reserved clusters available? */
51582 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
51583 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
51584 - capable(CAP_SYS_RESOURCE) ||
51585 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
51586 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
51587 + capable_nolog(CAP_SYS_RESOURCE)) {
51588
51589 if (free_clusters >= (nclusters + dirty_clusters))
51590 return 1;
51591 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
51592 index bbcd6a0..2824592 100644
51593 --- a/fs/ext4/ext4.h
51594 +++ b/fs/ext4/ext4.h
51595 @@ -1265,19 +1265,19 @@ struct ext4_sb_info {
51596 unsigned long s_mb_last_start;
51597
51598 /* stats for buddy allocator */
51599 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
51600 - atomic_t s_bal_success; /* we found long enough chunks */
51601 - atomic_t s_bal_allocated; /* in blocks */
51602 - atomic_t s_bal_ex_scanned; /* total extents scanned */
51603 - atomic_t s_bal_goals; /* goal hits */
51604 - atomic_t s_bal_breaks; /* too long searches */
51605 - atomic_t s_bal_2orders; /* 2^order hits */
51606 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
51607 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
51608 + atomic_unchecked_t s_bal_allocated; /* in blocks */
51609 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
51610 + atomic_unchecked_t s_bal_goals; /* goal hits */
51611 + atomic_unchecked_t s_bal_breaks; /* too long searches */
51612 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
51613 spinlock_t s_bal_lock;
51614 unsigned long s_mb_buddies_generated;
51615 unsigned long long s_mb_generation_time;
51616 - atomic_t s_mb_lost_chunks;
51617 - atomic_t s_mb_preallocated;
51618 - atomic_t s_mb_discarded;
51619 + atomic_unchecked_t s_mb_lost_chunks;
51620 + atomic_unchecked_t s_mb_preallocated;
51621 + atomic_unchecked_t s_mb_discarded;
51622 atomic_t s_lock_busy;
51623
51624 /* locality groups */
51625 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
51626 index 82f8c2d..ce7c889 100644
51627 --- a/fs/ext4/mballoc.c
51628 +++ b/fs/ext4/mballoc.c
51629 @@ -1747,7 +1747,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
51630 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
51631
51632 if (EXT4_SB(sb)->s_mb_stats)
51633 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
51634 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
51635
51636 break;
51637 }
51638 @@ -2044,7 +2044,7 @@ repeat:
51639 ac->ac_status = AC_STATUS_CONTINUE;
51640 ac->ac_flags |= EXT4_MB_HINT_FIRST;
51641 cr = 3;
51642 - atomic_inc(&sbi->s_mb_lost_chunks);
51643 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
51644 goto repeat;
51645 }
51646 }
51647 @@ -2552,25 +2552,25 @@ int ext4_mb_release(struct super_block *sb)
51648 if (sbi->s_mb_stats) {
51649 ext4_msg(sb, KERN_INFO,
51650 "mballoc: %u blocks %u reqs (%u success)",
51651 - atomic_read(&sbi->s_bal_allocated),
51652 - atomic_read(&sbi->s_bal_reqs),
51653 - atomic_read(&sbi->s_bal_success));
51654 + atomic_read_unchecked(&sbi->s_bal_allocated),
51655 + atomic_read_unchecked(&sbi->s_bal_reqs),
51656 + atomic_read_unchecked(&sbi->s_bal_success));
51657 ext4_msg(sb, KERN_INFO,
51658 "mballoc: %u extents scanned, %u goal hits, "
51659 "%u 2^N hits, %u breaks, %u lost",
51660 - atomic_read(&sbi->s_bal_ex_scanned),
51661 - atomic_read(&sbi->s_bal_goals),
51662 - atomic_read(&sbi->s_bal_2orders),
51663 - atomic_read(&sbi->s_bal_breaks),
51664 - atomic_read(&sbi->s_mb_lost_chunks));
51665 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
51666 + atomic_read_unchecked(&sbi->s_bal_goals),
51667 + atomic_read_unchecked(&sbi->s_bal_2orders),
51668 + atomic_read_unchecked(&sbi->s_bal_breaks),
51669 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
51670 ext4_msg(sb, KERN_INFO,
51671 "mballoc: %lu generated and it took %Lu",
51672 sbi->s_mb_buddies_generated,
51673 sbi->s_mb_generation_time);
51674 ext4_msg(sb, KERN_INFO,
51675 "mballoc: %u preallocated, %u discarded",
51676 - atomic_read(&sbi->s_mb_preallocated),
51677 - atomic_read(&sbi->s_mb_discarded));
51678 + atomic_read_unchecked(&sbi->s_mb_preallocated),
51679 + atomic_read_unchecked(&sbi->s_mb_discarded));
51680 }
51681
51682 free_percpu(sbi->s_locality_groups);
51683 @@ -3060,16 +3060,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
51684 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
51685
51686 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
51687 - atomic_inc(&sbi->s_bal_reqs);
51688 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51689 + atomic_inc_unchecked(&sbi->s_bal_reqs);
51690 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51691 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
51692 - atomic_inc(&sbi->s_bal_success);
51693 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
51694 + atomic_inc_unchecked(&sbi->s_bal_success);
51695 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
51696 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
51697 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
51698 - atomic_inc(&sbi->s_bal_goals);
51699 + atomic_inc_unchecked(&sbi->s_bal_goals);
51700 if (ac->ac_found > sbi->s_mb_max_to_scan)
51701 - atomic_inc(&sbi->s_bal_breaks);
51702 + atomic_inc_unchecked(&sbi->s_bal_breaks);
51703 }
51704
51705 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
51706 @@ -3469,7 +3469,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
51707 trace_ext4_mb_new_inode_pa(ac, pa);
51708
51709 ext4_mb_use_inode_pa(ac, pa);
51710 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
51711 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
51712
51713 ei = EXT4_I(ac->ac_inode);
51714 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51715 @@ -3529,7 +3529,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
51716 trace_ext4_mb_new_group_pa(ac, pa);
51717
51718 ext4_mb_use_group_pa(ac, pa);
51719 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51720 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51721
51722 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51723 lg = ac->ac_lg;
51724 @@ -3618,7 +3618,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
51725 * from the bitmap and continue.
51726 */
51727 }
51728 - atomic_add(free, &sbi->s_mb_discarded);
51729 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
51730
51731 return err;
51732 }
51733 @@ -3636,7 +3636,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
51734 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
51735 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
51736 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
51737 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51738 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51739 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
51740
51741 return 0;
51742 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
51743 index 24c767d..893aa55 100644
51744 --- a/fs/ext4/super.c
51745 +++ b/fs/ext4/super.c
51746 @@ -2429,7 +2429,7 @@ struct ext4_attr {
51747 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
51748 const char *, size_t);
51749 int offset;
51750 -};
51751 +} __do_const;
51752
51753 static int parse_strtoul(const char *buf,
51754 unsigned long max, unsigned long *value)
51755 diff --git a/fs/fcntl.c b/fs/fcntl.c
51756 index 71a600a..20d87b1 100644
51757 --- a/fs/fcntl.c
51758 +++ b/fs/fcntl.c
51759 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
51760 if (err)
51761 return err;
51762
51763 + if (gr_handle_chroot_fowner(pid, type))
51764 + return -ENOENT;
51765 + if (gr_check_protected_task_fowner(pid, type))
51766 + return -EACCES;
51767 +
51768 f_modown(filp, pid, type, force);
51769 return 0;
51770 }
51771 diff --git a/fs/fhandle.c b/fs/fhandle.c
51772 index 999ff5c..41f4109 100644
51773 --- a/fs/fhandle.c
51774 +++ b/fs/fhandle.c
51775 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
51776 } else
51777 retval = 0;
51778 /* copy the mount id */
51779 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
51780 - sizeof(*mnt_id)) ||
51781 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
51782 copy_to_user(ufh, handle,
51783 sizeof(struct file_handle) + handle_bytes))
51784 retval = -EFAULT;
51785 diff --git a/fs/fifo.c b/fs/fifo.c
51786 index cf6f434..3d7942c 100644
51787 --- a/fs/fifo.c
51788 +++ b/fs/fifo.c
51789 @@ -59,10 +59,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
51790 */
51791 filp->f_op = &read_pipefifo_fops;
51792 pipe->r_counter++;
51793 - if (pipe->readers++ == 0)
51794 + if (atomic_inc_return(&pipe->readers) == 1)
51795 wake_up_partner(inode);
51796
51797 - if (!pipe->writers) {
51798 + if (!atomic_read(&pipe->writers)) {
51799 if ((filp->f_flags & O_NONBLOCK)) {
51800 /* suppress POLLHUP until we have
51801 * seen a writer */
51802 @@ -81,15 +81,15 @@ static int fifo_open(struct inode *inode, struct file *filp)
51803 * errno=ENXIO when there is no process reading the FIFO.
51804 */
51805 ret = -ENXIO;
51806 - if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
51807 + if ((filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
51808 goto err;
51809
51810 filp->f_op = &write_pipefifo_fops;
51811 pipe->w_counter++;
51812 - if (!pipe->writers++)
51813 + if (atomic_inc_return(&pipe->writers) == 1)
51814 wake_up_partner(inode);
51815
51816 - if (!pipe->readers) {
51817 + if (!atomic_read(&pipe->readers)) {
51818 if (wait_for_partner(inode, &pipe->r_counter))
51819 goto err_wr;
51820 }
51821 @@ -104,11 +104,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
51822 */
51823 filp->f_op = &rdwr_pipefifo_fops;
51824
51825 - pipe->readers++;
51826 - pipe->writers++;
51827 + atomic_inc(&pipe->readers);
51828 + atomic_inc(&pipe->writers);
51829 pipe->r_counter++;
51830 pipe->w_counter++;
51831 - if (pipe->readers == 1 || pipe->writers == 1)
51832 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
51833 wake_up_partner(inode);
51834 break;
51835
51836 @@ -122,19 +122,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
51837 return 0;
51838
51839 err_rd:
51840 - if (!--pipe->readers)
51841 + if (atomic_dec_and_test(&pipe->readers))
51842 wake_up_interruptible(&pipe->wait);
51843 ret = -ERESTARTSYS;
51844 goto err;
51845
51846 err_wr:
51847 - if (!--pipe->writers)
51848 + if (atomic_dec_and_test(&pipe->writers))
51849 wake_up_interruptible(&pipe->wait);
51850 ret = -ERESTARTSYS;
51851 goto err;
51852
51853 err:
51854 - if (!pipe->readers && !pipe->writers)
51855 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers))
51856 free_pipe_info(inode);
51857
51858 err_nocleanup:
51859 diff --git a/fs/file.c b/fs/file.c
51860 index 2b3570b..c57924b 100644
51861 --- a/fs/file.c
51862 +++ b/fs/file.c
51863 @@ -16,6 +16,7 @@
51864 #include <linux/slab.h>
51865 #include <linux/vmalloc.h>
51866 #include <linux/file.h>
51867 +#include <linux/security.h>
51868 #include <linux/fdtable.h>
51869 #include <linux/bitops.h>
51870 #include <linux/interrupt.h>
51871 @@ -892,6 +893,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
51872 if (!file)
51873 return __close_fd(files, fd);
51874
51875 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
51876 if (fd >= rlimit(RLIMIT_NOFILE))
51877 return -EBADF;
51878
51879 @@ -918,6 +920,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
51880 if (unlikely(oldfd == newfd))
51881 return -EINVAL;
51882
51883 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
51884 if (newfd >= rlimit(RLIMIT_NOFILE))
51885 return -EBADF;
51886
51887 @@ -973,6 +976,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
51888 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
51889 {
51890 int err;
51891 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
51892 if (from >= rlimit(RLIMIT_NOFILE))
51893 return -EINVAL;
51894 err = alloc_fd(from, flags);
51895 diff --git a/fs/filesystems.c b/fs/filesystems.c
51896 index da165f6..3671bdb 100644
51897 --- a/fs/filesystems.c
51898 +++ b/fs/filesystems.c
51899 @@ -273,7 +273,12 @@ struct file_system_type *get_fs_type(const char *name)
51900 int len = dot ? dot - name : strlen(name);
51901
51902 fs = __get_fs_type(name, len);
51903 +
51904 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
51905 + if (!fs && (___request_module(true, "grsec_modharden_fs", "%.*s", len, name) == 0))
51906 +#else
51907 if (!fs && (request_module("%.*s", len, name) == 0))
51908 +#endif
51909 fs = __get_fs_type(name, len);
51910
51911 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
51912 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
51913 index fe6ca58..65318cf 100644
51914 --- a/fs/fs_struct.c
51915 +++ b/fs/fs_struct.c
51916 @@ -4,6 +4,7 @@
51917 #include <linux/path.h>
51918 #include <linux/slab.h>
51919 #include <linux/fs_struct.h>
51920 +#include <linux/grsecurity.h>
51921 #include "internal.h"
51922
51923 /*
51924 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, struct path *path)
51925 write_seqcount_begin(&fs->seq);
51926 old_root = fs->root;
51927 fs->root = *path;
51928 + gr_set_chroot_entries(current, path);
51929 write_seqcount_end(&fs->seq);
51930 spin_unlock(&fs->lock);
51931 if (old_root.dentry)
51932 @@ -53,6 +55,21 @@ static inline int replace_path(struct path *p, const struct path *old, const str
51933 return 1;
51934 }
51935
51936 +static inline int replace_root_path(struct task_struct *task, struct path *p, const struct path *old, struct path *new)
51937 +{
51938 + if (likely(p->dentry != old->dentry || p->mnt != old->mnt))
51939 + return 0;
51940 + *p = *new;
51941 +
51942 + /* This function is only called from pivot_root(). Leave our
51943 + gr_chroot_dentry and is_chrooted flags as-is, so that a
51944 + pivoted root isn't treated as a chroot
51945 + */
51946 + //gr_set_chroot_entries(task, new);
51947 +
51948 + return 1;
51949 +}
51950 +
51951 void chroot_fs_refs(struct path *old_root, struct path *new_root)
51952 {
51953 struct task_struct *g, *p;
51954 @@ -67,7 +84,7 @@ void chroot_fs_refs(struct path *old_root, struct path *new_root)
51955 int hits = 0;
51956 spin_lock(&fs->lock);
51957 write_seqcount_begin(&fs->seq);
51958 - hits += replace_path(&fs->root, old_root, new_root);
51959 + hits += replace_root_path(p, &fs->root, old_root, new_root);
51960 hits += replace_path(&fs->pwd, old_root, new_root);
51961 write_seqcount_end(&fs->seq);
51962 while (hits--) {
51963 @@ -99,7 +116,8 @@ void exit_fs(struct task_struct *tsk)
51964 task_lock(tsk);
51965 spin_lock(&fs->lock);
51966 tsk->fs = NULL;
51967 - kill = !--fs->users;
51968 + gr_clear_chroot_entries(tsk);
51969 + kill = !atomic_dec_return(&fs->users);
51970 spin_unlock(&fs->lock);
51971 task_unlock(tsk);
51972 if (kill)
51973 @@ -112,7 +130,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51974 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
51975 /* We don't need to lock fs - think why ;-) */
51976 if (fs) {
51977 - fs->users = 1;
51978 + atomic_set(&fs->users, 1);
51979 fs->in_exec = 0;
51980 spin_lock_init(&fs->lock);
51981 seqcount_init(&fs->seq);
51982 @@ -121,6 +139,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51983 spin_lock(&old->lock);
51984 fs->root = old->root;
51985 path_get(&fs->root);
51986 + /* instead of calling gr_set_chroot_entries here,
51987 + we call it from every caller of this function
51988 + */
51989 fs->pwd = old->pwd;
51990 path_get(&fs->pwd);
51991 spin_unlock(&old->lock);
51992 @@ -139,8 +160,9 @@ int unshare_fs_struct(void)
51993
51994 task_lock(current);
51995 spin_lock(&fs->lock);
51996 - kill = !--fs->users;
51997 + kill = !atomic_dec_return(&fs->users);
51998 current->fs = new_fs;
51999 + gr_set_chroot_entries(current, &new_fs->root);
52000 spin_unlock(&fs->lock);
52001 task_unlock(current);
52002
52003 @@ -153,13 +175,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
52004
52005 int current_umask(void)
52006 {
52007 - return current->fs->umask;
52008 + return current->fs->umask | gr_acl_umask();
52009 }
52010 EXPORT_SYMBOL(current_umask);
52011
52012 /* to be mentioned only in INIT_TASK */
52013 struct fs_struct init_fs = {
52014 - .users = 1,
52015 + .users = ATOMIC_INIT(1),
52016 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
52017 .seq = SEQCNT_ZERO,
52018 .umask = 0022,
52019 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
52020 index 8dcb114..b1072e2 100644
52021 --- a/fs/fscache/cookie.c
52022 +++ b/fs/fscache/cookie.c
52023 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
52024 parent ? (char *) parent->def->name : "<no-parent>",
52025 def->name, netfs_data);
52026
52027 - fscache_stat(&fscache_n_acquires);
52028 + fscache_stat_unchecked(&fscache_n_acquires);
52029
52030 /* if there's no parent cookie, then we don't create one here either */
52031 if (!parent) {
52032 - fscache_stat(&fscache_n_acquires_null);
52033 + fscache_stat_unchecked(&fscache_n_acquires_null);
52034 _leave(" [no parent]");
52035 return NULL;
52036 }
52037 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
52038 /* allocate and initialise a cookie */
52039 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
52040 if (!cookie) {
52041 - fscache_stat(&fscache_n_acquires_oom);
52042 + fscache_stat_unchecked(&fscache_n_acquires_oom);
52043 _leave(" [ENOMEM]");
52044 return NULL;
52045 }
52046 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
52047
52048 switch (cookie->def->type) {
52049 case FSCACHE_COOKIE_TYPE_INDEX:
52050 - fscache_stat(&fscache_n_cookie_index);
52051 + fscache_stat_unchecked(&fscache_n_cookie_index);
52052 break;
52053 case FSCACHE_COOKIE_TYPE_DATAFILE:
52054 - fscache_stat(&fscache_n_cookie_data);
52055 + fscache_stat_unchecked(&fscache_n_cookie_data);
52056 break;
52057 default:
52058 - fscache_stat(&fscache_n_cookie_special);
52059 + fscache_stat_unchecked(&fscache_n_cookie_special);
52060 break;
52061 }
52062
52063 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
52064 if (fscache_acquire_non_index_cookie(cookie) < 0) {
52065 atomic_dec(&parent->n_children);
52066 __fscache_cookie_put(cookie);
52067 - fscache_stat(&fscache_n_acquires_nobufs);
52068 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
52069 _leave(" = NULL");
52070 return NULL;
52071 }
52072 }
52073
52074 - fscache_stat(&fscache_n_acquires_ok);
52075 + fscache_stat_unchecked(&fscache_n_acquires_ok);
52076 _leave(" = %p", cookie);
52077 return cookie;
52078 }
52079 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
52080 cache = fscache_select_cache_for_object(cookie->parent);
52081 if (!cache) {
52082 up_read(&fscache_addremove_sem);
52083 - fscache_stat(&fscache_n_acquires_no_cache);
52084 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
52085 _leave(" = -ENOMEDIUM [no cache]");
52086 return -ENOMEDIUM;
52087 }
52088 @@ -256,12 +256,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
52089 object = cache->ops->alloc_object(cache, cookie);
52090 fscache_stat_d(&fscache_n_cop_alloc_object);
52091 if (IS_ERR(object)) {
52092 - fscache_stat(&fscache_n_object_no_alloc);
52093 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
52094 ret = PTR_ERR(object);
52095 goto error;
52096 }
52097
52098 - fscache_stat(&fscache_n_object_alloc);
52099 + fscache_stat_unchecked(&fscache_n_object_alloc);
52100
52101 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
52102
52103 @@ -378,7 +378,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
52104
52105 _enter("{%s}", cookie->def->name);
52106
52107 - fscache_stat(&fscache_n_invalidates);
52108 + fscache_stat_unchecked(&fscache_n_invalidates);
52109
52110 /* Only permit invalidation of data files. Invalidating an index will
52111 * require the caller to release all its attachments to the tree rooted
52112 @@ -437,10 +437,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
52113 struct fscache_object *object;
52114 struct hlist_node *_p;
52115
52116 - fscache_stat(&fscache_n_updates);
52117 + fscache_stat_unchecked(&fscache_n_updates);
52118
52119 if (!cookie) {
52120 - fscache_stat(&fscache_n_updates_null);
52121 + fscache_stat_unchecked(&fscache_n_updates_null);
52122 _leave(" [no cookie]");
52123 return;
52124 }
52125 @@ -474,12 +474,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52126 struct fscache_object *object;
52127 unsigned long event;
52128
52129 - fscache_stat(&fscache_n_relinquishes);
52130 + fscache_stat_unchecked(&fscache_n_relinquishes);
52131 if (retire)
52132 - fscache_stat(&fscache_n_relinquishes_retire);
52133 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
52134
52135 if (!cookie) {
52136 - fscache_stat(&fscache_n_relinquishes_null);
52137 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
52138 _leave(" [no cookie]");
52139 return;
52140 }
52141 @@ -495,7 +495,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52142
52143 /* wait for the cookie to finish being instantiated (or to fail) */
52144 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
52145 - fscache_stat(&fscache_n_relinquishes_waitcrt);
52146 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
52147 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
52148 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
52149 }
52150 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
52151 index ee38fef..0a326d4 100644
52152 --- a/fs/fscache/internal.h
52153 +++ b/fs/fscache/internal.h
52154 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
52155 * stats.c
52156 */
52157 #ifdef CONFIG_FSCACHE_STATS
52158 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52159 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52160 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52161 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52162
52163 -extern atomic_t fscache_n_op_pend;
52164 -extern atomic_t fscache_n_op_run;
52165 -extern atomic_t fscache_n_op_enqueue;
52166 -extern atomic_t fscache_n_op_deferred_release;
52167 -extern atomic_t fscache_n_op_release;
52168 -extern atomic_t fscache_n_op_gc;
52169 -extern atomic_t fscache_n_op_cancelled;
52170 -extern atomic_t fscache_n_op_rejected;
52171 +extern atomic_unchecked_t fscache_n_op_pend;
52172 +extern atomic_unchecked_t fscache_n_op_run;
52173 +extern atomic_unchecked_t fscache_n_op_enqueue;
52174 +extern atomic_unchecked_t fscache_n_op_deferred_release;
52175 +extern atomic_unchecked_t fscache_n_op_release;
52176 +extern atomic_unchecked_t fscache_n_op_gc;
52177 +extern atomic_unchecked_t fscache_n_op_cancelled;
52178 +extern atomic_unchecked_t fscache_n_op_rejected;
52179
52180 -extern atomic_t fscache_n_attr_changed;
52181 -extern atomic_t fscache_n_attr_changed_ok;
52182 -extern atomic_t fscache_n_attr_changed_nobufs;
52183 -extern atomic_t fscache_n_attr_changed_nomem;
52184 -extern atomic_t fscache_n_attr_changed_calls;
52185 +extern atomic_unchecked_t fscache_n_attr_changed;
52186 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
52187 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
52188 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
52189 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
52190
52191 -extern atomic_t fscache_n_allocs;
52192 -extern atomic_t fscache_n_allocs_ok;
52193 -extern atomic_t fscache_n_allocs_wait;
52194 -extern atomic_t fscache_n_allocs_nobufs;
52195 -extern atomic_t fscache_n_allocs_intr;
52196 -extern atomic_t fscache_n_allocs_object_dead;
52197 -extern atomic_t fscache_n_alloc_ops;
52198 -extern atomic_t fscache_n_alloc_op_waits;
52199 +extern atomic_unchecked_t fscache_n_allocs;
52200 +extern atomic_unchecked_t fscache_n_allocs_ok;
52201 +extern atomic_unchecked_t fscache_n_allocs_wait;
52202 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
52203 +extern atomic_unchecked_t fscache_n_allocs_intr;
52204 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
52205 +extern atomic_unchecked_t fscache_n_alloc_ops;
52206 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
52207
52208 -extern atomic_t fscache_n_retrievals;
52209 -extern atomic_t fscache_n_retrievals_ok;
52210 -extern atomic_t fscache_n_retrievals_wait;
52211 -extern atomic_t fscache_n_retrievals_nodata;
52212 -extern atomic_t fscache_n_retrievals_nobufs;
52213 -extern atomic_t fscache_n_retrievals_intr;
52214 -extern atomic_t fscache_n_retrievals_nomem;
52215 -extern atomic_t fscache_n_retrievals_object_dead;
52216 -extern atomic_t fscache_n_retrieval_ops;
52217 -extern atomic_t fscache_n_retrieval_op_waits;
52218 +extern atomic_unchecked_t fscache_n_retrievals;
52219 +extern atomic_unchecked_t fscache_n_retrievals_ok;
52220 +extern atomic_unchecked_t fscache_n_retrievals_wait;
52221 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
52222 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
52223 +extern atomic_unchecked_t fscache_n_retrievals_intr;
52224 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
52225 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
52226 +extern atomic_unchecked_t fscache_n_retrieval_ops;
52227 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
52228
52229 -extern atomic_t fscache_n_stores;
52230 -extern atomic_t fscache_n_stores_ok;
52231 -extern atomic_t fscache_n_stores_again;
52232 -extern atomic_t fscache_n_stores_nobufs;
52233 -extern atomic_t fscache_n_stores_oom;
52234 -extern atomic_t fscache_n_store_ops;
52235 -extern atomic_t fscache_n_store_calls;
52236 -extern atomic_t fscache_n_store_pages;
52237 -extern atomic_t fscache_n_store_radix_deletes;
52238 -extern atomic_t fscache_n_store_pages_over_limit;
52239 +extern atomic_unchecked_t fscache_n_stores;
52240 +extern atomic_unchecked_t fscache_n_stores_ok;
52241 +extern atomic_unchecked_t fscache_n_stores_again;
52242 +extern atomic_unchecked_t fscache_n_stores_nobufs;
52243 +extern atomic_unchecked_t fscache_n_stores_oom;
52244 +extern atomic_unchecked_t fscache_n_store_ops;
52245 +extern atomic_unchecked_t fscache_n_store_calls;
52246 +extern atomic_unchecked_t fscache_n_store_pages;
52247 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
52248 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
52249
52250 -extern atomic_t fscache_n_store_vmscan_not_storing;
52251 -extern atomic_t fscache_n_store_vmscan_gone;
52252 -extern atomic_t fscache_n_store_vmscan_busy;
52253 -extern atomic_t fscache_n_store_vmscan_cancelled;
52254 -extern atomic_t fscache_n_store_vmscan_wait;
52255 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52256 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
52257 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
52258 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52259 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
52260
52261 -extern atomic_t fscache_n_marks;
52262 -extern atomic_t fscache_n_uncaches;
52263 +extern atomic_unchecked_t fscache_n_marks;
52264 +extern atomic_unchecked_t fscache_n_uncaches;
52265
52266 -extern atomic_t fscache_n_acquires;
52267 -extern atomic_t fscache_n_acquires_null;
52268 -extern atomic_t fscache_n_acquires_no_cache;
52269 -extern atomic_t fscache_n_acquires_ok;
52270 -extern atomic_t fscache_n_acquires_nobufs;
52271 -extern atomic_t fscache_n_acquires_oom;
52272 +extern atomic_unchecked_t fscache_n_acquires;
52273 +extern atomic_unchecked_t fscache_n_acquires_null;
52274 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
52275 +extern atomic_unchecked_t fscache_n_acquires_ok;
52276 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
52277 +extern atomic_unchecked_t fscache_n_acquires_oom;
52278
52279 -extern atomic_t fscache_n_invalidates;
52280 -extern atomic_t fscache_n_invalidates_run;
52281 +extern atomic_unchecked_t fscache_n_invalidates;
52282 +extern atomic_unchecked_t fscache_n_invalidates_run;
52283
52284 -extern atomic_t fscache_n_updates;
52285 -extern atomic_t fscache_n_updates_null;
52286 -extern atomic_t fscache_n_updates_run;
52287 +extern atomic_unchecked_t fscache_n_updates;
52288 +extern atomic_unchecked_t fscache_n_updates_null;
52289 +extern atomic_unchecked_t fscache_n_updates_run;
52290
52291 -extern atomic_t fscache_n_relinquishes;
52292 -extern atomic_t fscache_n_relinquishes_null;
52293 -extern atomic_t fscache_n_relinquishes_waitcrt;
52294 -extern atomic_t fscache_n_relinquishes_retire;
52295 +extern atomic_unchecked_t fscache_n_relinquishes;
52296 +extern atomic_unchecked_t fscache_n_relinquishes_null;
52297 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52298 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
52299
52300 -extern atomic_t fscache_n_cookie_index;
52301 -extern atomic_t fscache_n_cookie_data;
52302 -extern atomic_t fscache_n_cookie_special;
52303 +extern atomic_unchecked_t fscache_n_cookie_index;
52304 +extern atomic_unchecked_t fscache_n_cookie_data;
52305 +extern atomic_unchecked_t fscache_n_cookie_special;
52306
52307 -extern atomic_t fscache_n_object_alloc;
52308 -extern atomic_t fscache_n_object_no_alloc;
52309 -extern atomic_t fscache_n_object_lookups;
52310 -extern atomic_t fscache_n_object_lookups_negative;
52311 -extern atomic_t fscache_n_object_lookups_positive;
52312 -extern atomic_t fscache_n_object_lookups_timed_out;
52313 -extern atomic_t fscache_n_object_created;
52314 -extern atomic_t fscache_n_object_avail;
52315 -extern atomic_t fscache_n_object_dead;
52316 +extern atomic_unchecked_t fscache_n_object_alloc;
52317 +extern atomic_unchecked_t fscache_n_object_no_alloc;
52318 +extern atomic_unchecked_t fscache_n_object_lookups;
52319 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
52320 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
52321 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
52322 +extern atomic_unchecked_t fscache_n_object_created;
52323 +extern atomic_unchecked_t fscache_n_object_avail;
52324 +extern atomic_unchecked_t fscache_n_object_dead;
52325
52326 -extern atomic_t fscache_n_checkaux_none;
52327 -extern atomic_t fscache_n_checkaux_okay;
52328 -extern atomic_t fscache_n_checkaux_update;
52329 -extern atomic_t fscache_n_checkaux_obsolete;
52330 +extern atomic_unchecked_t fscache_n_checkaux_none;
52331 +extern atomic_unchecked_t fscache_n_checkaux_okay;
52332 +extern atomic_unchecked_t fscache_n_checkaux_update;
52333 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
52334
52335 extern atomic_t fscache_n_cop_alloc_object;
52336 extern atomic_t fscache_n_cop_lookup_object;
52337 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
52338 atomic_inc(stat);
52339 }
52340
52341 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
52342 +{
52343 + atomic_inc_unchecked(stat);
52344 +}
52345 +
52346 static inline void fscache_stat_d(atomic_t *stat)
52347 {
52348 atomic_dec(stat);
52349 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
52350
52351 #define __fscache_stat(stat) (NULL)
52352 #define fscache_stat(stat) do {} while (0)
52353 +#define fscache_stat_unchecked(stat) do {} while (0)
52354 #define fscache_stat_d(stat) do {} while (0)
52355 #endif
52356
52357 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
52358 index 50d41c1..10ee117 100644
52359 --- a/fs/fscache/object.c
52360 +++ b/fs/fscache/object.c
52361 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52362 /* Invalidate an object on disk */
52363 case FSCACHE_OBJECT_INVALIDATING:
52364 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
52365 - fscache_stat(&fscache_n_invalidates_run);
52366 + fscache_stat_unchecked(&fscache_n_invalidates_run);
52367 fscache_stat(&fscache_n_cop_invalidate_object);
52368 fscache_invalidate_object(object);
52369 fscache_stat_d(&fscache_n_cop_invalidate_object);
52370 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52371 /* update the object metadata on disk */
52372 case FSCACHE_OBJECT_UPDATING:
52373 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
52374 - fscache_stat(&fscache_n_updates_run);
52375 + fscache_stat_unchecked(&fscache_n_updates_run);
52376 fscache_stat(&fscache_n_cop_update_object);
52377 object->cache->ops->update_object(object);
52378 fscache_stat_d(&fscache_n_cop_update_object);
52379 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52380 spin_lock(&object->lock);
52381 object->state = FSCACHE_OBJECT_DEAD;
52382 spin_unlock(&object->lock);
52383 - fscache_stat(&fscache_n_object_dead);
52384 + fscache_stat_unchecked(&fscache_n_object_dead);
52385 goto terminal_transit;
52386
52387 /* handle the parent cache of this object being withdrawn from
52388 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52389 spin_lock(&object->lock);
52390 object->state = FSCACHE_OBJECT_DEAD;
52391 spin_unlock(&object->lock);
52392 - fscache_stat(&fscache_n_object_dead);
52393 + fscache_stat_unchecked(&fscache_n_object_dead);
52394 goto terminal_transit;
52395
52396 /* complain about the object being woken up once it is
52397 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52398 parent->cookie->def->name, cookie->def->name,
52399 object->cache->tag->name);
52400
52401 - fscache_stat(&fscache_n_object_lookups);
52402 + fscache_stat_unchecked(&fscache_n_object_lookups);
52403 fscache_stat(&fscache_n_cop_lookup_object);
52404 ret = object->cache->ops->lookup_object(object);
52405 fscache_stat_d(&fscache_n_cop_lookup_object);
52406 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52407 if (ret == -ETIMEDOUT) {
52408 /* probably stuck behind another object, so move this one to
52409 * the back of the queue */
52410 - fscache_stat(&fscache_n_object_lookups_timed_out);
52411 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
52412 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52413 }
52414
52415 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
52416
52417 spin_lock(&object->lock);
52418 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52419 - fscache_stat(&fscache_n_object_lookups_negative);
52420 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
52421
52422 /* transit here to allow write requests to begin stacking up
52423 * and read requests to begin returning ENODATA */
52424 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
52425 * result, in which case there may be data available */
52426 spin_lock(&object->lock);
52427 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52428 - fscache_stat(&fscache_n_object_lookups_positive);
52429 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
52430
52431 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
52432
52433 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
52434 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52435 } else {
52436 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
52437 - fscache_stat(&fscache_n_object_created);
52438 + fscache_stat_unchecked(&fscache_n_object_created);
52439
52440 object->state = FSCACHE_OBJECT_AVAILABLE;
52441 spin_unlock(&object->lock);
52442 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
52443 fscache_enqueue_dependents(object);
52444
52445 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
52446 - fscache_stat(&fscache_n_object_avail);
52447 + fscache_stat_unchecked(&fscache_n_object_avail);
52448
52449 _leave("");
52450 }
52451 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52452 enum fscache_checkaux result;
52453
52454 if (!object->cookie->def->check_aux) {
52455 - fscache_stat(&fscache_n_checkaux_none);
52456 + fscache_stat_unchecked(&fscache_n_checkaux_none);
52457 return FSCACHE_CHECKAUX_OKAY;
52458 }
52459
52460 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52461 switch (result) {
52462 /* entry okay as is */
52463 case FSCACHE_CHECKAUX_OKAY:
52464 - fscache_stat(&fscache_n_checkaux_okay);
52465 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
52466 break;
52467
52468 /* entry requires update */
52469 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
52470 - fscache_stat(&fscache_n_checkaux_update);
52471 + fscache_stat_unchecked(&fscache_n_checkaux_update);
52472 break;
52473
52474 /* entry requires deletion */
52475 case FSCACHE_CHECKAUX_OBSOLETE:
52476 - fscache_stat(&fscache_n_checkaux_obsolete);
52477 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
52478 break;
52479
52480 default:
52481 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
52482 index 762a9ec..2023284 100644
52483 --- a/fs/fscache/operation.c
52484 +++ b/fs/fscache/operation.c
52485 @@ -17,7 +17,7 @@
52486 #include <linux/slab.h>
52487 #include "internal.h"
52488
52489 -atomic_t fscache_op_debug_id;
52490 +atomic_unchecked_t fscache_op_debug_id;
52491 EXPORT_SYMBOL(fscache_op_debug_id);
52492
52493 /**
52494 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
52495 ASSERTCMP(atomic_read(&op->usage), >, 0);
52496 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
52497
52498 - fscache_stat(&fscache_n_op_enqueue);
52499 + fscache_stat_unchecked(&fscache_n_op_enqueue);
52500 switch (op->flags & FSCACHE_OP_TYPE) {
52501 case FSCACHE_OP_ASYNC:
52502 _debug("queue async");
52503 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
52504 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
52505 if (op->processor)
52506 fscache_enqueue_operation(op);
52507 - fscache_stat(&fscache_n_op_run);
52508 + fscache_stat_unchecked(&fscache_n_op_run);
52509 }
52510
52511 /*
52512 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52513 if (object->n_in_progress > 0) {
52514 atomic_inc(&op->usage);
52515 list_add_tail(&op->pend_link, &object->pending_ops);
52516 - fscache_stat(&fscache_n_op_pend);
52517 + fscache_stat_unchecked(&fscache_n_op_pend);
52518 } else if (!list_empty(&object->pending_ops)) {
52519 atomic_inc(&op->usage);
52520 list_add_tail(&op->pend_link, &object->pending_ops);
52521 - fscache_stat(&fscache_n_op_pend);
52522 + fscache_stat_unchecked(&fscache_n_op_pend);
52523 fscache_start_operations(object);
52524 } else {
52525 ASSERTCMP(object->n_in_progress, ==, 0);
52526 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52527 object->n_exclusive++; /* reads and writes must wait */
52528 atomic_inc(&op->usage);
52529 list_add_tail(&op->pend_link, &object->pending_ops);
52530 - fscache_stat(&fscache_n_op_pend);
52531 + fscache_stat_unchecked(&fscache_n_op_pend);
52532 ret = 0;
52533 } else {
52534 /* If we're in any other state, there must have been an I/O
52535 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
52536 if (object->n_exclusive > 0) {
52537 atomic_inc(&op->usage);
52538 list_add_tail(&op->pend_link, &object->pending_ops);
52539 - fscache_stat(&fscache_n_op_pend);
52540 + fscache_stat_unchecked(&fscache_n_op_pend);
52541 } else if (!list_empty(&object->pending_ops)) {
52542 atomic_inc(&op->usage);
52543 list_add_tail(&op->pend_link, &object->pending_ops);
52544 - fscache_stat(&fscache_n_op_pend);
52545 + fscache_stat_unchecked(&fscache_n_op_pend);
52546 fscache_start_operations(object);
52547 } else {
52548 ASSERTCMP(object->n_exclusive, ==, 0);
52549 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
52550 object->n_ops++;
52551 atomic_inc(&op->usage);
52552 list_add_tail(&op->pend_link, &object->pending_ops);
52553 - fscache_stat(&fscache_n_op_pend);
52554 + fscache_stat_unchecked(&fscache_n_op_pend);
52555 ret = 0;
52556 } else if (object->state == FSCACHE_OBJECT_DYING ||
52557 object->state == FSCACHE_OBJECT_LC_DYING ||
52558 object->state == FSCACHE_OBJECT_WITHDRAWING) {
52559 - fscache_stat(&fscache_n_op_rejected);
52560 + fscache_stat_unchecked(&fscache_n_op_rejected);
52561 op->state = FSCACHE_OP_ST_CANCELLED;
52562 ret = -ENOBUFS;
52563 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
52564 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
52565 ret = -EBUSY;
52566 if (op->state == FSCACHE_OP_ST_PENDING) {
52567 ASSERT(!list_empty(&op->pend_link));
52568 - fscache_stat(&fscache_n_op_cancelled);
52569 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52570 list_del_init(&op->pend_link);
52571 if (do_cancel)
52572 do_cancel(op);
52573 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
52574 while (!list_empty(&object->pending_ops)) {
52575 op = list_entry(object->pending_ops.next,
52576 struct fscache_operation, pend_link);
52577 - fscache_stat(&fscache_n_op_cancelled);
52578 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52579 list_del_init(&op->pend_link);
52580
52581 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
52582 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
52583 op->state, ==, FSCACHE_OP_ST_CANCELLED);
52584 op->state = FSCACHE_OP_ST_DEAD;
52585
52586 - fscache_stat(&fscache_n_op_release);
52587 + fscache_stat_unchecked(&fscache_n_op_release);
52588
52589 if (op->release) {
52590 op->release(op);
52591 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
52592 * lock, and defer it otherwise */
52593 if (!spin_trylock(&object->lock)) {
52594 _debug("defer put");
52595 - fscache_stat(&fscache_n_op_deferred_release);
52596 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
52597
52598 cache = object->cache;
52599 spin_lock(&cache->op_gc_list_lock);
52600 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
52601
52602 _debug("GC DEFERRED REL OBJ%x OP%x",
52603 object->debug_id, op->debug_id);
52604 - fscache_stat(&fscache_n_op_gc);
52605 + fscache_stat_unchecked(&fscache_n_op_gc);
52606
52607 ASSERTCMP(atomic_read(&op->usage), ==, 0);
52608 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
52609 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
52610 index ff000e5..c44ec6d 100644
52611 --- a/fs/fscache/page.c
52612 +++ b/fs/fscache/page.c
52613 @@ -61,7 +61,7 @@ try_again:
52614 val = radix_tree_lookup(&cookie->stores, page->index);
52615 if (!val) {
52616 rcu_read_unlock();
52617 - fscache_stat(&fscache_n_store_vmscan_not_storing);
52618 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
52619 __fscache_uncache_page(cookie, page);
52620 return true;
52621 }
52622 @@ -91,11 +91,11 @@ try_again:
52623 spin_unlock(&cookie->stores_lock);
52624
52625 if (xpage) {
52626 - fscache_stat(&fscache_n_store_vmscan_cancelled);
52627 - fscache_stat(&fscache_n_store_radix_deletes);
52628 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
52629 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52630 ASSERTCMP(xpage, ==, page);
52631 } else {
52632 - fscache_stat(&fscache_n_store_vmscan_gone);
52633 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
52634 }
52635
52636 wake_up_bit(&cookie->flags, 0);
52637 @@ -110,11 +110,11 @@ page_busy:
52638 * sleeping on memory allocation, so we may need to impose a timeout
52639 * too. */
52640 if (!(gfp & __GFP_WAIT)) {
52641 - fscache_stat(&fscache_n_store_vmscan_busy);
52642 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
52643 return false;
52644 }
52645
52646 - fscache_stat(&fscache_n_store_vmscan_wait);
52647 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
52648 __fscache_wait_on_page_write(cookie, page);
52649 gfp &= ~__GFP_WAIT;
52650 goto try_again;
52651 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
52652 FSCACHE_COOKIE_STORING_TAG);
52653 if (!radix_tree_tag_get(&cookie->stores, page->index,
52654 FSCACHE_COOKIE_PENDING_TAG)) {
52655 - fscache_stat(&fscache_n_store_radix_deletes);
52656 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52657 xpage = radix_tree_delete(&cookie->stores, page->index);
52658 }
52659 spin_unlock(&cookie->stores_lock);
52660 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
52661
52662 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
52663
52664 - fscache_stat(&fscache_n_attr_changed_calls);
52665 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
52666
52667 if (fscache_object_is_active(object)) {
52668 fscache_stat(&fscache_n_cop_attr_changed);
52669 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52670
52671 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52672
52673 - fscache_stat(&fscache_n_attr_changed);
52674 + fscache_stat_unchecked(&fscache_n_attr_changed);
52675
52676 op = kzalloc(sizeof(*op), GFP_KERNEL);
52677 if (!op) {
52678 - fscache_stat(&fscache_n_attr_changed_nomem);
52679 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
52680 _leave(" = -ENOMEM");
52681 return -ENOMEM;
52682 }
52683 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52684 if (fscache_submit_exclusive_op(object, op) < 0)
52685 goto nobufs;
52686 spin_unlock(&cookie->lock);
52687 - fscache_stat(&fscache_n_attr_changed_ok);
52688 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
52689 fscache_put_operation(op);
52690 _leave(" = 0");
52691 return 0;
52692 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52693 nobufs:
52694 spin_unlock(&cookie->lock);
52695 kfree(op);
52696 - fscache_stat(&fscache_n_attr_changed_nobufs);
52697 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
52698 _leave(" = %d", -ENOBUFS);
52699 return -ENOBUFS;
52700 }
52701 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
52702 /* allocate a retrieval operation and attempt to submit it */
52703 op = kzalloc(sizeof(*op), GFP_NOIO);
52704 if (!op) {
52705 - fscache_stat(&fscache_n_retrievals_nomem);
52706 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52707 return NULL;
52708 }
52709
52710 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
52711 return 0;
52712 }
52713
52714 - fscache_stat(&fscache_n_retrievals_wait);
52715 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
52716
52717 jif = jiffies;
52718 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
52719 fscache_wait_bit_interruptible,
52720 TASK_INTERRUPTIBLE) != 0) {
52721 - fscache_stat(&fscache_n_retrievals_intr);
52722 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52723 _leave(" = -ERESTARTSYS");
52724 return -ERESTARTSYS;
52725 }
52726 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
52727 */
52728 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52729 struct fscache_retrieval *op,
52730 - atomic_t *stat_op_waits,
52731 - atomic_t *stat_object_dead)
52732 + atomic_unchecked_t *stat_op_waits,
52733 + atomic_unchecked_t *stat_object_dead)
52734 {
52735 int ret;
52736
52737 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52738 goto check_if_dead;
52739
52740 _debug(">>> WT");
52741 - fscache_stat(stat_op_waits);
52742 + fscache_stat_unchecked(stat_op_waits);
52743 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
52744 fscache_wait_bit_interruptible,
52745 TASK_INTERRUPTIBLE) != 0) {
52746 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52747
52748 check_if_dead:
52749 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
52750 - fscache_stat(stat_object_dead);
52751 + fscache_stat_unchecked(stat_object_dead);
52752 _leave(" = -ENOBUFS [cancelled]");
52753 return -ENOBUFS;
52754 }
52755 if (unlikely(fscache_object_is_dead(object))) {
52756 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
52757 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
52758 - fscache_stat(stat_object_dead);
52759 + fscache_stat_unchecked(stat_object_dead);
52760 return -ENOBUFS;
52761 }
52762 return 0;
52763 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52764
52765 _enter("%p,%p,,,", cookie, page);
52766
52767 - fscache_stat(&fscache_n_retrievals);
52768 + fscache_stat_unchecked(&fscache_n_retrievals);
52769
52770 if (hlist_empty(&cookie->backing_objects))
52771 goto nobufs;
52772 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52773 goto nobufs_unlock_dec;
52774 spin_unlock(&cookie->lock);
52775
52776 - fscache_stat(&fscache_n_retrieval_ops);
52777 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52778
52779 /* pin the netfs read context in case we need to do the actual netfs
52780 * read because we've encountered a cache read failure */
52781 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52782
52783 error:
52784 if (ret == -ENOMEM)
52785 - fscache_stat(&fscache_n_retrievals_nomem);
52786 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52787 else if (ret == -ERESTARTSYS)
52788 - fscache_stat(&fscache_n_retrievals_intr);
52789 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52790 else if (ret == -ENODATA)
52791 - fscache_stat(&fscache_n_retrievals_nodata);
52792 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52793 else if (ret < 0)
52794 - fscache_stat(&fscache_n_retrievals_nobufs);
52795 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52796 else
52797 - fscache_stat(&fscache_n_retrievals_ok);
52798 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52799
52800 fscache_put_retrieval(op);
52801 _leave(" = %d", ret);
52802 @@ -467,7 +467,7 @@ nobufs_unlock:
52803 spin_unlock(&cookie->lock);
52804 kfree(op);
52805 nobufs:
52806 - fscache_stat(&fscache_n_retrievals_nobufs);
52807 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52808 _leave(" = -ENOBUFS");
52809 return -ENOBUFS;
52810 }
52811 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52812
52813 _enter("%p,,%d,,,", cookie, *nr_pages);
52814
52815 - fscache_stat(&fscache_n_retrievals);
52816 + fscache_stat_unchecked(&fscache_n_retrievals);
52817
52818 if (hlist_empty(&cookie->backing_objects))
52819 goto nobufs;
52820 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52821 goto nobufs_unlock_dec;
52822 spin_unlock(&cookie->lock);
52823
52824 - fscache_stat(&fscache_n_retrieval_ops);
52825 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52826
52827 /* pin the netfs read context in case we need to do the actual netfs
52828 * read because we've encountered a cache read failure */
52829 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52830
52831 error:
52832 if (ret == -ENOMEM)
52833 - fscache_stat(&fscache_n_retrievals_nomem);
52834 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52835 else if (ret == -ERESTARTSYS)
52836 - fscache_stat(&fscache_n_retrievals_intr);
52837 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52838 else if (ret == -ENODATA)
52839 - fscache_stat(&fscache_n_retrievals_nodata);
52840 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52841 else if (ret < 0)
52842 - fscache_stat(&fscache_n_retrievals_nobufs);
52843 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52844 else
52845 - fscache_stat(&fscache_n_retrievals_ok);
52846 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52847
52848 fscache_put_retrieval(op);
52849 _leave(" = %d", ret);
52850 @@ -591,7 +591,7 @@ nobufs_unlock:
52851 spin_unlock(&cookie->lock);
52852 kfree(op);
52853 nobufs:
52854 - fscache_stat(&fscache_n_retrievals_nobufs);
52855 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52856 _leave(" = -ENOBUFS");
52857 return -ENOBUFS;
52858 }
52859 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52860
52861 _enter("%p,%p,,,", cookie, page);
52862
52863 - fscache_stat(&fscache_n_allocs);
52864 + fscache_stat_unchecked(&fscache_n_allocs);
52865
52866 if (hlist_empty(&cookie->backing_objects))
52867 goto nobufs;
52868 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52869 goto nobufs_unlock;
52870 spin_unlock(&cookie->lock);
52871
52872 - fscache_stat(&fscache_n_alloc_ops);
52873 + fscache_stat_unchecked(&fscache_n_alloc_ops);
52874
52875 ret = fscache_wait_for_retrieval_activation(
52876 object, op,
52877 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52878
52879 error:
52880 if (ret == -ERESTARTSYS)
52881 - fscache_stat(&fscache_n_allocs_intr);
52882 + fscache_stat_unchecked(&fscache_n_allocs_intr);
52883 else if (ret < 0)
52884 - fscache_stat(&fscache_n_allocs_nobufs);
52885 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52886 else
52887 - fscache_stat(&fscache_n_allocs_ok);
52888 + fscache_stat_unchecked(&fscache_n_allocs_ok);
52889
52890 fscache_put_retrieval(op);
52891 _leave(" = %d", ret);
52892 @@ -677,7 +677,7 @@ nobufs_unlock:
52893 spin_unlock(&cookie->lock);
52894 kfree(op);
52895 nobufs:
52896 - fscache_stat(&fscache_n_allocs_nobufs);
52897 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52898 _leave(" = -ENOBUFS");
52899 return -ENOBUFS;
52900 }
52901 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52902
52903 spin_lock(&cookie->stores_lock);
52904
52905 - fscache_stat(&fscache_n_store_calls);
52906 + fscache_stat_unchecked(&fscache_n_store_calls);
52907
52908 /* find a page to store */
52909 page = NULL;
52910 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52911 page = results[0];
52912 _debug("gang %d [%lx]", n, page->index);
52913 if (page->index > op->store_limit) {
52914 - fscache_stat(&fscache_n_store_pages_over_limit);
52915 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
52916 goto superseded;
52917 }
52918
52919 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52920 spin_unlock(&cookie->stores_lock);
52921 spin_unlock(&object->lock);
52922
52923 - fscache_stat(&fscache_n_store_pages);
52924 + fscache_stat_unchecked(&fscache_n_store_pages);
52925 fscache_stat(&fscache_n_cop_write_page);
52926 ret = object->cache->ops->write_page(op, page);
52927 fscache_stat_d(&fscache_n_cop_write_page);
52928 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52929 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52930 ASSERT(PageFsCache(page));
52931
52932 - fscache_stat(&fscache_n_stores);
52933 + fscache_stat_unchecked(&fscache_n_stores);
52934
52935 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
52936 _leave(" = -ENOBUFS [invalidating]");
52937 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52938 spin_unlock(&cookie->stores_lock);
52939 spin_unlock(&object->lock);
52940
52941 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
52942 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
52943 op->store_limit = object->store_limit;
52944
52945 if (fscache_submit_op(object, &op->op) < 0)
52946 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52947
52948 spin_unlock(&cookie->lock);
52949 radix_tree_preload_end();
52950 - fscache_stat(&fscache_n_store_ops);
52951 - fscache_stat(&fscache_n_stores_ok);
52952 + fscache_stat_unchecked(&fscache_n_store_ops);
52953 + fscache_stat_unchecked(&fscache_n_stores_ok);
52954
52955 /* the work queue now carries its own ref on the object */
52956 fscache_put_operation(&op->op);
52957 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52958 return 0;
52959
52960 already_queued:
52961 - fscache_stat(&fscache_n_stores_again);
52962 + fscache_stat_unchecked(&fscache_n_stores_again);
52963 already_pending:
52964 spin_unlock(&cookie->stores_lock);
52965 spin_unlock(&object->lock);
52966 spin_unlock(&cookie->lock);
52967 radix_tree_preload_end();
52968 kfree(op);
52969 - fscache_stat(&fscache_n_stores_ok);
52970 + fscache_stat_unchecked(&fscache_n_stores_ok);
52971 _leave(" = 0");
52972 return 0;
52973
52974 @@ -959,14 +959,14 @@ nobufs:
52975 spin_unlock(&cookie->lock);
52976 radix_tree_preload_end();
52977 kfree(op);
52978 - fscache_stat(&fscache_n_stores_nobufs);
52979 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
52980 _leave(" = -ENOBUFS");
52981 return -ENOBUFS;
52982
52983 nomem_free:
52984 kfree(op);
52985 nomem:
52986 - fscache_stat(&fscache_n_stores_oom);
52987 + fscache_stat_unchecked(&fscache_n_stores_oom);
52988 _leave(" = -ENOMEM");
52989 return -ENOMEM;
52990 }
52991 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
52992 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52993 ASSERTCMP(page, !=, NULL);
52994
52995 - fscache_stat(&fscache_n_uncaches);
52996 + fscache_stat_unchecked(&fscache_n_uncaches);
52997
52998 /* cache withdrawal may beat us to it */
52999 if (!PageFsCache(page))
53000 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
53001 struct fscache_cookie *cookie = op->op.object->cookie;
53002
53003 #ifdef CONFIG_FSCACHE_STATS
53004 - atomic_inc(&fscache_n_marks);
53005 + atomic_inc_unchecked(&fscache_n_marks);
53006 #endif
53007
53008 _debug("- mark %p{%lx}", page, page->index);
53009 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
53010 index 8179e8b..5072cc7 100644
53011 --- a/fs/fscache/stats.c
53012 +++ b/fs/fscache/stats.c
53013 @@ -18,99 +18,99 @@
53014 /*
53015 * operation counters
53016 */
53017 -atomic_t fscache_n_op_pend;
53018 -atomic_t fscache_n_op_run;
53019 -atomic_t fscache_n_op_enqueue;
53020 -atomic_t fscache_n_op_requeue;
53021 -atomic_t fscache_n_op_deferred_release;
53022 -atomic_t fscache_n_op_release;
53023 -atomic_t fscache_n_op_gc;
53024 -atomic_t fscache_n_op_cancelled;
53025 -atomic_t fscache_n_op_rejected;
53026 +atomic_unchecked_t fscache_n_op_pend;
53027 +atomic_unchecked_t fscache_n_op_run;
53028 +atomic_unchecked_t fscache_n_op_enqueue;
53029 +atomic_unchecked_t fscache_n_op_requeue;
53030 +atomic_unchecked_t fscache_n_op_deferred_release;
53031 +atomic_unchecked_t fscache_n_op_release;
53032 +atomic_unchecked_t fscache_n_op_gc;
53033 +atomic_unchecked_t fscache_n_op_cancelled;
53034 +atomic_unchecked_t fscache_n_op_rejected;
53035
53036 -atomic_t fscache_n_attr_changed;
53037 -atomic_t fscache_n_attr_changed_ok;
53038 -atomic_t fscache_n_attr_changed_nobufs;
53039 -atomic_t fscache_n_attr_changed_nomem;
53040 -atomic_t fscache_n_attr_changed_calls;
53041 +atomic_unchecked_t fscache_n_attr_changed;
53042 +atomic_unchecked_t fscache_n_attr_changed_ok;
53043 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
53044 +atomic_unchecked_t fscache_n_attr_changed_nomem;
53045 +atomic_unchecked_t fscache_n_attr_changed_calls;
53046
53047 -atomic_t fscache_n_allocs;
53048 -atomic_t fscache_n_allocs_ok;
53049 -atomic_t fscache_n_allocs_wait;
53050 -atomic_t fscache_n_allocs_nobufs;
53051 -atomic_t fscache_n_allocs_intr;
53052 -atomic_t fscache_n_allocs_object_dead;
53053 -atomic_t fscache_n_alloc_ops;
53054 -atomic_t fscache_n_alloc_op_waits;
53055 +atomic_unchecked_t fscache_n_allocs;
53056 +atomic_unchecked_t fscache_n_allocs_ok;
53057 +atomic_unchecked_t fscache_n_allocs_wait;
53058 +atomic_unchecked_t fscache_n_allocs_nobufs;
53059 +atomic_unchecked_t fscache_n_allocs_intr;
53060 +atomic_unchecked_t fscache_n_allocs_object_dead;
53061 +atomic_unchecked_t fscache_n_alloc_ops;
53062 +atomic_unchecked_t fscache_n_alloc_op_waits;
53063
53064 -atomic_t fscache_n_retrievals;
53065 -atomic_t fscache_n_retrievals_ok;
53066 -atomic_t fscache_n_retrievals_wait;
53067 -atomic_t fscache_n_retrievals_nodata;
53068 -atomic_t fscache_n_retrievals_nobufs;
53069 -atomic_t fscache_n_retrievals_intr;
53070 -atomic_t fscache_n_retrievals_nomem;
53071 -atomic_t fscache_n_retrievals_object_dead;
53072 -atomic_t fscache_n_retrieval_ops;
53073 -atomic_t fscache_n_retrieval_op_waits;
53074 +atomic_unchecked_t fscache_n_retrievals;
53075 +atomic_unchecked_t fscache_n_retrievals_ok;
53076 +atomic_unchecked_t fscache_n_retrievals_wait;
53077 +atomic_unchecked_t fscache_n_retrievals_nodata;
53078 +atomic_unchecked_t fscache_n_retrievals_nobufs;
53079 +atomic_unchecked_t fscache_n_retrievals_intr;
53080 +atomic_unchecked_t fscache_n_retrievals_nomem;
53081 +atomic_unchecked_t fscache_n_retrievals_object_dead;
53082 +atomic_unchecked_t fscache_n_retrieval_ops;
53083 +atomic_unchecked_t fscache_n_retrieval_op_waits;
53084
53085 -atomic_t fscache_n_stores;
53086 -atomic_t fscache_n_stores_ok;
53087 -atomic_t fscache_n_stores_again;
53088 -atomic_t fscache_n_stores_nobufs;
53089 -atomic_t fscache_n_stores_oom;
53090 -atomic_t fscache_n_store_ops;
53091 -atomic_t fscache_n_store_calls;
53092 -atomic_t fscache_n_store_pages;
53093 -atomic_t fscache_n_store_radix_deletes;
53094 -atomic_t fscache_n_store_pages_over_limit;
53095 +atomic_unchecked_t fscache_n_stores;
53096 +atomic_unchecked_t fscache_n_stores_ok;
53097 +atomic_unchecked_t fscache_n_stores_again;
53098 +atomic_unchecked_t fscache_n_stores_nobufs;
53099 +atomic_unchecked_t fscache_n_stores_oom;
53100 +atomic_unchecked_t fscache_n_store_ops;
53101 +atomic_unchecked_t fscache_n_store_calls;
53102 +atomic_unchecked_t fscache_n_store_pages;
53103 +atomic_unchecked_t fscache_n_store_radix_deletes;
53104 +atomic_unchecked_t fscache_n_store_pages_over_limit;
53105
53106 -atomic_t fscache_n_store_vmscan_not_storing;
53107 -atomic_t fscache_n_store_vmscan_gone;
53108 -atomic_t fscache_n_store_vmscan_busy;
53109 -atomic_t fscache_n_store_vmscan_cancelled;
53110 -atomic_t fscache_n_store_vmscan_wait;
53111 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
53112 +atomic_unchecked_t fscache_n_store_vmscan_gone;
53113 +atomic_unchecked_t fscache_n_store_vmscan_busy;
53114 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
53115 +atomic_unchecked_t fscache_n_store_vmscan_wait;
53116
53117 -atomic_t fscache_n_marks;
53118 -atomic_t fscache_n_uncaches;
53119 +atomic_unchecked_t fscache_n_marks;
53120 +atomic_unchecked_t fscache_n_uncaches;
53121
53122 -atomic_t fscache_n_acquires;
53123 -atomic_t fscache_n_acquires_null;
53124 -atomic_t fscache_n_acquires_no_cache;
53125 -atomic_t fscache_n_acquires_ok;
53126 -atomic_t fscache_n_acquires_nobufs;
53127 -atomic_t fscache_n_acquires_oom;
53128 +atomic_unchecked_t fscache_n_acquires;
53129 +atomic_unchecked_t fscache_n_acquires_null;
53130 +atomic_unchecked_t fscache_n_acquires_no_cache;
53131 +atomic_unchecked_t fscache_n_acquires_ok;
53132 +atomic_unchecked_t fscache_n_acquires_nobufs;
53133 +atomic_unchecked_t fscache_n_acquires_oom;
53134
53135 -atomic_t fscache_n_invalidates;
53136 -atomic_t fscache_n_invalidates_run;
53137 +atomic_unchecked_t fscache_n_invalidates;
53138 +atomic_unchecked_t fscache_n_invalidates_run;
53139
53140 -atomic_t fscache_n_updates;
53141 -atomic_t fscache_n_updates_null;
53142 -atomic_t fscache_n_updates_run;
53143 +atomic_unchecked_t fscache_n_updates;
53144 +atomic_unchecked_t fscache_n_updates_null;
53145 +atomic_unchecked_t fscache_n_updates_run;
53146
53147 -atomic_t fscache_n_relinquishes;
53148 -atomic_t fscache_n_relinquishes_null;
53149 -atomic_t fscache_n_relinquishes_waitcrt;
53150 -atomic_t fscache_n_relinquishes_retire;
53151 +atomic_unchecked_t fscache_n_relinquishes;
53152 +atomic_unchecked_t fscache_n_relinquishes_null;
53153 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
53154 +atomic_unchecked_t fscache_n_relinquishes_retire;
53155
53156 -atomic_t fscache_n_cookie_index;
53157 -atomic_t fscache_n_cookie_data;
53158 -atomic_t fscache_n_cookie_special;
53159 +atomic_unchecked_t fscache_n_cookie_index;
53160 +atomic_unchecked_t fscache_n_cookie_data;
53161 +atomic_unchecked_t fscache_n_cookie_special;
53162
53163 -atomic_t fscache_n_object_alloc;
53164 -atomic_t fscache_n_object_no_alloc;
53165 -atomic_t fscache_n_object_lookups;
53166 -atomic_t fscache_n_object_lookups_negative;
53167 -atomic_t fscache_n_object_lookups_positive;
53168 -atomic_t fscache_n_object_lookups_timed_out;
53169 -atomic_t fscache_n_object_created;
53170 -atomic_t fscache_n_object_avail;
53171 -atomic_t fscache_n_object_dead;
53172 +atomic_unchecked_t fscache_n_object_alloc;
53173 +atomic_unchecked_t fscache_n_object_no_alloc;
53174 +atomic_unchecked_t fscache_n_object_lookups;
53175 +atomic_unchecked_t fscache_n_object_lookups_negative;
53176 +atomic_unchecked_t fscache_n_object_lookups_positive;
53177 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
53178 +atomic_unchecked_t fscache_n_object_created;
53179 +atomic_unchecked_t fscache_n_object_avail;
53180 +atomic_unchecked_t fscache_n_object_dead;
53181
53182 -atomic_t fscache_n_checkaux_none;
53183 -atomic_t fscache_n_checkaux_okay;
53184 -atomic_t fscache_n_checkaux_update;
53185 -atomic_t fscache_n_checkaux_obsolete;
53186 +atomic_unchecked_t fscache_n_checkaux_none;
53187 +atomic_unchecked_t fscache_n_checkaux_okay;
53188 +atomic_unchecked_t fscache_n_checkaux_update;
53189 +atomic_unchecked_t fscache_n_checkaux_obsolete;
53190
53191 atomic_t fscache_n_cop_alloc_object;
53192 atomic_t fscache_n_cop_lookup_object;
53193 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
53194 seq_puts(m, "FS-Cache statistics\n");
53195
53196 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
53197 - atomic_read(&fscache_n_cookie_index),
53198 - atomic_read(&fscache_n_cookie_data),
53199 - atomic_read(&fscache_n_cookie_special));
53200 + atomic_read_unchecked(&fscache_n_cookie_index),
53201 + atomic_read_unchecked(&fscache_n_cookie_data),
53202 + atomic_read_unchecked(&fscache_n_cookie_special));
53203
53204 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
53205 - atomic_read(&fscache_n_object_alloc),
53206 - atomic_read(&fscache_n_object_no_alloc),
53207 - atomic_read(&fscache_n_object_avail),
53208 - atomic_read(&fscache_n_object_dead));
53209 + atomic_read_unchecked(&fscache_n_object_alloc),
53210 + atomic_read_unchecked(&fscache_n_object_no_alloc),
53211 + atomic_read_unchecked(&fscache_n_object_avail),
53212 + atomic_read_unchecked(&fscache_n_object_dead));
53213 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
53214 - atomic_read(&fscache_n_checkaux_none),
53215 - atomic_read(&fscache_n_checkaux_okay),
53216 - atomic_read(&fscache_n_checkaux_update),
53217 - atomic_read(&fscache_n_checkaux_obsolete));
53218 + atomic_read_unchecked(&fscache_n_checkaux_none),
53219 + atomic_read_unchecked(&fscache_n_checkaux_okay),
53220 + atomic_read_unchecked(&fscache_n_checkaux_update),
53221 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
53222
53223 seq_printf(m, "Pages : mrk=%u unc=%u\n",
53224 - atomic_read(&fscache_n_marks),
53225 - atomic_read(&fscache_n_uncaches));
53226 + atomic_read_unchecked(&fscache_n_marks),
53227 + atomic_read_unchecked(&fscache_n_uncaches));
53228
53229 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
53230 " oom=%u\n",
53231 - atomic_read(&fscache_n_acquires),
53232 - atomic_read(&fscache_n_acquires_null),
53233 - atomic_read(&fscache_n_acquires_no_cache),
53234 - atomic_read(&fscache_n_acquires_ok),
53235 - atomic_read(&fscache_n_acquires_nobufs),
53236 - atomic_read(&fscache_n_acquires_oom));
53237 + atomic_read_unchecked(&fscache_n_acquires),
53238 + atomic_read_unchecked(&fscache_n_acquires_null),
53239 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
53240 + atomic_read_unchecked(&fscache_n_acquires_ok),
53241 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
53242 + atomic_read_unchecked(&fscache_n_acquires_oom));
53243
53244 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
53245 - atomic_read(&fscache_n_object_lookups),
53246 - atomic_read(&fscache_n_object_lookups_negative),
53247 - atomic_read(&fscache_n_object_lookups_positive),
53248 - atomic_read(&fscache_n_object_created),
53249 - atomic_read(&fscache_n_object_lookups_timed_out));
53250 + atomic_read_unchecked(&fscache_n_object_lookups),
53251 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
53252 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
53253 + atomic_read_unchecked(&fscache_n_object_created),
53254 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
53255
53256 seq_printf(m, "Invals : n=%u run=%u\n",
53257 - atomic_read(&fscache_n_invalidates),
53258 - atomic_read(&fscache_n_invalidates_run));
53259 + atomic_read_unchecked(&fscache_n_invalidates),
53260 + atomic_read_unchecked(&fscache_n_invalidates_run));
53261
53262 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
53263 - atomic_read(&fscache_n_updates),
53264 - atomic_read(&fscache_n_updates_null),
53265 - atomic_read(&fscache_n_updates_run));
53266 + atomic_read_unchecked(&fscache_n_updates),
53267 + atomic_read_unchecked(&fscache_n_updates_null),
53268 + atomic_read_unchecked(&fscache_n_updates_run));
53269
53270 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
53271 - atomic_read(&fscache_n_relinquishes),
53272 - atomic_read(&fscache_n_relinquishes_null),
53273 - atomic_read(&fscache_n_relinquishes_waitcrt),
53274 - atomic_read(&fscache_n_relinquishes_retire));
53275 + atomic_read_unchecked(&fscache_n_relinquishes),
53276 + atomic_read_unchecked(&fscache_n_relinquishes_null),
53277 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
53278 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
53279
53280 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
53281 - atomic_read(&fscache_n_attr_changed),
53282 - atomic_read(&fscache_n_attr_changed_ok),
53283 - atomic_read(&fscache_n_attr_changed_nobufs),
53284 - atomic_read(&fscache_n_attr_changed_nomem),
53285 - atomic_read(&fscache_n_attr_changed_calls));
53286 + atomic_read_unchecked(&fscache_n_attr_changed),
53287 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
53288 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
53289 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
53290 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
53291
53292 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
53293 - atomic_read(&fscache_n_allocs),
53294 - atomic_read(&fscache_n_allocs_ok),
53295 - atomic_read(&fscache_n_allocs_wait),
53296 - atomic_read(&fscache_n_allocs_nobufs),
53297 - atomic_read(&fscache_n_allocs_intr));
53298 + atomic_read_unchecked(&fscache_n_allocs),
53299 + atomic_read_unchecked(&fscache_n_allocs_ok),
53300 + atomic_read_unchecked(&fscache_n_allocs_wait),
53301 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
53302 + atomic_read_unchecked(&fscache_n_allocs_intr));
53303 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
53304 - atomic_read(&fscache_n_alloc_ops),
53305 - atomic_read(&fscache_n_alloc_op_waits),
53306 - atomic_read(&fscache_n_allocs_object_dead));
53307 + atomic_read_unchecked(&fscache_n_alloc_ops),
53308 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
53309 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
53310
53311 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
53312 " int=%u oom=%u\n",
53313 - atomic_read(&fscache_n_retrievals),
53314 - atomic_read(&fscache_n_retrievals_ok),
53315 - atomic_read(&fscache_n_retrievals_wait),
53316 - atomic_read(&fscache_n_retrievals_nodata),
53317 - atomic_read(&fscache_n_retrievals_nobufs),
53318 - atomic_read(&fscache_n_retrievals_intr),
53319 - atomic_read(&fscache_n_retrievals_nomem));
53320 + atomic_read_unchecked(&fscache_n_retrievals),
53321 + atomic_read_unchecked(&fscache_n_retrievals_ok),
53322 + atomic_read_unchecked(&fscache_n_retrievals_wait),
53323 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
53324 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
53325 + atomic_read_unchecked(&fscache_n_retrievals_intr),
53326 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
53327 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
53328 - atomic_read(&fscache_n_retrieval_ops),
53329 - atomic_read(&fscache_n_retrieval_op_waits),
53330 - atomic_read(&fscache_n_retrievals_object_dead));
53331 + atomic_read_unchecked(&fscache_n_retrieval_ops),
53332 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
53333 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
53334
53335 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
53336 - atomic_read(&fscache_n_stores),
53337 - atomic_read(&fscache_n_stores_ok),
53338 - atomic_read(&fscache_n_stores_again),
53339 - atomic_read(&fscache_n_stores_nobufs),
53340 - atomic_read(&fscache_n_stores_oom));
53341 + atomic_read_unchecked(&fscache_n_stores),
53342 + atomic_read_unchecked(&fscache_n_stores_ok),
53343 + atomic_read_unchecked(&fscache_n_stores_again),
53344 + atomic_read_unchecked(&fscache_n_stores_nobufs),
53345 + atomic_read_unchecked(&fscache_n_stores_oom));
53346 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
53347 - atomic_read(&fscache_n_store_ops),
53348 - atomic_read(&fscache_n_store_calls),
53349 - atomic_read(&fscache_n_store_pages),
53350 - atomic_read(&fscache_n_store_radix_deletes),
53351 - atomic_read(&fscache_n_store_pages_over_limit));
53352 + atomic_read_unchecked(&fscache_n_store_ops),
53353 + atomic_read_unchecked(&fscache_n_store_calls),
53354 + atomic_read_unchecked(&fscache_n_store_pages),
53355 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
53356 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
53357
53358 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
53359 - atomic_read(&fscache_n_store_vmscan_not_storing),
53360 - atomic_read(&fscache_n_store_vmscan_gone),
53361 - atomic_read(&fscache_n_store_vmscan_busy),
53362 - atomic_read(&fscache_n_store_vmscan_cancelled),
53363 - atomic_read(&fscache_n_store_vmscan_wait));
53364 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
53365 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
53366 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
53367 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
53368 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
53369
53370 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
53371 - atomic_read(&fscache_n_op_pend),
53372 - atomic_read(&fscache_n_op_run),
53373 - atomic_read(&fscache_n_op_enqueue),
53374 - atomic_read(&fscache_n_op_cancelled),
53375 - atomic_read(&fscache_n_op_rejected));
53376 + atomic_read_unchecked(&fscache_n_op_pend),
53377 + atomic_read_unchecked(&fscache_n_op_run),
53378 + atomic_read_unchecked(&fscache_n_op_enqueue),
53379 + atomic_read_unchecked(&fscache_n_op_cancelled),
53380 + atomic_read_unchecked(&fscache_n_op_rejected));
53381 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
53382 - atomic_read(&fscache_n_op_deferred_release),
53383 - atomic_read(&fscache_n_op_release),
53384 - atomic_read(&fscache_n_op_gc));
53385 + atomic_read_unchecked(&fscache_n_op_deferred_release),
53386 + atomic_read_unchecked(&fscache_n_op_release),
53387 + atomic_read_unchecked(&fscache_n_op_gc));
53388
53389 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
53390 atomic_read(&fscache_n_cop_alloc_object),
53391 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
53392 index e397b67..b0d8709 100644
53393 --- a/fs/fuse/cuse.c
53394 +++ b/fs/fuse/cuse.c
53395 @@ -593,10 +593,12 @@ static int __init cuse_init(void)
53396 INIT_LIST_HEAD(&cuse_conntbl[i]);
53397
53398 /* inherit and extend fuse_dev_operations */
53399 - cuse_channel_fops = fuse_dev_operations;
53400 - cuse_channel_fops.owner = THIS_MODULE;
53401 - cuse_channel_fops.open = cuse_channel_open;
53402 - cuse_channel_fops.release = cuse_channel_release;
53403 + pax_open_kernel();
53404 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
53405 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
53406 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
53407 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
53408 + pax_close_kernel();
53409
53410 cuse_class = class_create(THIS_MODULE, "cuse");
53411 if (IS_ERR(cuse_class))
53412 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
53413 index e83351a..41e3c9c 100644
53414 --- a/fs/fuse/dev.c
53415 +++ b/fs/fuse/dev.c
53416 @@ -1236,7 +1236,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
53417 ret = 0;
53418 pipe_lock(pipe);
53419
53420 - if (!pipe->readers) {
53421 + if (!atomic_read(&pipe->readers)) {
53422 send_sig(SIGPIPE, current, 0);
53423 if (!ret)
53424 ret = -EPIPE;
53425 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
53426 index 315e1f8..91f890c 100644
53427 --- a/fs/fuse/dir.c
53428 +++ b/fs/fuse/dir.c
53429 @@ -1233,7 +1233,7 @@ static char *read_link(struct dentry *dentry)
53430 return link;
53431 }
53432
53433 -static void free_link(char *link)
53434 +static void free_link(const char *link)
53435 {
53436 if (!IS_ERR(link))
53437 free_page((unsigned long) link);
53438 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
53439 index 2b6f569..fcb4d1f 100644
53440 --- a/fs/gfs2/inode.c
53441 +++ b/fs/gfs2/inode.c
53442 @@ -1499,7 +1499,7 @@ out:
53443
53444 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53445 {
53446 - char *s = nd_get_link(nd);
53447 + const char *s = nd_get_link(nd);
53448 if (!IS_ERR(s))
53449 kfree(s);
53450 }
53451 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
53452 index 78bde32..767e906 100644
53453 --- a/fs/hugetlbfs/inode.c
53454 +++ b/fs/hugetlbfs/inode.c
53455 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53456 struct mm_struct *mm = current->mm;
53457 struct vm_area_struct *vma;
53458 struct hstate *h = hstate_file(file);
53459 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
53460 struct vm_unmapped_area_info info;
53461
53462 if (len & ~huge_page_mask(h))
53463 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53464 return addr;
53465 }
53466
53467 +#ifdef CONFIG_PAX_RANDMMAP
53468 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
53469 +#endif
53470 +
53471 if (addr) {
53472 addr = ALIGN(addr, huge_page_size(h));
53473 vma = find_vma(mm, addr);
53474 - if (TASK_SIZE - len >= addr &&
53475 - (!vma || addr + len <= vma->vm_start))
53476 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
53477 return addr;
53478 }
53479
53480 info.flags = 0;
53481 info.length = len;
53482 info.low_limit = TASK_UNMAPPED_BASE;
53483 +
53484 +#ifdef CONFIG_PAX_RANDMMAP
53485 + if (mm->pax_flags & MF_PAX_RANDMMAP)
53486 + info.low_limit += mm->delta_mmap;
53487 +#endif
53488 +
53489 info.high_limit = TASK_SIZE;
53490 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
53491 info.align_offset = 0;
53492 @@ -897,7 +907,7 @@ static struct file_system_type hugetlbfs_fs_type = {
53493 .kill_sb = kill_litter_super,
53494 };
53495
53496 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53497 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53498
53499 static int can_do_hugetlb_shm(void)
53500 {
53501 diff --git a/fs/inode.c b/fs/inode.c
53502 index 14084b7..29af1d9 100644
53503 --- a/fs/inode.c
53504 +++ b/fs/inode.c
53505 @@ -880,8 +880,8 @@ unsigned int get_next_ino(void)
53506
53507 #ifdef CONFIG_SMP
53508 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
53509 - static atomic_t shared_last_ino;
53510 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
53511 + static atomic_unchecked_t shared_last_ino;
53512 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
53513
53514 res = next - LAST_INO_BATCH;
53515 }
53516 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
53517 index 4a6cf28..d3a29d3 100644
53518 --- a/fs/jffs2/erase.c
53519 +++ b/fs/jffs2/erase.c
53520 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
53521 struct jffs2_unknown_node marker = {
53522 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
53523 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53524 - .totlen = cpu_to_je32(c->cleanmarker_size)
53525 + .totlen = cpu_to_je32(c->cleanmarker_size),
53526 + .hdr_crc = cpu_to_je32(0)
53527 };
53528
53529 jffs2_prealloc_raw_node_refs(c, jeb, 1);
53530 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
53531 index a6597d6..41b30ec 100644
53532 --- a/fs/jffs2/wbuf.c
53533 +++ b/fs/jffs2/wbuf.c
53534 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
53535 {
53536 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
53537 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53538 - .totlen = constant_cpu_to_je32(8)
53539 + .totlen = constant_cpu_to_je32(8),
53540 + .hdr_crc = constant_cpu_to_je32(0)
53541 };
53542
53543 /*
53544 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
53545 index 1a543be..a4e1363 100644
53546 --- a/fs/jfs/super.c
53547 +++ b/fs/jfs/super.c
53548 @@ -225,7 +225,7 @@ static const match_table_t tokens = {
53549 static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
53550 int *flag)
53551 {
53552 - void *nls_map = (void *)-1; /* -1: no change; NULL: none */
53553 + const void *nls_map = (const void *)-1; /* -1: no change; NULL: none */
53554 char *p;
53555 struct jfs_sb_info *sbi = JFS_SBI(sb);
53556
53557 @@ -253,7 +253,7 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
53558 /* Don't do anything ;-) */
53559 break;
53560 case Opt_iocharset:
53561 - if (nls_map && nls_map != (void *) -1)
53562 + if (nls_map && nls_map != (const void *) -1)
53563 unload_nls(nls_map);
53564 if (!strcmp(args[0].from, "none"))
53565 nls_map = NULL;
53566 @@ -855,7 +855,7 @@ static int __init init_jfs_fs(void)
53567
53568 jfs_inode_cachep =
53569 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
53570 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
53571 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
53572 init_once);
53573 if (jfs_inode_cachep == NULL)
53574 return -ENOMEM;
53575 diff --git a/fs/libfs.c b/fs/libfs.c
53576 index 916da8c..1588998 100644
53577 --- a/fs/libfs.c
53578 +++ b/fs/libfs.c
53579 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53580
53581 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
53582 struct dentry *next;
53583 + char d_name[sizeof(next->d_iname)];
53584 + const unsigned char *name;
53585 +
53586 next = list_entry(p, struct dentry, d_u.d_child);
53587 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
53588 if (!simple_positive(next)) {
53589 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53590
53591 spin_unlock(&next->d_lock);
53592 spin_unlock(&dentry->d_lock);
53593 - if (filldir(dirent, next->d_name.name,
53594 + name = next->d_name.name;
53595 + if (name == next->d_iname) {
53596 + memcpy(d_name, name, next->d_name.len);
53597 + name = d_name;
53598 + }
53599 + if (filldir(dirent, name,
53600 next->d_name.len, filp->f_pos,
53601 next->d_inode->i_ino,
53602 dt_type(next->d_inode)) < 0)
53603 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
53604 index 52e5120..808936e 100644
53605 --- a/fs/lockd/clntproc.c
53606 +++ b/fs/lockd/clntproc.c
53607 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
53608 /*
53609 * Cookie counter for NLM requests
53610 */
53611 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
53612 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
53613
53614 void nlmclnt_next_cookie(struct nlm_cookie *c)
53615 {
53616 - u32 cookie = atomic_inc_return(&nlm_cookie);
53617 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
53618
53619 memcpy(c->data, &cookie, 4);
53620 c->len=4;
53621 diff --git a/fs/locks.c b/fs/locks.c
53622 index a94e331..060bce3 100644
53623 --- a/fs/locks.c
53624 +++ b/fs/locks.c
53625 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
53626 return;
53627
53628 if (filp->f_op && filp->f_op->flock) {
53629 - struct file_lock fl = {
53630 + struct file_lock flock = {
53631 .fl_pid = current->tgid,
53632 .fl_file = filp,
53633 .fl_flags = FL_FLOCK,
53634 .fl_type = F_UNLCK,
53635 .fl_end = OFFSET_MAX,
53636 };
53637 - filp->f_op->flock(filp, F_SETLKW, &fl);
53638 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
53639 - fl.fl_ops->fl_release_private(&fl);
53640 + filp->f_op->flock(filp, F_SETLKW, &flock);
53641 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
53642 + flock.fl_ops->fl_release_private(&flock);
53643 }
53644
53645 lock_flocks();
53646 diff --git a/fs/namei.c b/fs/namei.c
53647 index ec97aef..e67718d 100644
53648 --- a/fs/namei.c
53649 +++ b/fs/namei.c
53650 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
53651 if (ret != -EACCES)
53652 return ret;
53653
53654 +#ifdef CONFIG_GRKERNSEC
53655 + /* we'll block if we have to log due to a denied capability use */
53656 + if (mask & MAY_NOT_BLOCK)
53657 + return -ECHILD;
53658 +#endif
53659 +
53660 if (S_ISDIR(inode->i_mode)) {
53661 /* DACs are overridable for directories */
53662 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
53663 - return 0;
53664 if (!(mask & MAY_WRITE))
53665 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53666 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53667 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53668 return 0;
53669 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
53670 + return 0;
53671 return -EACCES;
53672 }
53673 /*
53674 + * Searching includes executable on directories, else just read.
53675 + */
53676 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53677 + if (mask == MAY_READ)
53678 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53679 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53680 + return 0;
53681 +
53682 + /*
53683 * Read/write DACs are always overridable.
53684 * Executable DACs are overridable when there is
53685 * at least one exec bit set.
53686 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
53687 if (inode_capable(inode, CAP_DAC_OVERRIDE))
53688 return 0;
53689
53690 - /*
53691 - * Searching includes executable on directories, else just read.
53692 - */
53693 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53694 - if (mask == MAY_READ)
53695 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53696 - return 0;
53697 -
53698 return -EACCES;
53699 }
53700
53701 @@ -824,7 +832,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53702 {
53703 struct dentry *dentry = link->dentry;
53704 int error;
53705 - char *s;
53706 + const char *s;
53707
53708 BUG_ON(nd->flags & LOOKUP_RCU);
53709
53710 @@ -845,6 +853,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53711 if (error)
53712 goto out_put_nd_path;
53713
53714 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
53715 + dentry->d_inode, dentry, nd->path.mnt)) {
53716 + error = -EACCES;
53717 + goto out_put_nd_path;
53718 + }
53719 +
53720 nd->last_type = LAST_BIND;
53721 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
53722 error = PTR_ERR(*p);
53723 @@ -1594,6 +1608,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
53724 break;
53725 res = walk_component(nd, path, &nd->last,
53726 nd->last_type, LOOKUP_FOLLOW);
53727 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
53728 + res = -EACCES;
53729 put_link(nd, &link, cookie);
53730 } while (res > 0);
53731
53732 @@ -1692,7 +1708,7 @@ EXPORT_SYMBOL(full_name_hash);
53733 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
53734 {
53735 unsigned long a, b, adata, bdata, mask, hash, len;
53736 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53737 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53738
53739 hash = a = 0;
53740 len = -sizeof(unsigned long);
53741 @@ -1977,6 +1993,8 @@ static int path_lookupat(int dfd, const char *name,
53742 if (err)
53743 break;
53744 err = lookup_last(nd, &path);
53745 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
53746 + err = -EACCES;
53747 put_link(nd, &link, cookie);
53748 }
53749 }
53750 @@ -1984,6 +2002,13 @@ static int path_lookupat(int dfd, const char *name,
53751 if (!err)
53752 err = complete_walk(nd);
53753
53754 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
53755 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53756 + path_put(&nd->path);
53757 + err = -ENOENT;
53758 + }
53759 + }
53760 +
53761 if (!err && nd->flags & LOOKUP_DIRECTORY) {
53762 if (!nd->inode->i_op->lookup) {
53763 path_put(&nd->path);
53764 @@ -2011,8 +2036,15 @@ static int filename_lookup(int dfd, struct filename *name,
53765 retval = path_lookupat(dfd, name->name,
53766 flags | LOOKUP_REVAL, nd);
53767
53768 - if (likely(!retval))
53769 + if (likely(!retval)) {
53770 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
53771 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
53772 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
53773 + path_put(&nd->path);
53774 + return -ENOENT;
53775 + }
53776 + }
53777 + }
53778 return retval;
53779 }
53780
53781 @@ -2390,6 +2422,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
53782 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
53783 return -EPERM;
53784
53785 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
53786 + return -EPERM;
53787 + if (gr_handle_rawio(inode))
53788 + return -EPERM;
53789 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
53790 + return -EACCES;
53791 +
53792 return 0;
53793 }
53794
53795 @@ -2611,7 +2650,7 @@ looked_up:
53796 * cleared otherwise prior to returning.
53797 */
53798 static int lookup_open(struct nameidata *nd, struct path *path,
53799 - struct file *file,
53800 + struct path *link, struct file *file,
53801 const struct open_flags *op,
53802 bool got_write, int *opened)
53803 {
53804 @@ -2646,6 +2685,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53805 /* Negative dentry, just create the file */
53806 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
53807 umode_t mode = op->mode;
53808 +
53809 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
53810 + error = -EACCES;
53811 + goto out_dput;
53812 + }
53813 +
53814 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
53815 + error = -EACCES;
53816 + goto out_dput;
53817 + }
53818 +
53819 if (!IS_POSIXACL(dir->d_inode))
53820 mode &= ~current_umask();
53821 /*
53822 @@ -2667,6 +2717,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53823 nd->flags & LOOKUP_EXCL);
53824 if (error)
53825 goto out_dput;
53826 + else
53827 + gr_handle_create(dentry, nd->path.mnt);
53828 }
53829 out_no_open:
53830 path->dentry = dentry;
53831 @@ -2681,7 +2733,7 @@ out_dput:
53832 /*
53833 * Handle the last step of open()
53834 */
53835 -static int do_last(struct nameidata *nd, struct path *path,
53836 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
53837 struct file *file, const struct open_flags *op,
53838 int *opened, struct filename *name)
53839 {
53840 @@ -2710,16 +2762,32 @@ static int do_last(struct nameidata *nd, struct path *path,
53841 error = complete_walk(nd);
53842 if (error)
53843 return error;
53844 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53845 + error = -ENOENT;
53846 + goto out;
53847 + }
53848 audit_inode(name, nd->path.dentry, 0);
53849 if (open_flag & O_CREAT) {
53850 error = -EISDIR;
53851 goto out;
53852 }
53853 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53854 + error = -EACCES;
53855 + goto out;
53856 + }
53857 goto finish_open;
53858 case LAST_BIND:
53859 error = complete_walk(nd);
53860 if (error)
53861 return error;
53862 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
53863 + error = -ENOENT;
53864 + goto out;
53865 + }
53866 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53867 + error = -EACCES;
53868 + goto out;
53869 + }
53870 audit_inode(name, dir, 0);
53871 goto finish_open;
53872 }
53873 @@ -2768,7 +2836,7 @@ retry_lookup:
53874 */
53875 }
53876 mutex_lock(&dir->d_inode->i_mutex);
53877 - error = lookup_open(nd, path, file, op, got_write, opened);
53878 + error = lookup_open(nd, path, link, file, op, got_write, opened);
53879 mutex_unlock(&dir->d_inode->i_mutex);
53880
53881 if (error <= 0) {
53882 @@ -2792,11 +2860,28 @@ retry_lookup:
53883 goto finish_open_created;
53884 }
53885
53886 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
53887 + error = -ENOENT;
53888 + goto exit_dput;
53889 + }
53890 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
53891 + error = -EACCES;
53892 + goto exit_dput;
53893 + }
53894 +
53895 /*
53896 * create/update audit record if it already exists.
53897 */
53898 - if (path->dentry->d_inode)
53899 + if (path->dentry->d_inode) {
53900 + /* only check if O_CREAT is specified, all other checks need to go
53901 + into may_open */
53902 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
53903 + error = -EACCES;
53904 + goto exit_dput;
53905 + }
53906 +
53907 audit_inode(name, path->dentry, 0);
53908 + }
53909
53910 /*
53911 * If atomic_open() acquired write access it is dropped now due to
53912 @@ -2837,6 +2922,11 @@ finish_lookup:
53913 }
53914 }
53915 BUG_ON(inode != path->dentry->d_inode);
53916 + /* if we're resolving a symlink to another symlink */
53917 + if (link && gr_handle_symlink_owner(link, inode)) {
53918 + error = -EACCES;
53919 + goto out;
53920 + }
53921 return 1;
53922 }
53923
53924 @@ -2846,7 +2936,6 @@ finish_lookup:
53925 save_parent.dentry = nd->path.dentry;
53926 save_parent.mnt = mntget(path->mnt);
53927 nd->path.dentry = path->dentry;
53928 -
53929 }
53930 nd->inode = inode;
53931 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
53932 @@ -2855,6 +2944,16 @@ finish_lookup:
53933 path_put(&save_parent);
53934 return error;
53935 }
53936 +
53937 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53938 + error = -ENOENT;
53939 + goto out;
53940 + }
53941 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53942 + error = -EACCES;
53943 + goto out;
53944 + }
53945 +
53946 error = -EISDIR;
53947 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
53948 goto out;
53949 @@ -2953,7 +3052,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53950 if (unlikely(error))
53951 goto out;
53952
53953 - error = do_last(nd, &path, file, op, &opened, pathname);
53954 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
53955 while (unlikely(error > 0)) { /* trailing symlink */
53956 struct path link = path;
53957 void *cookie;
53958 @@ -2971,7 +3070,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53959 error = follow_link(&link, nd, &cookie);
53960 if (unlikely(error))
53961 break;
53962 - error = do_last(nd, &path, file, op, &opened, pathname);
53963 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
53964 put_link(nd, &link, cookie);
53965 }
53966 out:
53967 @@ -3071,8 +3170,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
53968 goto unlock;
53969
53970 error = -EEXIST;
53971 - if (dentry->d_inode)
53972 + if (dentry->d_inode) {
53973 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
53974 + error = -ENOENT;
53975 + }
53976 goto fail;
53977 + }
53978 /*
53979 * Special case - lookup gave negative, but... we had foo/bar/
53980 * From the vfs_mknod() POV we just have a negative dentry -
53981 @@ -3124,6 +3227,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
53982 }
53983 EXPORT_SYMBOL(user_path_create);
53984
53985 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
53986 +{
53987 + struct filename *tmp = getname(pathname);
53988 + struct dentry *res;
53989 + if (IS_ERR(tmp))
53990 + return ERR_CAST(tmp);
53991 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
53992 + if (IS_ERR(res))
53993 + putname(tmp);
53994 + else
53995 + *to = tmp;
53996 + return res;
53997 +}
53998 +
53999 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
54000 {
54001 int error = may_create(dir, dentry);
54002 @@ -3186,6 +3303,17 @@ retry:
54003
54004 if (!IS_POSIXACL(path.dentry->d_inode))
54005 mode &= ~current_umask();
54006 +
54007 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
54008 + error = -EPERM;
54009 + goto out;
54010 + }
54011 +
54012 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
54013 + error = -EACCES;
54014 + goto out;
54015 + }
54016 +
54017 error = security_path_mknod(&path, dentry, mode, dev);
54018 if (error)
54019 goto out;
54020 @@ -3202,6 +3330,8 @@ retry:
54021 break;
54022 }
54023 out:
54024 + if (!error)
54025 + gr_handle_create(dentry, path.mnt);
54026 done_path_create(&path, dentry);
54027 if (retry_estale(error, lookup_flags)) {
54028 lookup_flags |= LOOKUP_REVAL;
54029 @@ -3254,9 +3384,16 @@ retry:
54030
54031 if (!IS_POSIXACL(path.dentry->d_inode))
54032 mode &= ~current_umask();
54033 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
54034 + error = -EACCES;
54035 + goto out;
54036 + }
54037 error = security_path_mkdir(&path, dentry, mode);
54038 if (!error)
54039 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
54040 + if (!error)
54041 + gr_handle_create(dentry, path.mnt);
54042 +out:
54043 done_path_create(&path, dentry);
54044 if (retry_estale(error, lookup_flags)) {
54045 lookup_flags |= LOOKUP_REVAL;
54046 @@ -3337,6 +3474,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
54047 struct filename *name;
54048 struct dentry *dentry;
54049 struct nameidata nd;
54050 + ino_t saved_ino = 0;
54051 + dev_t saved_dev = 0;
54052 unsigned int lookup_flags = 0;
54053 retry:
54054 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
54055 @@ -3369,10 +3508,21 @@ retry:
54056 error = -ENOENT;
54057 goto exit3;
54058 }
54059 +
54060 + saved_ino = dentry->d_inode->i_ino;
54061 + saved_dev = gr_get_dev_from_dentry(dentry);
54062 +
54063 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
54064 + error = -EACCES;
54065 + goto exit3;
54066 + }
54067 +
54068 error = security_path_rmdir(&nd.path, dentry);
54069 if (error)
54070 goto exit3;
54071 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
54072 + if (!error && (saved_dev || saved_ino))
54073 + gr_handle_delete(saved_ino, saved_dev);
54074 exit3:
54075 dput(dentry);
54076 exit2:
54077 @@ -3438,6 +3588,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
54078 struct dentry *dentry;
54079 struct nameidata nd;
54080 struct inode *inode = NULL;
54081 + ino_t saved_ino = 0;
54082 + dev_t saved_dev = 0;
54083 unsigned int lookup_flags = 0;
54084 retry:
54085 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
54086 @@ -3464,10 +3616,22 @@ retry:
54087 if (!inode)
54088 goto slashes;
54089 ihold(inode);
54090 +
54091 + if (inode->i_nlink <= 1) {
54092 + saved_ino = inode->i_ino;
54093 + saved_dev = gr_get_dev_from_dentry(dentry);
54094 + }
54095 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
54096 + error = -EACCES;
54097 + goto exit2;
54098 + }
54099 +
54100 error = security_path_unlink(&nd.path, dentry);
54101 if (error)
54102 goto exit2;
54103 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
54104 + if (!error && (saved_ino || saved_dev))
54105 + gr_handle_delete(saved_ino, saved_dev);
54106 exit2:
54107 dput(dentry);
54108 }
54109 @@ -3545,9 +3709,17 @@ retry:
54110 if (IS_ERR(dentry))
54111 goto out_putname;
54112
54113 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
54114 + error = -EACCES;
54115 + goto out;
54116 + }
54117 +
54118 error = security_path_symlink(&path, dentry, from->name);
54119 if (!error)
54120 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
54121 + if (!error)
54122 + gr_handle_create(dentry, path.mnt);
54123 +out:
54124 done_path_create(&path, dentry);
54125 if (retry_estale(error, lookup_flags)) {
54126 lookup_flags |= LOOKUP_REVAL;
54127 @@ -3621,6 +3793,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
54128 {
54129 struct dentry *new_dentry;
54130 struct path old_path, new_path;
54131 + struct filename *to = NULL;
54132 int how = 0;
54133 int error;
54134
54135 @@ -3644,7 +3817,7 @@ retry:
54136 if (error)
54137 return error;
54138
54139 - new_dentry = user_path_create(newdfd, newname, &new_path,
54140 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
54141 (how & LOOKUP_REVAL));
54142 error = PTR_ERR(new_dentry);
54143 if (IS_ERR(new_dentry))
54144 @@ -3656,11 +3829,28 @@ retry:
54145 error = may_linkat(&old_path);
54146 if (unlikely(error))
54147 goto out_dput;
54148 +
54149 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
54150 + old_path.dentry->d_inode,
54151 + old_path.dentry->d_inode->i_mode, to)) {
54152 + error = -EACCES;
54153 + goto out_dput;
54154 + }
54155 +
54156 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
54157 + old_path.dentry, old_path.mnt, to)) {
54158 + error = -EACCES;
54159 + goto out_dput;
54160 + }
54161 +
54162 error = security_path_link(old_path.dentry, &new_path, new_dentry);
54163 if (error)
54164 goto out_dput;
54165 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
54166 + if (!error)
54167 + gr_handle_create(new_dentry, new_path.mnt);
54168 out_dput:
54169 + putname(to);
54170 done_path_create(&new_path, new_dentry);
54171 if (retry_estale(error, how)) {
54172 how |= LOOKUP_REVAL;
54173 @@ -3906,12 +4096,21 @@ retry:
54174 if (new_dentry == trap)
54175 goto exit5;
54176
54177 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
54178 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
54179 + to);
54180 + if (error)
54181 + goto exit5;
54182 +
54183 error = security_path_rename(&oldnd.path, old_dentry,
54184 &newnd.path, new_dentry);
54185 if (error)
54186 goto exit5;
54187 error = vfs_rename(old_dir->d_inode, old_dentry,
54188 new_dir->d_inode, new_dentry);
54189 + if (!error)
54190 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
54191 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
54192 exit5:
54193 dput(new_dentry);
54194 exit4:
54195 @@ -3943,6 +4142,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
54196
54197 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
54198 {
54199 + char tmpbuf[64];
54200 + const char *newlink;
54201 int len;
54202
54203 len = PTR_ERR(link);
54204 @@ -3952,7 +4153,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
54205 len = strlen(link);
54206 if (len > (unsigned) buflen)
54207 len = buflen;
54208 - if (copy_to_user(buffer, link, len))
54209 +
54210 + if (len < sizeof(tmpbuf)) {
54211 + memcpy(tmpbuf, link, len);
54212 + newlink = tmpbuf;
54213 + } else
54214 + newlink = link;
54215 +
54216 + if (copy_to_user(buffer, newlink, len))
54217 len = -EFAULT;
54218 out:
54219 return len;
54220 diff --git a/fs/namespace.c b/fs/namespace.c
54221 index 5dd7709..6f64e9c 100644
54222 --- a/fs/namespace.c
54223 +++ b/fs/namespace.c
54224 @@ -1219,6 +1219,9 @@ static int do_umount(struct mount *mnt, int flags)
54225 if (!(sb->s_flags & MS_RDONLY))
54226 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
54227 up_write(&sb->s_umount);
54228 +
54229 + gr_log_remount(mnt->mnt_devname, retval);
54230 +
54231 return retval;
54232 }
54233
54234 @@ -1238,6 +1241,9 @@ static int do_umount(struct mount *mnt, int flags)
54235 br_write_unlock(&vfsmount_lock);
54236 up_write(&namespace_sem);
54237 release_mounts(&umount_list);
54238 +
54239 + gr_log_unmount(mnt->mnt_devname, retval);
54240 +
54241 return retval;
54242 }
54243
54244 @@ -1713,7 +1719,7 @@ static int do_loopback(struct path *path, const char *old_name,
54245
54246 if (IS_ERR(mnt)) {
54247 err = PTR_ERR(mnt);
54248 - goto out;
54249 + goto out2;
54250 }
54251
54252 err = graft_tree(mnt, path);
54253 @@ -2294,6 +2300,16 @@ long do_mount(const char *dev_name, const char *dir_name,
54254 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
54255 MS_STRICTATIME);
54256
54257 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
54258 + retval = -EPERM;
54259 + goto dput_out;
54260 + }
54261 +
54262 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
54263 + retval = -EPERM;
54264 + goto dput_out;
54265 + }
54266 +
54267 if (flags & MS_REMOUNT)
54268 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
54269 data_page);
54270 @@ -2308,6 +2324,9 @@ long do_mount(const char *dev_name, const char *dir_name,
54271 dev_name, data_page);
54272 dput_out:
54273 path_put(&path);
54274 +
54275 + gr_log_mount(dev_name, dir_name, retval);
54276 +
54277 return retval;
54278 }
54279
54280 @@ -2594,6 +2613,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
54281 if (error)
54282 goto out2;
54283
54284 + if (gr_handle_chroot_pivot()) {
54285 + error = -EPERM;
54286 + goto out2;
54287 + }
54288 +
54289 get_fs_root(current->fs, &root);
54290 error = lock_mount(&old);
54291 if (error)
54292 @@ -2842,7 +2866,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
54293 !nsown_capable(CAP_SYS_ADMIN))
54294 return -EPERM;
54295
54296 - if (fs->users != 1)
54297 + if (atomic_read(&fs->users) != 1)
54298 return -EINVAL;
54299
54300 get_mnt_ns(mnt_ns);
54301 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
54302 index 59461c9..b17c57e 100644
54303 --- a/fs/nfs/callback_xdr.c
54304 +++ b/fs/nfs/callback_xdr.c
54305 @@ -51,7 +51,7 @@ struct callback_op {
54306 callback_decode_arg_t decode_args;
54307 callback_encode_res_t encode_res;
54308 long res_maxsize;
54309 -};
54310 +} __do_const;
54311
54312 static struct callback_op callback_ops[];
54313
54314 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
54315 index ebeb94c..ff35337 100644
54316 --- a/fs/nfs/inode.c
54317 +++ b/fs/nfs/inode.c
54318 @@ -1042,16 +1042,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
54319 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
54320 }
54321
54322 -static atomic_long_t nfs_attr_generation_counter;
54323 +static atomic_long_unchecked_t nfs_attr_generation_counter;
54324
54325 static unsigned long nfs_read_attr_generation_counter(void)
54326 {
54327 - return atomic_long_read(&nfs_attr_generation_counter);
54328 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
54329 }
54330
54331 unsigned long nfs_inc_attr_generation_counter(void)
54332 {
54333 - return atomic_long_inc_return(&nfs_attr_generation_counter);
54334 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
54335 }
54336
54337 void nfs_fattr_init(struct nfs_fattr *fattr)
54338 diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
54339 index 2e9779b..c53189d 100644
54340 --- a/fs/nfs/nfs4client.c
54341 +++ b/fs/nfs/nfs4client.c
54342 @@ -300,7 +300,7 @@ int nfs40_walk_client_list(struct nfs_client *new,
54343 struct rpc_cred *cred)
54344 {
54345 struct nfs_net *nn = net_generic(new->cl_net, nfs_net_id);
54346 - struct nfs_client *pos, *n, *prev = NULL;
54347 + struct nfs_client *pos, *prev = NULL;
54348 struct nfs4_setclientid_res clid = {
54349 .clientid = new->cl_clientid,
54350 .confirm = new->cl_confirm,
54351 @@ -308,10 +308,23 @@ int nfs40_walk_client_list(struct nfs_client *new,
54352 int status = -NFS4ERR_STALE_CLIENTID;
54353
54354 spin_lock(&nn->nfs_client_lock);
54355 - list_for_each_entry_safe(pos, n, &nn->nfs_client_list, cl_share_link) {
54356 + list_for_each_entry(pos, &nn->nfs_client_list, cl_share_link) {
54357 /* If "pos" isn't marked ready, we can't trust the
54358 * remaining fields in "pos" */
54359 - if (pos->cl_cons_state < NFS_CS_READY)
54360 + if (pos->cl_cons_state > NFS_CS_READY) {
54361 + atomic_inc(&pos->cl_count);
54362 + spin_unlock(&nn->nfs_client_lock);
54363 +
54364 + if (prev)
54365 + nfs_put_client(prev);
54366 + prev = pos;
54367 +
54368 + status = nfs_wait_client_init_complete(pos);
54369 + spin_lock(&nn->nfs_client_lock);
54370 + if (status < 0)
54371 + continue;
54372 + }
54373 + if (pos->cl_cons_state != NFS_CS_READY)
54374 continue;
54375
54376 if (pos->rpc_ops != new->rpc_ops)
54377 @@ -423,16 +436,16 @@ int nfs41_walk_client_list(struct nfs_client *new,
54378 struct rpc_cred *cred)
54379 {
54380 struct nfs_net *nn = net_generic(new->cl_net, nfs_net_id);
54381 - struct nfs_client *pos, *n, *prev = NULL;
54382 + struct nfs_client *pos, *prev = NULL;
54383 int status = -NFS4ERR_STALE_CLIENTID;
54384
54385 spin_lock(&nn->nfs_client_lock);
54386 - list_for_each_entry_safe(pos, n, &nn->nfs_client_list, cl_share_link) {
54387 + list_for_each_entry(pos, &nn->nfs_client_list, cl_share_link) {
54388 /* If "pos" isn't marked ready, we can't trust the
54389 * remaining fields in "pos", especially the client
54390 * ID and serverowner fields. Wait for CREATE_SESSION
54391 * to finish. */
54392 - if (pos->cl_cons_state < NFS_CS_READY) {
54393 + if (pos->cl_cons_state > NFS_CS_READY) {
54394 atomic_inc(&pos->cl_count);
54395 spin_unlock(&nn->nfs_client_lock);
54396
54397 @@ -440,18 +453,17 @@ int nfs41_walk_client_list(struct nfs_client *new,
54398 nfs_put_client(prev);
54399 prev = pos;
54400
54401 - nfs4_schedule_lease_recovery(pos);
54402 status = nfs_wait_client_init_complete(pos);
54403 - if (status < 0) {
54404 - nfs_put_client(pos);
54405 - spin_lock(&nn->nfs_client_lock);
54406 - continue;
54407 + if (status == 0) {
54408 + nfs4_schedule_lease_recovery(pos);
54409 + status = nfs4_wait_clnt_recover(pos);
54410 }
54411 - status = pos->cl_cons_state;
54412 spin_lock(&nn->nfs_client_lock);
54413 if (status < 0)
54414 continue;
54415 }
54416 + if (pos->cl_cons_state != NFS_CS_READY)
54417 + continue;
54418
54419 if (pos->rpc_ops != new->rpc_ops)
54420 continue;
54421 @@ -469,17 +481,18 @@ int nfs41_walk_client_list(struct nfs_client *new,
54422 continue;
54423
54424 atomic_inc(&pos->cl_count);
54425 - spin_unlock(&nn->nfs_client_lock);
54426 + *result = pos;
54427 + status = 0;
54428 dprintk("NFS: <-- %s using nfs_client = %p ({%d})\n",
54429 __func__, pos, atomic_read(&pos->cl_count));
54430 -
54431 - *result = pos;
54432 - return 0;
54433 + break;
54434 }
54435
54436 /* No matching nfs_client found. */
54437 spin_unlock(&nn->nfs_client_lock);
54438 dprintk("NFS: <-- %s status = %d\n", __func__, status);
54439 + if (prev)
54440 + nfs_put_client(prev);
54441 return status;
54442 }
54443 #endif /* CONFIG_NFS_V4_1 */
54444 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
54445 index 9d1c5db..1e13db8 100644
54446 --- a/fs/nfsd/nfs4proc.c
54447 +++ b/fs/nfsd/nfs4proc.c
54448 @@ -1097,7 +1097,7 @@ struct nfsd4_operation {
54449 nfsd4op_rsize op_rsize_bop;
54450 stateid_getter op_get_currentstateid;
54451 stateid_setter op_set_currentstateid;
54452 -};
54453 +} __do_const;
54454
54455 static struct nfsd4_operation nfsd4_ops[];
54456
54457 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
54458 index d1dd710..32ac0e8 100644
54459 --- a/fs/nfsd/nfs4xdr.c
54460 +++ b/fs/nfsd/nfs4xdr.c
54461 @@ -1456,7 +1456,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
54462
54463 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
54464
54465 -static nfsd4_dec nfsd4_dec_ops[] = {
54466 +static const nfsd4_dec nfsd4_dec_ops[] = {
54467 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54468 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54469 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54470 @@ -1496,7 +1496,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
54471 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
54472 };
54473
54474 -static nfsd4_dec nfsd41_dec_ops[] = {
54475 +static const nfsd4_dec nfsd41_dec_ops[] = {
54476 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54477 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54478 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54479 @@ -1558,7 +1558,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
54480 };
54481
54482 struct nfsd4_minorversion_ops {
54483 - nfsd4_dec *decoders;
54484 + const nfsd4_dec *decoders;
54485 int nops;
54486 };
54487
54488 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
54489 index 69c6413..c0408d2 100644
54490 --- a/fs/nfsd/vfs.c
54491 +++ b/fs/nfsd/vfs.c
54492 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54493 } else {
54494 oldfs = get_fs();
54495 set_fs(KERNEL_DS);
54496 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
54497 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
54498 set_fs(oldfs);
54499 }
54500
54501 @@ -1026,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54502
54503 /* Write the data. */
54504 oldfs = get_fs(); set_fs(KERNEL_DS);
54505 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
54506 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
54507 set_fs(oldfs);
54508 if (host_err < 0)
54509 goto out_nfserr;
54510 @@ -1572,7 +1572,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
54511 */
54512
54513 oldfs = get_fs(); set_fs(KERNEL_DS);
54514 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
54515 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
54516 set_fs(oldfs);
54517
54518 if (host_err < 0)
54519 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
54520 index fea6bd5..8ee9d81 100644
54521 --- a/fs/nls/nls_base.c
54522 +++ b/fs/nls/nls_base.c
54523 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
54524
54525 int register_nls(struct nls_table * nls)
54526 {
54527 - struct nls_table ** tmp = &tables;
54528 + struct nls_table *tmp = tables;
54529
54530 if (nls->next)
54531 return -EBUSY;
54532
54533 spin_lock(&nls_lock);
54534 - while (*tmp) {
54535 - if (nls == *tmp) {
54536 + while (tmp) {
54537 + if (nls == tmp) {
54538 spin_unlock(&nls_lock);
54539 return -EBUSY;
54540 }
54541 - tmp = &(*tmp)->next;
54542 + tmp = tmp->next;
54543 }
54544 - nls->next = tables;
54545 + pax_open_kernel();
54546 + *(struct nls_table **)&nls->next = tables;
54547 + pax_close_kernel();
54548 tables = nls;
54549 spin_unlock(&nls_lock);
54550 return 0;
54551 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
54552
54553 int unregister_nls(struct nls_table * nls)
54554 {
54555 - struct nls_table ** tmp = &tables;
54556 + struct nls_table * const * tmp = &tables;
54557
54558 spin_lock(&nls_lock);
54559 while (*tmp) {
54560 if (nls == *tmp) {
54561 - *tmp = nls->next;
54562 + pax_open_kernel();
54563 + *(struct nls_table **)tmp = nls->next;
54564 + pax_close_kernel();
54565 spin_unlock(&nls_lock);
54566 return 0;
54567 }
54568 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
54569 index 7424929..35f6be5 100644
54570 --- a/fs/nls/nls_euc-jp.c
54571 +++ b/fs/nls/nls_euc-jp.c
54572 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
54573 p_nls = load_nls("cp932");
54574
54575 if (p_nls) {
54576 - table.charset2upper = p_nls->charset2upper;
54577 - table.charset2lower = p_nls->charset2lower;
54578 + pax_open_kernel();
54579 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54580 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54581 + pax_close_kernel();
54582 return register_nls(&table);
54583 }
54584
54585 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
54586 index e7bc1d7..06bd4bb 100644
54587 --- a/fs/nls/nls_koi8-ru.c
54588 +++ b/fs/nls/nls_koi8-ru.c
54589 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
54590 p_nls = load_nls("koi8-u");
54591
54592 if (p_nls) {
54593 - table.charset2upper = p_nls->charset2upper;
54594 - table.charset2lower = p_nls->charset2lower;
54595 + pax_open_kernel();
54596 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54597 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54598 + pax_close_kernel();
54599 return register_nls(&table);
54600 }
54601
54602 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
54603 index 9ff4a5e..deb1f0f 100644
54604 --- a/fs/notify/fanotify/fanotify_user.c
54605 +++ b/fs/notify/fanotify/fanotify_user.c
54606 @@ -251,8 +251,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
54607
54608 fd = fanotify_event_metadata.fd;
54609 ret = -EFAULT;
54610 - if (copy_to_user(buf, &fanotify_event_metadata,
54611 - fanotify_event_metadata.event_len))
54612 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
54613 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
54614 goto out_close_fd;
54615
54616 ret = prepare_for_access_response(group, event, fd);
54617 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
54618 index 7b51b05..5ea5ef6 100644
54619 --- a/fs/notify/notification.c
54620 +++ b/fs/notify/notification.c
54621 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
54622 * get set to 0 so it will never get 'freed'
54623 */
54624 static struct fsnotify_event *q_overflow_event;
54625 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54626 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54627
54628 /**
54629 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
54630 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54631 */
54632 u32 fsnotify_get_cookie(void)
54633 {
54634 - return atomic_inc_return(&fsnotify_sync_cookie);
54635 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
54636 }
54637 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
54638
54639 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
54640 index 99e3610..02c1068 100644
54641 --- a/fs/ntfs/dir.c
54642 +++ b/fs/ntfs/dir.c
54643 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
54644 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
54645 ~(s64)(ndir->itype.index.block_size - 1)));
54646 /* Bounds checks. */
54647 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54648 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54649 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
54650 "inode 0x%lx or driver bug.", vdir->i_ino);
54651 goto err_out;
54652 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
54653 index 5b2d4f0..c6de396 100644
54654 --- a/fs/ntfs/file.c
54655 +++ b/fs/ntfs/file.c
54656 @@ -2242,6 +2242,6 @@ const struct inode_operations ntfs_file_inode_ops = {
54657 #endif /* NTFS_RW */
54658 };
54659
54660 -const struct file_operations ntfs_empty_file_ops = {};
54661 +const struct file_operations ntfs_empty_file_ops __read_only;
54662
54663 -const struct inode_operations ntfs_empty_inode_ops = {};
54664 +const struct inode_operations ntfs_empty_inode_ops __read_only;
54665 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
54666 index a9f78c7..ed8a381 100644
54667 --- a/fs/ocfs2/localalloc.c
54668 +++ b/fs/ocfs2/localalloc.c
54669 @@ -1279,7 +1279,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
54670 goto bail;
54671 }
54672
54673 - atomic_inc(&osb->alloc_stats.moves);
54674 + atomic_inc_unchecked(&osb->alloc_stats.moves);
54675
54676 bail:
54677 if (handle)
54678 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
54679 index d355e6e..578d905 100644
54680 --- a/fs/ocfs2/ocfs2.h
54681 +++ b/fs/ocfs2/ocfs2.h
54682 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
54683
54684 struct ocfs2_alloc_stats
54685 {
54686 - atomic_t moves;
54687 - atomic_t local_data;
54688 - atomic_t bitmap_data;
54689 - atomic_t bg_allocs;
54690 - atomic_t bg_extends;
54691 + atomic_unchecked_t moves;
54692 + atomic_unchecked_t local_data;
54693 + atomic_unchecked_t bitmap_data;
54694 + atomic_unchecked_t bg_allocs;
54695 + atomic_unchecked_t bg_extends;
54696 };
54697
54698 enum ocfs2_local_alloc_state
54699 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
54700 index b7e74b5..19c6536 100644
54701 --- a/fs/ocfs2/suballoc.c
54702 +++ b/fs/ocfs2/suballoc.c
54703 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
54704 mlog_errno(status);
54705 goto bail;
54706 }
54707 - atomic_inc(&osb->alloc_stats.bg_extends);
54708 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
54709
54710 /* You should never ask for this much metadata */
54711 BUG_ON(bits_wanted >
54712 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
54713 mlog_errno(status);
54714 goto bail;
54715 }
54716 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54717 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54718
54719 *suballoc_loc = res.sr_bg_blkno;
54720 *suballoc_bit_start = res.sr_bit_offset;
54721 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
54722 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
54723 res->sr_bits);
54724
54725 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54726 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54727
54728 BUG_ON(res->sr_bits != 1);
54729
54730 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
54731 mlog_errno(status);
54732 goto bail;
54733 }
54734 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54735 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54736
54737 BUG_ON(res.sr_bits != 1);
54738
54739 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54740 cluster_start,
54741 num_clusters);
54742 if (!status)
54743 - atomic_inc(&osb->alloc_stats.local_data);
54744 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
54745 } else {
54746 if (min_clusters > (osb->bitmap_cpg - 1)) {
54747 /* The only paths asking for contiguousness
54748 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54749 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
54750 res.sr_bg_blkno,
54751 res.sr_bit_offset);
54752 - atomic_inc(&osb->alloc_stats.bitmap_data);
54753 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
54754 *num_clusters = res.sr_bits;
54755 }
54756 }
54757 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
54758 index 0e91ec2..f4b3fc6 100644
54759 --- a/fs/ocfs2/super.c
54760 +++ b/fs/ocfs2/super.c
54761 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
54762 "%10s => GlobalAllocs: %d LocalAllocs: %d "
54763 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
54764 "Stats",
54765 - atomic_read(&osb->alloc_stats.bitmap_data),
54766 - atomic_read(&osb->alloc_stats.local_data),
54767 - atomic_read(&osb->alloc_stats.bg_allocs),
54768 - atomic_read(&osb->alloc_stats.moves),
54769 - atomic_read(&osb->alloc_stats.bg_extends));
54770 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
54771 + atomic_read_unchecked(&osb->alloc_stats.local_data),
54772 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
54773 + atomic_read_unchecked(&osb->alloc_stats.moves),
54774 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
54775
54776 out += snprintf(buf + out, len - out,
54777 "%10s => State: %u Descriptor: %llu Size: %u bits "
54778 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
54779 spin_lock_init(&osb->osb_xattr_lock);
54780 ocfs2_init_steal_slots(osb);
54781
54782 - atomic_set(&osb->alloc_stats.moves, 0);
54783 - atomic_set(&osb->alloc_stats.local_data, 0);
54784 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
54785 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
54786 - atomic_set(&osb->alloc_stats.bg_extends, 0);
54787 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
54788 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
54789 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
54790 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
54791 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
54792
54793 /* Copy the blockcheck stats from the superblock probe */
54794 osb->osb_ecc_stats = *stats;
54795 diff --git a/fs/open.c b/fs/open.c
54796 index 9b33c0c..2ffcca2 100644
54797 --- a/fs/open.c
54798 +++ b/fs/open.c
54799 @@ -31,6 +31,8 @@
54800 #include <linux/ima.h>
54801 #include <linux/dnotify.h>
54802
54803 +#define CREATE_TRACE_POINTS
54804 +#include <trace/events/fs.h>
54805 #include "internal.h"
54806
54807 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
54808 @@ -101,6 +103,8 @@ long vfs_truncate(struct path *path, loff_t length)
54809 error = locks_verify_truncate(inode, NULL, length);
54810 if (!error)
54811 error = security_path_truncate(path);
54812 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
54813 + error = -EACCES;
54814 if (!error)
54815 error = do_truncate(path->dentry, length, 0, NULL);
54816
54817 @@ -178,6 +182,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
54818 error = locks_verify_truncate(inode, f.file, length);
54819 if (!error)
54820 error = security_path_truncate(&f.file->f_path);
54821 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
54822 + error = -EACCES;
54823 if (!error)
54824 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
54825 sb_end_write(inode->i_sb);
54826 @@ -373,6 +379,9 @@ retry:
54827 if (__mnt_is_readonly(path.mnt))
54828 res = -EROFS;
54829
54830 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
54831 + res = -EACCES;
54832 +
54833 out_path_release:
54834 path_put(&path);
54835 if (retry_estale(res, lookup_flags)) {
54836 @@ -404,6 +413,8 @@ retry:
54837 if (error)
54838 goto dput_and_out;
54839
54840 + gr_log_chdir(path.dentry, path.mnt);
54841 +
54842 set_fs_pwd(current->fs, &path);
54843
54844 dput_and_out:
54845 @@ -433,6 +444,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
54846 goto out_putf;
54847
54848 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
54849 +
54850 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
54851 + error = -EPERM;
54852 +
54853 + if (!error)
54854 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
54855 +
54856 if (!error)
54857 set_fs_pwd(current->fs, &f.file->f_path);
54858 out_putf:
54859 @@ -462,7 +480,13 @@ retry:
54860 if (error)
54861 goto dput_and_out;
54862
54863 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
54864 + goto dput_and_out;
54865 +
54866 set_fs_root(current->fs, &path);
54867 +
54868 + gr_handle_chroot_chdir(&path);
54869 +
54870 error = 0;
54871 dput_and_out:
54872 path_put(&path);
54873 @@ -484,6 +508,16 @@ static int chmod_common(struct path *path, umode_t mode)
54874 if (error)
54875 return error;
54876 mutex_lock(&inode->i_mutex);
54877 +
54878 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
54879 + error = -EACCES;
54880 + goto out_unlock;
54881 + }
54882 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
54883 + error = -EACCES;
54884 + goto out_unlock;
54885 + }
54886 +
54887 error = security_path_chmod(path, mode);
54888 if (error)
54889 goto out_unlock;
54890 @@ -544,6 +578,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
54891 uid = make_kuid(current_user_ns(), user);
54892 gid = make_kgid(current_user_ns(), group);
54893
54894 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
54895 + return -EACCES;
54896 +
54897 newattrs.ia_valid = ATTR_CTIME;
54898 if (user != (uid_t) -1) {
54899 if (!uid_valid(uid))
54900 @@ -960,6 +997,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
54901 } else {
54902 fsnotify_open(f);
54903 fd_install(fd, f);
54904 + trace_do_sys_open(tmp->name, flags, mode);
54905 }
54906 }
54907 putname(tmp);
54908 diff --git a/fs/pipe.c b/fs/pipe.c
54909 index 8e2e73f..1ef1048 100644
54910 --- a/fs/pipe.c
54911 +++ b/fs/pipe.c
54912 @@ -438,9 +438,9 @@ redo:
54913 }
54914 if (bufs) /* More to do? */
54915 continue;
54916 - if (!pipe->writers)
54917 + if (!atomic_read(&pipe->writers))
54918 break;
54919 - if (!pipe->waiting_writers) {
54920 + if (!atomic_read(&pipe->waiting_writers)) {
54921 /* syscall merging: Usually we must not sleep
54922 * if O_NONBLOCK is set, or if we got some data.
54923 * But if a writer sleeps in kernel space, then
54924 @@ -504,7 +504,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
54925 mutex_lock(&inode->i_mutex);
54926 pipe = inode->i_pipe;
54927
54928 - if (!pipe->readers) {
54929 + if (!atomic_read(&pipe->readers)) {
54930 send_sig(SIGPIPE, current, 0);
54931 ret = -EPIPE;
54932 goto out;
54933 @@ -553,7 +553,7 @@ redo1:
54934 for (;;) {
54935 int bufs;
54936
54937 - if (!pipe->readers) {
54938 + if (!atomic_read(&pipe->readers)) {
54939 send_sig(SIGPIPE, current, 0);
54940 if (!ret)
54941 ret = -EPIPE;
54942 @@ -644,9 +644,9 @@ redo2:
54943 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54944 do_wakeup = 0;
54945 }
54946 - pipe->waiting_writers++;
54947 + atomic_inc(&pipe->waiting_writers);
54948 pipe_wait(pipe);
54949 - pipe->waiting_writers--;
54950 + atomic_dec(&pipe->waiting_writers);
54951 }
54952 out:
54953 mutex_unlock(&inode->i_mutex);
54954 @@ -716,7 +716,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54955 mask = 0;
54956 if (filp->f_mode & FMODE_READ) {
54957 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
54958 - if (!pipe->writers && filp->f_version != pipe->w_counter)
54959 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
54960 mask |= POLLHUP;
54961 }
54962
54963 @@ -726,7 +726,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54964 * Most Unices do not set POLLERR for FIFOs but on Linux they
54965 * behave exactly like pipes for poll().
54966 */
54967 - if (!pipe->readers)
54968 + if (!atomic_read(&pipe->readers))
54969 mask |= POLLERR;
54970 }
54971
54972 @@ -740,10 +740,10 @@ pipe_release(struct inode *inode, int decr, int decw)
54973
54974 mutex_lock(&inode->i_mutex);
54975 pipe = inode->i_pipe;
54976 - pipe->readers -= decr;
54977 - pipe->writers -= decw;
54978 + atomic_sub(decr, &pipe->readers);
54979 + atomic_sub(decw, &pipe->writers);
54980
54981 - if (!pipe->readers && !pipe->writers) {
54982 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers)) {
54983 free_pipe_info(inode);
54984 } else {
54985 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
54986 @@ -833,7 +833,7 @@ pipe_read_open(struct inode *inode, struct file *filp)
54987
54988 if (inode->i_pipe) {
54989 ret = 0;
54990 - inode->i_pipe->readers++;
54991 + atomic_inc(&inode->i_pipe->readers);
54992 }
54993
54994 mutex_unlock(&inode->i_mutex);
54995 @@ -850,7 +850,7 @@ pipe_write_open(struct inode *inode, struct file *filp)
54996
54997 if (inode->i_pipe) {
54998 ret = 0;
54999 - inode->i_pipe->writers++;
55000 + atomic_inc(&inode->i_pipe->writers);
55001 }
55002
55003 mutex_unlock(&inode->i_mutex);
55004 @@ -871,9 +871,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
55005 if (inode->i_pipe) {
55006 ret = 0;
55007 if (filp->f_mode & FMODE_READ)
55008 - inode->i_pipe->readers++;
55009 + atomic_inc(&inode->i_pipe->readers);
55010 if (filp->f_mode & FMODE_WRITE)
55011 - inode->i_pipe->writers++;
55012 + atomic_inc(&inode->i_pipe->writers);
55013 }
55014
55015 mutex_unlock(&inode->i_mutex);
55016 @@ -965,7 +965,7 @@ void free_pipe_info(struct inode *inode)
55017 inode->i_pipe = NULL;
55018 }
55019
55020 -static struct vfsmount *pipe_mnt __read_mostly;
55021 +struct vfsmount *pipe_mnt __read_mostly;
55022
55023 /*
55024 * pipefs_dname() is called from d_path().
55025 @@ -995,7 +995,8 @@ static struct inode * get_pipe_inode(void)
55026 goto fail_iput;
55027 inode->i_pipe = pipe;
55028
55029 - pipe->readers = pipe->writers = 1;
55030 + atomic_set(&pipe->readers, 1);
55031 + atomic_set(&pipe->writers, 1);
55032 inode->i_fop = &rdwr_pipefifo_fops;
55033
55034 /*
55035 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
55036 index 15af622..0e9f4467 100644
55037 --- a/fs/proc/Kconfig
55038 +++ b/fs/proc/Kconfig
55039 @@ -30,12 +30,12 @@ config PROC_FS
55040
55041 config PROC_KCORE
55042 bool "/proc/kcore support" if !ARM
55043 - depends on PROC_FS && MMU
55044 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
55045
55046 config PROC_VMCORE
55047 bool "/proc/vmcore support"
55048 - depends on PROC_FS && CRASH_DUMP
55049 - default y
55050 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
55051 + default n
55052 help
55053 Exports the dump image of crashed kernel in ELF format.
55054
55055 @@ -59,8 +59,8 @@ config PROC_SYSCTL
55056 limited in memory.
55057
55058 config PROC_PAGE_MONITOR
55059 - default y
55060 - depends on PROC_FS && MMU
55061 + default n
55062 + depends on PROC_FS && MMU && !GRKERNSEC
55063 bool "Enable /proc page monitoring" if EXPERT
55064 help
55065 Various /proc files exist to monitor process memory utilization:
55066 diff --git a/fs/proc/array.c b/fs/proc/array.c
55067 index 6a91e6f..e54dbc14 100644
55068 --- a/fs/proc/array.c
55069 +++ b/fs/proc/array.c
55070 @@ -60,6 +60,7 @@
55071 #include <linux/tty.h>
55072 #include <linux/string.h>
55073 #include <linux/mman.h>
55074 +#include <linux/grsecurity.h>
55075 #include <linux/proc_fs.h>
55076 #include <linux/ioport.h>
55077 #include <linux/uaccess.h>
55078 @@ -362,6 +363,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
55079 seq_putc(m, '\n');
55080 }
55081
55082 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
55083 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
55084 +{
55085 + if (p->mm)
55086 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
55087 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
55088 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
55089 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
55090 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
55091 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
55092 + else
55093 + seq_printf(m, "PaX:\t-----\n");
55094 +}
55095 +#endif
55096 +
55097 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55098 struct pid *pid, struct task_struct *task)
55099 {
55100 @@ -380,9 +396,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55101 task_cpus_allowed(m, task);
55102 cpuset_task_status_allowed(m, task);
55103 task_context_switch_counts(m, task);
55104 +
55105 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
55106 + task_pax(m, task);
55107 +#endif
55108 +
55109 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
55110 + task_grsec_rbac(m, task);
55111 +#endif
55112 +
55113 return 0;
55114 }
55115
55116 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55117 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55118 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55119 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55120 +#endif
55121 +
55122 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55123 struct pid *pid, struct task_struct *task, int whole)
55124 {
55125 @@ -404,6 +435,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55126 char tcomm[sizeof(task->comm)];
55127 unsigned long flags;
55128
55129 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55130 + if (current->exec_id != m->exec_id) {
55131 + gr_log_badprocpid("stat");
55132 + return 0;
55133 + }
55134 +#endif
55135 +
55136 state = *get_task_state(task);
55137 vsize = eip = esp = 0;
55138 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55139 @@ -475,6 +513,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55140 gtime = task->gtime;
55141 }
55142
55143 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55144 + if (PAX_RAND_FLAGS(mm)) {
55145 + eip = 0;
55146 + esp = 0;
55147 + wchan = 0;
55148 + }
55149 +#endif
55150 +#ifdef CONFIG_GRKERNSEC_HIDESYM
55151 + wchan = 0;
55152 + eip =0;
55153 + esp =0;
55154 +#endif
55155 +
55156 /* scale priority and nice values from timeslices to -20..20 */
55157 /* to make it look like a "normal" Unix priority/nice value */
55158 priority = task_prio(task);
55159 @@ -511,9 +562,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55160 seq_put_decimal_ull(m, ' ', vsize);
55161 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
55162 seq_put_decimal_ull(m, ' ', rsslim);
55163 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55164 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
55165 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
55166 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
55167 +#else
55168 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
55169 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
55170 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
55171 +#endif
55172 seq_put_decimal_ull(m, ' ', esp);
55173 seq_put_decimal_ull(m, ' ', eip);
55174 /* The signal information here is obsolete.
55175 @@ -535,7 +592,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55176 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
55177 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
55178
55179 - if (mm && permitted) {
55180 + if (mm && permitted
55181 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55182 + && !PAX_RAND_FLAGS(mm)
55183 +#endif
55184 + ) {
55185 seq_put_decimal_ull(m, ' ', mm->start_data);
55186 seq_put_decimal_ull(m, ' ', mm->end_data);
55187 seq_put_decimal_ull(m, ' ', mm->start_brk);
55188 @@ -573,8 +634,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55189 struct pid *pid, struct task_struct *task)
55190 {
55191 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
55192 - struct mm_struct *mm = get_task_mm(task);
55193 + struct mm_struct *mm;
55194
55195 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55196 + if (current->exec_id != m->exec_id) {
55197 + gr_log_badprocpid("statm");
55198 + return 0;
55199 + }
55200 +#endif
55201 + mm = get_task_mm(task);
55202 if (mm) {
55203 size = task_statm(mm, &shared, &text, &data, &resident);
55204 mmput(mm);
55205 @@ -597,6 +665,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55206 return 0;
55207 }
55208
55209 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55210 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
55211 +{
55212 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
55213 +}
55214 +#endif
55215 +
55216 #ifdef CONFIG_CHECKPOINT_RESTORE
55217 static struct pid *
55218 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
55219 diff --git a/fs/proc/base.c b/fs/proc/base.c
55220 index 9b43ff77..0fa9564 100644
55221 --- a/fs/proc/base.c
55222 +++ b/fs/proc/base.c
55223 @@ -111,6 +111,14 @@ struct pid_entry {
55224 union proc_op op;
55225 };
55226
55227 +struct getdents_callback {
55228 + struct linux_dirent __user * current_dir;
55229 + struct linux_dirent __user * previous;
55230 + struct file * file;
55231 + int count;
55232 + int error;
55233 +};
55234 +
55235 #define NOD(NAME, MODE, IOP, FOP, OP) { \
55236 .name = (NAME), \
55237 .len = sizeof(NAME) - 1, \
55238 @@ -208,6 +216,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
55239 if (!mm->arg_end)
55240 goto out_mm; /* Shh! No looking before we're done */
55241
55242 + if (gr_acl_handle_procpidmem(task))
55243 + goto out_mm;
55244 +
55245 len = mm->arg_end - mm->arg_start;
55246
55247 if (len > PAGE_SIZE)
55248 @@ -235,12 +246,28 @@ out:
55249 return res;
55250 }
55251
55252 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55253 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55254 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55255 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55256 +#endif
55257 +
55258 static int proc_pid_auxv(struct task_struct *task, char *buffer)
55259 {
55260 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
55261 int res = PTR_ERR(mm);
55262 if (mm && !IS_ERR(mm)) {
55263 unsigned int nwords = 0;
55264 +
55265 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55266 + /* allow if we're currently ptracing this task */
55267 + if (PAX_RAND_FLAGS(mm) &&
55268 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
55269 + mmput(mm);
55270 + return 0;
55271 + }
55272 +#endif
55273 +
55274 do {
55275 nwords += 2;
55276 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
55277 @@ -254,7 +281,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
55278 }
55279
55280
55281 -#ifdef CONFIG_KALLSYMS
55282 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55283 /*
55284 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
55285 * Returns the resolved symbol. If that fails, simply return the address.
55286 @@ -293,7 +320,7 @@ static void unlock_trace(struct task_struct *task)
55287 mutex_unlock(&task->signal->cred_guard_mutex);
55288 }
55289
55290 -#ifdef CONFIG_STACKTRACE
55291 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55292
55293 #define MAX_STACK_TRACE_DEPTH 64
55294
55295 @@ -485,7 +512,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
55296 return count;
55297 }
55298
55299 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55300 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55301 static int proc_pid_syscall(struct task_struct *task, char *buffer)
55302 {
55303 long nr;
55304 @@ -514,7 +541,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
55305 /************************************************************************/
55306
55307 /* permission checks */
55308 -static int proc_fd_access_allowed(struct inode *inode)
55309 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
55310 {
55311 struct task_struct *task;
55312 int allowed = 0;
55313 @@ -524,7 +551,10 @@ static int proc_fd_access_allowed(struct inode *inode)
55314 */
55315 task = get_proc_task(inode);
55316 if (task) {
55317 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55318 + if (log)
55319 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55320 + else
55321 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55322 put_task_struct(task);
55323 }
55324 return allowed;
55325 @@ -555,10 +585,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
55326 struct task_struct *task,
55327 int hide_pid_min)
55328 {
55329 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55330 + return false;
55331 +
55332 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55333 + rcu_read_lock();
55334 + {
55335 + const struct cred *tmpcred = current_cred();
55336 + const struct cred *cred = __task_cred(task);
55337 +
55338 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
55339 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55340 + || in_group_p(grsec_proc_gid)
55341 +#endif
55342 + ) {
55343 + rcu_read_unlock();
55344 + return true;
55345 + }
55346 + }
55347 + rcu_read_unlock();
55348 +
55349 + if (!pid->hide_pid)
55350 + return false;
55351 +#endif
55352 +
55353 if (pid->hide_pid < hide_pid_min)
55354 return true;
55355 if (in_group_p(pid->pid_gid))
55356 return true;
55357 +
55358 return ptrace_may_access(task, PTRACE_MODE_READ);
55359 }
55360
55361 @@ -576,7 +631,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
55362 put_task_struct(task);
55363
55364 if (!has_perms) {
55365 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55366 + {
55367 +#else
55368 if (pid->hide_pid == 2) {
55369 +#endif
55370 /*
55371 * Let's make getdents(), stat(), and open()
55372 * consistent with each other. If a process
55373 @@ -674,6 +733,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55374 if (!task)
55375 return -ESRCH;
55376
55377 + if (gr_acl_handle_procpidmem(task)) {
55378 + put_task_struct(task);
55379 + return -EPERM;
55380 + }
55381 +
55382 mm = mm_access(task, mode);
55383 put_task_struct(task);
55384
55385 @@ -689,6 +753,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55386
55387 file->private_data = mm;
55388
55389 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55390 + file->f_version = current->exec_id;
55391 +#endif
55392 +
55393 return 0;
55394 }
55395
55396 @@ -710,6 +778,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55397 ssize_t copied;
55398 char *page;
55399
55400 +#ifdef CONFIG_GRKERNSEC
55401 + if (write)
55402 + return -EPERM;
55403 +#endif
55404 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55405 + if (file->f_version != current->exec_id) {
55406 + gr_log_badprocpid("mem");
55407 + return 0;
55408 + }
55409 +#endif
55410 +
55411 if (!mm)
55412 return 0;
55413
55414 @@ -722,7 +801,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55415 goto free;
55416
55417 while (count > 0) {
55418 - int this_len = min_t(int, count, PAGE_SIZE);
55419 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
55420
55421 if (write && copy_from_user(page, buf, this_len)) {
55422 copied = -EFAULT;
55423 @@ -814,6 +893,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55424 if (!mm)
55425 return 0;
55426
55427 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55428 + if (file->f_version != current->exec_id) {
55429 + gr_log_badprocpid("environ");
55430 + return 0;
55431 + }
55432 +#endif
55433 +
55434 page = (char *)__get_free_page(GFP_TEMPORARY);
55435 if (!page)
55436 return -ENOMEM;
55437 @@ -823,7 +909,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55438 goto free;
55439 while (count > 0) {
55440 size_t this_len, max_len;
55441 - int retval;
55442 + ssize_t retval;
55443
55444 if (src >= (mm->env_end - mm->env_start))
55445 break;
55446 @@ -1429,7 +1515,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
55447 int error = -EACCES;
55448
55449 /* Are we allowed to snoop on the tasks file descriptors? */
55450 - if (!proc_fd_access_allowed(inode))
55451 + if (!proc_fd_access_allowed(inode, 0))
55452 goto out;
55453
55454 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55455 @@ -1473,8 +1559,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
55456 struct path path;
55457
55458 /* Are we allowed to snoop on the tasks file descriptors? */
55459 - if (!proc_fd_access_allowed(inode))
55460 - goto out;
55461 + /* logging this is needed for learning on chromium to work properly,
55462 + but we don't want to flood the logs from 'ps' which does a readlink
55463 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
55464 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
55465 + */
55466 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
55467 + if (!proc_fd_access_allowed(inode,0))
55468 + goto out;
55469 + } else {
55470 + if (!proc_fd_access_allowed(inode,1))
55471 + goto out;
55472 + }
55473
55474 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55475 if (error)
55476 @@ -1524,7 +1620,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
55477 rcu_read_lock();
55478 cred = __task_cred(task);
55479 inode->i_uid = cred->euid;
55480 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55481 + inode->i_gid = grsec_proc_gid;
55482 +#else
55483 inode->i_gid = cred->egid;
55484 +#endif
55485 rcu_read_unlock();
55486 }
55487 security_task_to_inode(task, inode);
55488 @@ -1560,10 +1660,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
55489 return -ENOENT;
55490 }
55491 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55492 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55493 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55494 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55495 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55496 +#endif
55497 task_dumpable(task)) {
55498 cred = __task_cred(task);
55499 stat->uid = cred->euid;
55500 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55501 + stat->gid = grsec_proc_gid;
55502 +#else
55503 stat->gid = cred->egid;
55504 +#endif
55505 }
55506 }
55507 rcu_read_unlock();
55508 @@ -1601,11 +1710,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
55509
55510 if (task) {
55511 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55512 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55513 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55514 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55515 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55516 +#endif
55517 task_dumpable(task)) {
55518 rcu_read_lock();
55519 cred = __task_cred(task);
55520 inode->i_uid = cred->euid;
55521 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55522 + inode->i_gid = grsec_proc_gid;
55523 +#else
55524 inode->i_gid = cred->egid;
55525 +#endif
55526 rcu_read_unlock();
55527 } else {
55528 inode->i_uid = GLOBAL_ROOT_UID;
55529 @@ -2058,6 +2176,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
55530 if (!task)
55531 goto out_no_task;
55532
55533 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55534 + goto out;
55535 +
55536 /*
55537 * Yes, it does not scale. And it should not. Don't add
55538 * new entries into /proc/<tgid>/ without very good reasons.
55539 @@ -2102,6 +2223,9 @@ static int proc_pident_readdir(struct file *filp,
55540 if (!task)
55541 goto out_no_task;
55542
55543 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55544 + goto out;
55545 +
55546 ret = 0;
55547 i = filp->f_pos;
55548 switch (i) {
55549 @@ -2515,7 +2639,7 @@ static const struct pid_entry tgid_base_stuff[] = {
55550 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
55551 #endif
55552 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55553 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55554 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55555 INF("syscall", S_IRUGO, proc_pid_syscall),
55556 #endif
55557 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55558 @@ -2540,10 +2664,10 @@ static const struct pid_entry tgid_base_stuff[] = {
55559 #ifdef CONFIG_SECURITY
55560 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55561 #endif
55562 -#ifdef CONFIG_KALLSYMS
55563 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55564 INF("wchan", S_IRUGO, proc_pid_wchan),
55565 #endif
55566 -#ifdef CONFIG_STACKTRACE
55567 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55568 ONE("stack", S_IRUGO, proc_pid_stack),
55569 #endif
55570 #ifdef CONFIG_SCHEDSTATS
55571 @@ -2577,6 +2701,9 @@ static const struct pid_entry tgid_base_stuff[] = {
55572 #ifdef CONFIG_HARDWALL
55573 INF("hardwall", S_IRUGO, proc_pid_hardwall),
55574 #endif
55575 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55576 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
55577 +#endif
55578 #ifdef CONFIG_USER_NS
55579 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
55580 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
55581 @@ -2705,7 +2832,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
55582 if (!inode)
55583 goto out;
55584
55585 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55586 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
55587 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55588 + inode->i_gid = grsec_proc_gid;
55589 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
55590 +#else
55591 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
55592 +#endif
55593 inode->i_op = &proc_tgid_base_inode_operations;
55594 inode->i_fop = &proc_tgid_base_operations;
55595 inode->i_flags|=S_IMMUTABLE;
55596 @@ -2743,7 +2877,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
55597 if (!task)
55598 goto out;
55599
55600 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55601 + goto out_put_task;
55602 +
55603 result = proc_pid_instantiate(dir, dentry, task, NULL);
55604 +out_put_task:
55605 put_task_struct(task);
55606 out:
55607 return result;
55608 @@ -2806,6 +2944,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
55609 static int fake_filldir(void *buf, const char *name, int namelen,
55610 loff_t offset, u64 ino, unsigned d_type)
55611 {
55612 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
55613 + __buf->error = -EINVAL;
55614 return 0;
55615 }
55616
55617 @@ -2857,7 +2997,7 @@ static const struct pid_entry tid_base_stuff[] = {
55618 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
55619 #endif
55620 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55621 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55622 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55623 INF("syscall", S_IRUGO, proc_pid_syscall),
55624 #endif
55625 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55626 @@ -2884,10 +3024,10 @@ static const struct pid_entry tid_base_stuff[] = {
55627 #ifdef CONFIG_SECURITY
55628 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55629 #endif
55630 -#ifdef CONFIG_KALLSYMS
55631 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55632 INF("wchan", S_IRUGO, proc_pid_wchan),
55633 #endif
55634 -#ifdef CONFIG_STACKTRACE
55635 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55636 ONE("stack", S_IRUGO, proc_pid_stack),
55637 #endif
55638 #ifdef CONFIG_SCHEDSTATS
55639 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
55640 index 82676e3..5f8518a 100644
55641 --- a/fs/proc/cmdline.c
55642 +++ b/fs/proc/cmdline.c
55643 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
55644
55645 static int __init proc_cmdline_init(void)
55646 {
55647 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55648 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
55649 +#else
55650 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
55651 +#endif
55652 return 0;
55653 }
55654 module_init(proc_cmdline_init);
55655 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
55656 index b143471..bb105e5 100644
55657 --- a/fs/proc/devices.c
55658 +++ b/fs/proc/devices.c
55659 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
55660
55661 static int __init proc_devices_init(void)
55662 {
55663 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55664 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
55665 +#else
55666 proc_create("devices", 0, NULL, &proc_devinfo_operations);
55667 +#endif
55668 return 0;
55669 }
55670 module_init(proc_devices_init);
55671 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
55672 index d7a4a28..0201742 100644
55673 --- a/fs/proc/fd.c
55674 +++ b/fs/proc/fd.c
55675 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
55676 if (!task)
55677 return -ENOENT;
55678
55679 - files = get_files_struct(task);
55680 + if (!gr_acl_handle_procpidmem(task))
55681 + files = get_files_struct(task);
55682 put_task_struct(task);
55683
55684 if (files) {
55685 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
55686 */
55687 int proc_fd_permission(struct inode *inode, int mask)
55688 {
55689 + struct task_struct *task;
55690 int rv = generic_permission(inode, mask);
55691 - if (rv == 0)
55692 - return 0;
55693 +
55694 if (task_pid(current) == proc_pid(inode))
55695 rv = 0;
55696 +
55697 + task = get_proc_task(inode);
55698 + if (task == NULL)
55699 + return rv;
55700 +
55701 + if (gr_acl_handle_procpidmem(task))
55702 + rv = -EACCES;
55703 +
55704 + put_task_struct(task);
55705 +
55706 return rv;
55707 }
55708
55709 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
55710 index 0ac1e1b..0497e58 100644
55711 --- a/fs/proc/inode.c
55712 +++ b/fs/proc/inode.c
55713 @@ -21,11 +21,17 @@
55714 #include <linux/seq_file.h>
55715 #include <linux/slab.h>
55716 #include <linux/mount.h>
55717 +#include <linux/grsecurity.h>
55718
55719 #include <asm/uaccess.h>
55720
55721 #include "internal.h"
55722
55723 +#ifdef CONFIG_PROC_SYSCTL
55724 +extern const struct inode_operations proc_sys_inode_operations;
55725 +extern const struct inode_operations proc_sys_dir_operations;
55726 +#endif
55727 +
55728 static void proc_evict_inode(struct inode *inode)
55729 {
55730 struct proc_dir_entry *de;
55731 @@ -53,6 +59,13 @@ static void proc_evict_inode(struct inode *inode)
55732 ns = PROC_I(inode)->ns;
55733 if (ns_ops && ns)
55734 ns_ops->put(ns);
55735 +
55736 +#ifdef CONFIG_PROC_SYSCTL
55737 + if (inode->i_op == &proc_sys_inode_operations ||
55738 + inode->i_op == &proc_sys_dir_operations)
55739 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
55740 +#endif
55741 +
55742 }
55743
55744 static struct kmem_cache * proc_inode_cachep;
55745 @@ -455,7 +468,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
55746 if (de->mode) {
55747 inode->i_mode = de->mode;
55748 inode->i_uid = de->uid;
55749 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55750 + inode->i_gid = grsec_proc_gid;
55751 +#else
55752 inode->i_gid = de->gid;
55753 +#endif
55754 }
55755 if (de->size)
55756 inode->i_size = de->size;
55757 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
55758 index 252544c..04395b9 100644
55759 --- a/fs/proc/internal.h
55760 +++ b/fs/proc/internal.h
55761 @@ -55,6 +55,9 @@ extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55762 struct pid *pid, struct task_struct *task);
55763 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55764 struct pid *pid, struct task_struct *task);
55765 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55766 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
55767 +#endif
55768 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
55769
55770 extern const struct file_operations proc_tid_children_operations;
55771 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
55772 index e96d4f1..8b116ed 100644
55773 --- a/fs/proc/kcore.c
55774 +++ b/fs/proc/kcore.c
55775 @@ -480,9 +480,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55776 * the addresses in the elf_phdr on our list.
55777 */
55778 start = kc_offset_to_vaddr(*fpos - elf_buflen);
55779 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
55780 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
55781 + if (tsz > buflen)
55782 tsz = buflen;
55783 -
55784 +
55785 while (buflen) {
55786 struct kcore_list *m;
55787
55788 @@ -511,20 +512,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55789 kfree(elf_buf);
55790 } else {
55791 if (kern_addr_valid(start)) {
55792 - unsigned long n;
55793 + char *elf_buf;
55794 + mm_segment_t oldfs;
55795
55796 - n = copy_to_user(buffer, (char *)start, tsz);
55797 - /*
55798 - * We cannot distinguish between fault on source
55799 - * and fault on destination. When this happens
55800 - * we clear too and hope it will trigger the
55801 - * EFAULT again.
55802 - */
55803 - if (n) {
55804 - if (clear_user(buffer + tsz - n,
55805 - n))
55806 + elf_buf = kmalloc(tsz, GFP_KERNEL);
55807 + if (!elf_buf)
55808 + return -ENOMEM;
55809 + oldfs = get_fs();
55810 + set_fs(KERNEL_DS);
55811 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
55812 + set_fs(oldfs);
55813 + if (copy_to_user(buffer, elf_buf, tsz)) {
55814 + kfree(elf_buf);
55815 return -EFAULT;
55816 + }
55817 }
55818 + set_fs(oldfs);
55819 + kfree(elf_buf);
55820 } else {
55821 if (clear_user(buffer, tsz))
55822 return -EFAULT;
55823 @@ -544,6 +548,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55824
55825 static int open_kcore(struct inode *inode, struct file *filp)
55826 {
55827 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
55828 + return -EPERM;
55829 +#endif
55830 if (!capable(CAP_SYS_RAWIO))
55831 return -EPERM;
55832 if (kcore_need_update)
55833 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
55834 index 80e4645..53e5fcf 100644
55835 --- a/fs/proc/meminfo.c
55836 +++ b/fs/proc/meminfo.c
55837 @@ -158,7 +158,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
55838 vmi.used >> 10,
55839 vmi.largest_chunk >> 10
55840 #ifdef CONFIG_MEMORY_FAILURE
55841 - ,atomic_long_read(&mce_bad_pages) << (PAGE_SHIFT - 10)
55842 + ,atomic_long_read_unchecked(&mce_bad_pages) << (PAGE_SHIFT - 10)
55843 #endif
55844 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
55845 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
55846 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
55847 index b1822dd..df622cb 100644
55848 --- a/fs/proc/nommu.c
55849 +++ b/fs/proc/nommu.c
55850 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
55851 if (len < 1)
55852 len = 1;
55853 seq_printf(m, "%*c", len, ' ');
55854 - seq_path(m, &file->f_path, "");
55855 + seq_path(m, &file->f_path, "\n\\");
55856 }
55857
55858 seq_putc(m, '\n');
55859 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
55860 index fe72cd0..21b52ff 100644
55861 --- a/fs/proc/proc_net.c
55862 +++ b/fs/proc/proc_net.c
55863 @@ -23,6 +23,7 @@
55864 #include <linux/nsproxy.h>
55865 #include <net/net_namespace.h>
55866 #include <linux/seq_file.h>
55867 +#include <linux/grsecurity.h>
55868
55869 #include "internal.h"
55870
55871 @@ -105,6 +106,17 @@ static struct net *get_proc_task_net(struct inode *dir)
55872 struct task_struct *task;
55873 struct nsproxy *ns;
55874 struct net *net = NULL;
55875 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55876 + const struct cred *cred = current_cred();
55877 +#endif
55878 +
55879 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55880 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
55881 + return net;
55882 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55883 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
55884 + return net;
55885 +#endif
55886
55887 rcu_read_lock();
55888 task = pid_task(proc_pid(dir), PIDTYPE_PID);
55889 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
55890 index 1827d88..43b0279 100644
55891 --- a/fs/proc/proc_sysctl.c
55892 +++ b/fs/proc/proc_sysctl.c
55893 @@ -12,11 +12,15 @@
55894 #include <linux/module.h>
55895 #include "internal.h"
55896
55897 +extern int gr_handle_chroot_sysctl(const int op);
55898 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
55899 + const int op);
55900 +
55901 static const struct dentry_operations proc_sys_dentry_operations;
55902 static const struct file_operations proc_sys_file_operations;
55903 -static const struct inode_operations proc_sys_inode_operations;
55904 +const struct inode_operations proc_sys_inode_operations;
55905 static const struct file_operations proc_sys_dir_file_operations;
55906 -static const struct inode_operations proc_sys_dir_operations;
55907 +const struct inode_operations proc_sys_dir_operations;
55908
55909 void proc_sys_poll_notify(struct ctl_table_poll *poll)
55910 {
55911 @@ -466,6 +470,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
55912
55913 err = NULL;
55914 d_set_d_op(dentry, &proc_sys_dentry_operations);
55915 +
55916 + gr_handle_proc_create(dentry, inode);
55917 +
55918 d_add(dentry, inode);
55919
55920 out:
55921 @@ -481,6 +488,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55922 struct inode *inode = filp->f_path.dentry->d_inode;
55923 struct ctl_table_header *head = grab_header(inode);
55924 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
55925 + int op = write ? MAY_WRITE : MAY_READ;
55926 ssize_t error;
55927 size_t res;
55928
55929 @@ -492,7 +500,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55930 * and won't be until we finish.
55931 */
55932 error = -EPERM;
55933 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
55934 + if (sysctl_perm(head, table, op))
55935 goto out;
55936
55937 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
55938 @@ -500,6 +508,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55939 if (!table->proc_handler)
55940 goto out;
55941
55942 +#ifdef CONFIG_GRKERNSEC
55943 + error = -EPERM;
55944 + if (gr_handle_chroot_sysctl(op))
55945 + goto out;
55946 + dget(filp->f_path.dentry);
55947 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
55948 + dput(filp->f_path.dentry);
55949 + goto out;
55950 + }
55951 + dput(filp->f_path.dentry);
55952 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
55953 + goto out;
55954 + if (write && !capable(CAP_SYS_ADMIN))
55955 + goto out;
55956 +#endif
55957 +
55958 /* careful: calling conventions are nasty here */
55959 res = count;
55960 error = table->proc_handler(table, write, buf, &res, ppos);
55961 @@ -597,6 +621,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
55962 return -ENOMEM;
55963 } else {
55964 d_set_d_op(child, &proc_sys_dentry_operations);
55965 +
55966 + gr_handle_proc_create(child, inode);
55967 +
55968 d_add(child, inode);
55969 }
55970 } else {
55971 @@ -640,6 +667,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
55972 if ((*pos)++ < file->f_pos)
55973 return 0;
55974
55975 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
55976 + return 0;
55977 +
55978 if (unlikely(S_ISLNK(table->mode)))
55979 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
55980 else
55981 @@ -750,6 +780,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
55982 if (IS_ERR(head))
55983 return PTR_ERR(head);
55984
55985 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
55986 + return -ENOENT;
55987 +
55988 generic_fillattr(inode, stat);
55989 if (table)
55990 stat->mode = (stat->mode & S_IFMT) | table->mode;
55991 @@ -772,13 +805,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
55992 .llseek = generic_file_llseek,
55993 };
55994
55995 -static const struct inode_operations proc_sys_inode_operations = {
55996 +const struct inode_operations proc_sys_inode_operations = {
55997 .permission = proc_sys_permission,
55998 .setattr = proc_sys_setattr,
55999 .getattr = proc_sys_getattr,
56000 };
56001
56002 -static const struct inode_operations proc_sys_dir_operations = {
56003 +const struct inode_operations proc_sys_dir_operations = {
56004 .lookup = proc_sys_lookup,
56005 .permission = proc_sys_permission,
56006 .setattr = proc_sys_setattr,
56007 @@ -854,7 +887,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
56008 static struct ctl_dir *new_dir(struct ctl_table_set *set,
56009 const char *name, int namelen)
56010 {
56011 - struct ctl_table *table;
56012 + ctl_table_no_const *table;
56013 struct ctl_dir *new;
56014 struct ctl_node *node;
56015 char *new_name;
56016 @@ -866,7 +899,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
56017 return NULL;
56018
56019 node = (struct ctl_node *)(new + 1);
56020 - table = (struct ctl_table *)(node + 1);
56021 + table = (ctl_table_no_const *)(node + 1);
56022 new_name = (char *)(table + 2);
56023 memcpy(new_name, name, namelen);
56024 new_name[namelen] = '\0';
56025 @@ -1035,7 +1068,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
56026 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
56027 struct ctl_table_root *link_root)
56028 {
56029 - struct ctl_table *link_table, *entry, *link;
56030 + ctl_table_no_const *link_table, *link;
56031 + struct ctl_table *entry;
56032 struct ctl_table_header *links;
56033 struct ctl_node *node;
56034 char *link_name;
56035 @@ -1058,7 +1092,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
56036 return NULL;
56037
56038 node = (struct ctl_node *)(links + 1);
56039 - link_table = (struct ctl_table *)(node + nr_entries);
56040 + link_table = (ctl_table_no_const *)(node + nr_entries);
56041 link_name = (char *)&link_table[nr_entries + 1];
56042
56043 for (link = link_table, entry = table; entry->procname; link++, entry++) {
56044 @@ -1306,8 +1340,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56045 struct ctl_table_header ***subheader, struct ctl_table_set *set,
56046 struct ctl_table *table)
56047 {
56048 - struct ctl_table *ctl_table_arg = NULL;
56049 - struct ctl_table *entry, *files;
56050 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
56051 + struct ctl_table *entry;
56052 int nr_files = 0;
56053 int nr_dirs = 0;
56054 int err = -ENOMEM;
56055 @@ -1319,10 +1353,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56056 nr_files++;
56057 }
56058
56059 - files = table;
56060 /* If there are mixed files and directories we need a new table */
56061 if (nr_dirs && nr_files) {
56062 - struct ctl_table *new;
56063 + ctl_table_no_const *new;
56064 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
56065 GFP_KERNEL);
56066 if (!files)
56067 @@ -1340,7 +1373,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56068 /* Register everything except a directory full of subdirectories */
56069 if (nr_files || !nr_dirs) {
56070 struct ctl_table_header *header;
56071 - header = __register_sysctl_table(set, path, files);
56072 + header = __register_sysctl_table(set, path, files ? files : table);
56073 if (!header) {
56074 kfree(ctl_table_arg);
56075 goto out;
56076 diff --git a/fs/proc/root.c b/fs/proc/root.c
56077 index 9c7fab1..ed1c8e0 100644
56078 --- a/fs/proc/root.c
56079 +++ b/fs/proc/root.c
56080 @@ -180,7 +180,15 @@ void __init proc_root_init(void)
56081 #ifdef CONFIG_PROC_DEVICETREE
56082 proc_device_tree_init();
56083 #endif
56084 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
56085 +#ifdef CONFIG_GRKERNSEC_PROC_USER
56086 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
56087 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
56088 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
56089 +#endif
56090 +#else
56091 proc_mkdir("bus", NULL);
56092 +#endif
56093 proc_sys_init();
56094 }
56095
56096 diff --git a/fs/proc/self.c b/fs/proc/self.c
56097 index aa5cc3b..c91a5d0 100644
56098 --- a/fs/proc/self.c
56099 +++ b/fs/proc/self.c
56100 @@ -37,7 +37,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
56101 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
56102 void *cookie)
56103 {
56104 - char *s = nd_get_link(nd);
56105 + const char *s = nd_get_link(nd);
56106 if (!IS_ERR(s))
56107 kfree(s);
56108 }
56109 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
56110 index ca5ce7f..02c1cf0 100644
56111 --- a/fs/proc/task_mmu.c
56112 +++ b/fs/proc/task_mmu.c
56113 @@ -11,12 +11,19 @@
56114 #include <linux/rmap.h>
56115 #include <linux/swap.h>
56116 #include <linux/swapops.h>
56117 +#include <linux/grsecurity.h>
56118
56119 #include <asm/elf.h>
56120 #include <asm/uaccess.h>
56121 #include <asm/tlbflush.h>
56122 #include "internal.h"
56123
56124 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56125 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
56126 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
56127 + _mm->pax_flags & MF_PAX_SEGMEXEC))
56128 +#endif
56129 +
56130 void task_mem(struct seq_file *m, struct mm_struct *mm)
56131 {
56132 unsigned long data, text, lib, swap;
56133 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56134 "VmExe:\t%8lu kB\n"
56135 "VmLib:\t%8lu kB\n"
56136 "VmPTE:\t%8lu kB\n"
56137 - "VmSwap:\t%8lu kB\n",
56138 - hiwater_vm << (PAGE_SHIFT-10),
56139 + "VmSwap:\t%8lu kB\n"
56140 +
56141 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56142 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
56143 +#endif
56144 +
56145 + ,hiwater_vm << (PAGE_SHIFT-10),
56146 total_vm << (PAGE_SHIFT-10),
56147 mm->locked_vm << (PAGE_SHIFT-10),
56148 mm->pinned_vm << (PAGE_SHIFT-10),
56149 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56150 data << (PAGE_SHIFT-10),
56151 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
56152 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
56153 - swap << (PAGE_SHIFT-10));
56154 + swap << (PAGE_SHIFT-10)
56155 +
56156 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56157 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56158 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
56159 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
56160 +#else
56161 + , mm->context.user_cs_base
56162 + , mm->context.user_cs_limit
56163 +#endif
56164 +#endif
56165 +
56166 + );
56167 }
56168
56169 unsigned long task_vsize(struct mm_struct *mm)
56170 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56171 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
56172 }
56173
56174 - /* We don't show the stack guard page in /proc/maps */
56175 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56176 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
56177 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
56178 +#else
56179 start = vma->vm_start;
56180 - if (stack_guard_page_start(vma, start))
56181 - start += PAGE_SIZE;
56182 end = vma->vm_end;
56183 - if (stack_guard_page_end(vma, end))
56184 - end -= PAGE_SIZE;
56185 +#endif
56186
56187 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
56188 start,
56189 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56190 flags & VM_WRITE ? 'w' : '-',
56191 flags & VM_EXEC ? 'x' : '-',
56192 flags & VM_MAYSHARE ? 's' : 'p',
56193 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56194 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
56195 +#else
56196 pgoff,
56197 +#endif
56198 MAJOR(dev), MINOR(dev), ino, &len);
56199
56200 /*
56201 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56202 */
56203 if (file) {
56204 pad_len_spaces(m, len);
56205 - seq_path(m, &file->f_path, "\n");
56206 + seq_path(m, &file->f_path, "\n\\");
56207 goto done;
56208 }
56209
56210 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56211 * Thread stack in /proc/PID/task/TID/maps or
56212 * the main process stack.
56213 */
56214 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
56215 - vma->vm_end >= mm->start_stack)) {
56216 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
56217 + (vma->vm_start <= mm->start_stack &&
56218 + vma->vm_end >= mm->start_stack)) {
56219 name = "[stack]";
56220 } else {
56221 /* Thread stack in /proc/PID/maps */
56222 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
56223 struct proc_maps_private *priv = m->private;
56224 struct task_struct *task = priv->task;
56225
56226 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56227 + if (current->exec_id != m->exec_id) {
56228 + gr_log_badprocpid("maps");
56229 + return 0;
56230 + }
56231 +#endif
56232 +
56233 show_map_vma(m, vma, is_pid);
56234
56235 if (m->count < m->size) /* vma is copied successfully */
56236 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56237 .private = &mss,
56238 };
56239
56240 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56241 + if (current->exec_id != m->exec_id) {
56242 + gr_log_badprocpid("smaps");
56243 + return 0;
56244 + }
56245 +#endif
56246 memset(&mss, 0, sizeof mss);
56247 - mss.vma = vma;
56248 - /* mmap_sem is held in m_start */
56249 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56250 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56251 -
56252 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56253 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
56254 +#endif
56255 + mss.vma = vma;
56256 + /* mmap_sem is held in m_start */
56257 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56258 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56259 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56260 + }
56261 +#endif
56262 show_map_vma(m, vma, is_pid);
56263
56264 seq_printf(m,
56265 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56266 "KernelPageSize: %8lu kB\n"
56267 "MMUPageSize: %8lu kB\n"
56268 "Locked: %8lu kB\n",
56269 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56270 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
56271 +#else
56272 (vma->vm_end - vma->vm_start) >> 10,
56273 +#endif
56274 mss.resident >> 10,
56275 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
56276 mss.shared_clean >> 10,
56277 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56278 int n;
56279 char buffer[50];
56280
56281 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56282 + if (current->exec_id != m->exec_id) {
56283 + gr_log_badprocpid("numa_maps");
56284 + return 0;
56285 + }
56286 +#endif
56287 +
56288 if (!mm)
56289 return 0;
56290
56291 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56292 mpol_to_str(buffer, sizeof(buffer), pol);
56293 mpol_cond_put(pol);
56294
56295 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56296 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
56297 +#else
56298 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
56299 +#endif
56300
56301 if (file) {
56302 seq_printf(m, " file=");
56303 - seq_path(m, &file->f_path, "\n\t= ");
56304 + seq_path(m, &file->f_path, "\n\t\\= ");
56305 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
56306 seq_printf(m, " heap");
56307 } else {
56308 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
56309 index 1ccfa53..0848f95 100644
56310 --- a/fs/proc/task_nommu.c
56311 +++ b/fs/proc/task_nommu.c
56312 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56313 else
56314 bytes += kobjsize(mm);
56315
56316 - if (current->fs && current->fs->users > 1)
56317 + if (current->fs && atomic_read(&current->fs->users) > 1)
56318 sbytes += kobjsize(current->fs);
56319 else
56320 bytes += kobjsize(current->fs);
56321 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
56322
56323 if (file) {
56324 pad_len_spaces(m, len);
56325 - seq_path(m, &file->f_path, "");
56326 + seq_path(m, &file->f_path, "\n\\");
56327 } else if (mm) {
56328 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
56329
56330 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
56331 index b00fcc9..e0c6381 100644
56332 --- a/fs/qnx6/qnx6.h
56333 +++ b/fs/qnx6/qnx6.h
56334 @@ -74,7 +74,7 @@ enum {
56335 BYTESEX_BE,
56336 };
56337
56338 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56339 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56340 {
56341 if (sbi->s_bytesex == BYTESEX_LE)
56342 return le64_to_cpu((__force __le64)n);
56343 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
56344 return (__force __fs64)cpu_to_be64(n);
56345 }
56346
56347 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56348 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56349 {
56350 if (sbi->s_bytesex == BYTESEX_LE)
56351 return le32_to_cpu((__force __le32)n);
56352 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
56353 index 16e8abb..2dcf914 100644
56354 --- a/fs/quota/netlink.c
56355 +++ b/fs/quota/netlink.c
56356 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
56357 void quota_send_warning(struct kqid qid, dev_t dev,
56358 const char warntype)
56359 {
56360 - static atomic_t seq;
56361 + static atomic_unchecked_t seq;
56362 struct sk_buff *skb;
56363 void *msg_head;
56364 int ret;
56365 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
56366 "VFS: Not enough memory to send quota warning.\n");
56367 return;
56368 }
56369 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
56370 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
56371 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
56372 if (!msg_head) {
56373 printk(KERN_ERR
56374 diff --git a/fs/readdir.c b/fs/readdir.c
56375 index 5e69ef5..e5d9099 100644
56376 --- a/fs/readdir.c
56377 +++ b/fs/readdir.c
56378 @@ -17,6 +17,7 @@
56379 #include <linux/security.h>
56380 #include <linux/syscalls.h>
56381 #include <linux/unistd.h>
56382 +#include <linux/namei.h>
56383
56384 #include <asm/uaccess.h>
56385
56386 @@ -67,6 +68,7 @@ struct old_linux_dirent {
56387
56388 struct readdir_callback {
56389 struct old_linux_dirent __user * dirent;
56390 + struct file * file;
56391 int result;
56392 };
56393
56394 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
56395 buf->result = -EOVERFLOW;
56396 return -EOVERFLOW;
56397 }
56398 +
56399 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56400 + return 0;
56401 +
56402 buf->result++;
56403 dirent = buf->dirent;
56404 if (!access_ok(VERIFY_WRITE, dirent,
56405 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
56406
56407 buf.result = 0;
56408 buf.dirent = dirent;
56409 + buf.file = f.file;
56410
56411 error = vfs_readdir(f.file, fillonedir, &buf);
56412 if (buf.result)
56413 @@ -139,6 +146,7 @@ struct linux_dirent {
56414 struct getdents_callback {
56415 struct linux_dirent __user * current_dir;
56416 struct linux_dirent __user * previous;
56417 + struct file * file;
56418 int count;
56419 int error;
56420 };
56421 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
56422 buf->error = -EOVERFLOW;
56423 return -EOVERFLOW;
56424 }
56425 +
56426 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56427 + return 0;
56428 +
56429 dirent = buf->previous;
56430 if (dirent) {
56431 if (__put_user(offset, &dirent->d_off))
56432 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56433 buf.previous = NULL;
56434 buf.count = count;
56435 buf.error = 0;
56436 + buf.file = f.file;
56437
56438 error = vfs_readdir(f.file, filldir, &buf);
56439 if (error >= 0)
56440 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56441 struct getdents_callback64 {
56442 struct linux_dirent64 __user * current_dir;
56443 struct linux_dirent64 __user * previous;
56444 + struct file *file;
56445 int count;
56446 int error;
56447 };
56448 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
56449 buf->error = -EINVAL; /* only used if we fail.. */
56450 if (reclen > buf->count)
56451 return -EINVAL;
56452 +
56453 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56454 + return 0;
56455 +
56456 dirent = buf->previous;
56457 if (dirent) {
56458 if (__put_user(offset, &dirent->d_off))
56459 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56460
56461 buf.current_dir = dirent;
56462 buf.previous = NULL;
56463 + buf.file = f.file;
56464 buf.count = count;
56465 buf.error = 0;
56466
56467 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56468 error = buf.error;
56469 lastdirent = buf.previous;
56470 if (lastdirent) {
56471 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
56472 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
56473 if (__put_user(d_off, &lastdirent->d_off))
56474 error = -EFAULT;
56475 else
56476 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
56477 index 2b7882b..1c5ef48 100644
56478 --- a/fs/reiserfs/do_balan.c
56479 +++ b/fs/reiserfs/do_balan.c
56480 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
56481 return;
56482 }
56483
56484 - atomic_inc(&(fs_generation(tb->tb_sb)));
56485 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
56486 do_balance_starts(tb);
56487
56488 /* balance leaf returns 0 except if combining L R and S into
56489 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
56490 index e60e870..f40ac16 100644
56491 --- a/fs/reiserfs/procfs.c
56492 +++ b/fs/reiserfs/procfs.c
56493 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
56494 "SMALL_TAILS " : "NO_TAILS ",
56495 replay_only(sb) ? "REPLAY_ONLY " : "",
56496 convert_reiserfs(sb) ? "CONV " : "",
56497 - atomic_read(&r->s_generation_counter),
56498 + atomic_read_unchecked(&r->s_generation_counter),
56499 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
56500 SF(s_do_balance), SF(s_unneeded_left_neighbor),
56501 SF(s_good_search_by_key_reada), SF(s_bmaps),
56502 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
56503 index 157e474..65a6114 100644
56504 --- a/fs/reiserfs/reiserfs.h
56505 +++ b/fs/reiserfs/reiserfs.h
56506 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
56507 /* Comment? -Hans */
56508 wait_queue_head_t s_wait;
56509 /* To be obsoleted soon by per buffer seals.. -Hans */
56510 - atomic_t s_generation_counter; // increased by one every time the
56511 + atomic_unchecked_t s_generation_counter; // increased by one every time the
56512 // tree gets re-balanced
56513 unsigned long s_properties; /* File system properties. Currently holds
56514 on-disk FS format */
56515 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
56516 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
56517
56518 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
56519 -#define get_generation(s) atomic_read (&fs_generation(s))
56520 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
56521 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
56522 #define __fs_changed(gen,s) (gen != get_generation (s))
56523 #define fs_changed(gen,s) \
56524 diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
56525 index c196369..4cce1d9 100644
56526 --- a/fs/reiserfs/xattr.c
56527 +++ b/fs/reiserfs/xattr.c
56528 @@ -187,8 +187,8 @@ fill_with_dentries(void *buf, const char *name, int namelen, loff_t offset,
56529 if (dbuf->count == ARRAY_SIZE(dbuf->dentries))
56530 return -ENOSPC;
56531
56532 - if (name[0] == '.' && (name[1] == '\0' ||
56533 - (name[1] == '.' && name[2] == '\0')))
56534 + if (name[0] == '.' && (namelen < 2 ||
56535 + (namelen == 2 && name[1] == '.')))
56536 return 0;
56537
56538 dentry = lookup_one_len(name, dbuf->xadir, namelen);
56539 diff --git a/fs/select.c b/fs/select.c
56540 index 2ef72d9..f213b17 100644
56541 --- a/fs/select.c
56542 +++ b/fs/select.c
56543 @@ -20,6 +20,7 @@
56544 #include <linux/export.h>
56545 #include <linux/slab.h>
56546 #include <linux/poll.h>
56547 +#include <linux/security.h>
56548 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
56549 #include <linux/file.h>
56550 #include <linux/fdtable.h>
56551 @@ -826,6 +827,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
56552 struct poll_list *walk = head;
56553 unsigned long todo = nfds;
56554
56555 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
56556 if (nfds > rlimit(RLIMIT_NOFILE))
56557 return -EINVAL;
56558
56559 diff --git a/fs/seq_file.c b/fs/seq_file.c
56560 index f2bc3df..239d4f6 100644
56561 --- a/fs/seq_file.c
56562 +++ b/fs/seq_file.c
56563 @@ -10,6 +10,7 @@
56564 #include <linux/seq_file.h>
56565 #include <linux/slab.h>
56566 #include <linux/cred.h>
56567 +#include <linux/sched.h>
56568
56569 #include <asm/uaccess.h>
56570 #include <asm/page.h>
56571 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
56572 #ifdef CONFIG_USER_NS
56573 p->user_ns = file->f_cred->user_ns;
56574 #endif
56575 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56576 + p->exec_id = current->exec_id;
56577 +#endif
56578
56579 /*
56580 * Wrappers around seq_open(e.g. swaps_open) need to be
56581 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56582 return 0;
56583 }
56584 if (!m->buf) {
56585 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56586 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56587 if (!m->buf)
56588 return -ENOMEM;
56589 }
56590 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56591 Eoverflow:
56592 m->op->stop(m, p);
56593 kfree(m->buf);
56594 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56595 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56596 return !m->buf ? -ENOMEM : -EAGAIN;
56597 }
56598
56599 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56600
56601 /* grab buffer if we didn't have one */
56602 if (!m->buf) {
56603 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56604 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56605 if (!m->buf)
56606 goto Enomem;
56607 }
56608 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56609 goto Fill;
56610 m->op->stop(m, p);
56611 kfree(m->buf);
56612 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56613 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56614 if (!m->buf)
56615 goto Enomem;
56616 m->count = 0;
56617 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
56618 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
56619 void *data)
56620 {
56621 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
56622 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
56623 int res = -ENOMEM;
56624
56625 if (op) {
56626 diff --git a/fs/splice.c b/fs/splice.c
56627 index 6909d89..5b2e8f9 100644
56628 --- a/fs/splice.c
56629 +++ b/fs/splice.c
56630 @@ -194,7 +194,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56631 pipe_lock(pipe);
56632
56633 for (;;) {
56634 - if (!pipe->readers) {
56635 + if (!atomic_read(&pipe->readers)) {
56636 send_sig(SIGPIPE, current, 0);
56637 if (!ret)
56638 ret = -EPIPE;
56639 @@ -248,9 +248,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56640 do_wakeup = 0;
56641 }
56642
56643 - pipe->waiting_writers++;
56644 + atomic_inc(&pipe->waiting_writers);
56645 pipe_wait(pipe);
56646 - pipe->waiting_writers--;
56647 + atomic_dec(&pipe->waiting_writers);
56648 }
56649
56650 pipe_unlock(pipe);
56651 @@ -563,7 +563,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
56652 old_fs = get_fs();
56653 set_fs(get_ds());
56654 /* The cast to a user pointer is valid due to the set_fs() */
56655 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
56656 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
56657 set_fs(old_fs);
56658
56659 return res;
56660 @@ -578,7 +578,7 @@ static ssize_t kernel_write(struct file *file, const char *buf, size_t count,
56661 old_fs = get_fs();
56662 set_fs(get_ds());
56663 /* The cast to a user pointer is valid due to the set_fs() */
56664 - res = vfs_write(file, (const char __user *)buf, count, &pos);
56665 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
56666 set_fs(old_fs);
56667
56668 return res;
56669 @@ -630,7 +630,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
56670 goto err;
56671
56672 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
56673 - vec[i].iov_base = (void __user *) page_address(page);
56674 + vec[i].iov_base = (void __force_user *) page_address(page);
56675 vec[i].iov_len = this_len;
56676 spd.pages[i] = page;
56677 spd.nr_pages++;
56678 @@ -851,10 +851,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
56679 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
56680 {
56681 while (!pipe->nrbufs) {
56682 - if (!pipe->writers)
56683 + if (!atomic_read(&pipe->writers))
56684 return 0;
56685
56686 - if (!pipe->waiting_writers && sd->num_spliced)
56687 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
56688 return 0;
56689
56690 if (sd->flags & SPLICE_F_NONBLOCK)
56691 @@ -1189,7 +1189,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
56692 * out of the pipe right after the splice_to_pipe(). So set
56693 * PIPE_READERS appropriately.
56694 */
56695 - pipe->readers = 1;
56696 + atomic_set(&pipe->readers, 1);
56697
56698 current->splice_pipe = pipe;
56699 }
56700 @@ -1738,9 +1738,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56701 ret = -ERESTARTSYS;
56702 break;
56703 }
56704 - if (!pipe->writers)
56705 + if (!atomic_read(&pipe->writers))
56706 break;
56707 - if (!pipe->waiting_writers) {
56708 + if (!atomic_read(&pipe->waiting_writers)) {
56709 if (flags & SPLICE_F_NONBLOCK) {
56710 ret = -EAGAIN;
56711 break;
56712 @@ -1772,7 +1772,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56713 pipe_lock(pipe);
56714
56715 while (pipe->nrbufs >= pipe->buffers) {
56716 - if (!pipe->readers) {
56717 + if (!atomic_read(&pipe->readers)) {
56718 send_sig(SIGPIPE, current, 0);
56719 ret = -EPIPE;
56720 break;
56721 @@ -1785,9 +1785,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56722 ret = -ERESTARTSYS;
56723 break;
56724 }
56725 - pipe->waiting_writers++;
56726 + atomic_inc(&pipe->waiting_writers);
56727 pipe_wait(pipe);
56728 - pipe->waiting_writers--;
56729 + atomic_dec(&pipe->waiting_writers);
56730 }
56731
56732 pipe_unlock(pipe);
56733 @@ -1823,14 +1823,14 @@ retry:
56734 pipe_double_lock(ipipe, opipe);
56735
56736 do {
56737 - if (!opipe->readers) {
56738 + if (!atomic_read(&opipe->readers)) {
56739 send_sig(SIGPIPE, current, 0);
56740 if (!ret)
56741 ret = -EPIPE;
56742 break;
56743 }
56744
56745 - if (!ipipe->nrbufs && !ipipe->writers)
56746 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
56747 break;
56748
56749 /*
56750 @@ -1927,7 +1927,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56751 pipe_double_lock(ipipe, opipe);
56752
56753 do {
56754 - if (!opipe->readers) {
56755 + if (!atomic_read(&opipe->readers)) {
56756 send_sig(SIGPIPE, current, 0);
56757 if (!ret)
56758 ret = -EPIPE;
56759 @@ -1972,7 +1972,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56760 * return EAGAIN if we have the potential of some data in the
56761 * future, otherwise just return 0
56762 */
56763 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
56764 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
56765 ret = -EAGAIN;
56766
56767 pipe_unlock(ipipe);
56768 diff --git a/fs/stat.c b/fs/stat.c
56769 index 14f4545..9b7f55b 100644
56770 --- a/fs/stat.c
56771 +++ b/fs/stat.c
56772 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
56773 stat->gid = inode->i_gid;
56774 stat->rdev = inode->i_rdev;
56775 stat->size = i_size_read(inode);
56776 - stat->atime = inode->i_atime;
56777 - stat->mtime = inode->i_mtime;
56778 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56779 + stat->atime = inode->i_ctime;
56780 + stat->mtime = inode->i_ctime;
56781 + } else {
56782 + stat->atime = inode->i_atime;
56783 + stat->mtime = inode->i_mtime;
56784 + }
56785 stat->ctime = inode->i_ctime;
56786 stat->blksize = (1 << inode->i_blkbits);
56787 stat->blocks = inode->i_blocks;
56788 @@ -46,8 +51,14 @@ int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
56789 if (retval)
56790 return retval;
56791
56792 - if (inode->i_op->getattr)
56793 - return inode->i_op->getattr(mnt, dentry, stat);
56794 + if (inode->i_op->getattr) {
56795 + retval = inode->i_op->getattr(mnt, dentry, stat);
56796 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56797 + stat->atime = stat->ctime;
56798 + stat->mtime = stat->ctime;
56799 + }
56800 + return retval;
56801 + }
56802
56803 generic_fillattr(inode, stat);
56804 return 0;
56805 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
56806 index 614b2b5..4d321e6 100644
56807 --- a/fs/sysfs/bin.c
56808 +++ b/fs/sysfs/bin.c
56809 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
56810 return ret;
56811 }
56812
56813 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
56814 - void *buf, int len, int write)
56815 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
56816 + void *buf, size_t len, int write)
56817 {
56818 struct file *file = vma->vm_file;
56819 struct bin_buffer *bb = file->private_data;
56820 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
56821 - int ret;
56822 + ssize_t ret;
56823
56824 if (!bb->vm_ops)
56825 return -EINVAL;
56826 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
56827 index 1f8c823..ed57cfe 100644
56828 --- a/fs/sysfs/dir.c
56829 +++ b/fs/sysfs/dir.c
56830 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
56831 *
56832 * Returns 31 bit hash of ns + name (so it fits in an off_t )
56833 */
56834 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
56835 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
56836 {
56837 unsigned long hash = init_name_hash();
56838 unsigned int len = strlen(name);
56839 @@ -685,6 +685,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
56840 struct sysfs_dirent *sd;
56841 int rc;
56842
56843 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
56844 + const char *parent_name = parent_sd->s_name;
56845 +
56846 + mode = S_IFDIR | S_IRWXU;
56847 +
56848 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
56849 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
56850 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
56851 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
56852 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
56853 +#endif
56854 +
56855 /* allocate */
56856 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
56857 if (!sd)
56858 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
56859 index 602f56d..6853db8 100644
56860 --- a/fs/sysfs/file.c
56861 +++ b/fs/sysfs/file.c
56862 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
56863
56864 struct sysfs_open_dirent {
56865 atomic_t refcnt;
56866 - atomic_t event;
56867 + atomic_unchecked_t event;
56868 wait_queue_head_t poll;
56869 struct list_head buffers; /* goes through sysfs_buffer.list */
56870 };
56871 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
56872 if (!sysfs_get_active(attr_sd))
56873 return -ENODEV;
56874
56875 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
56876 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
56877 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
56878
56879 sysfs_put_active(attr_sd);
56880 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
56881 return -ENOMEM;
56882
56883 atomic_set(&new_od->refcnt, 0);
56884 - atomic_set(&new_od->event, 1);
56885 + atomic_set_unchecked(&new_od->event, 1);
56886 init_waitqueue_head(&new_od->poll);
56887 INIT_LIST_HEAD(&new_od->buffers);
56888 goto retry;
56889 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
56890
56891 sysfs_put_active(attr_sd);
56892
56893 - if (buffer->event != atomic_read(&od->event))
56894 + if (buffer->event != atomic_read_unchecked(&od->event))
56895 goto trigger;
56896
56897 return DEFAULT_POLLMASK;
56898 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
56899
56900 od = sd->s_attr.open;
56901 if (od) {
56902 - atomic_inc(&od->event);
56903 + atomic_inc_unchecked(&od->event);
56904 wake_up_interruptible(&od->poll);
56905 }
56906
56907 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
56908 index 3c9eb56..9dea5be 100644
56909 --- a/fs/sysfs/symlink.c
56910 +++ b/fs/sysfs/symlink.c
56911 @@ -286,7 +286,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
56912
56913 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
56914 {
56915 - char *page = nd_get_link(nd);
56916 + const char *page = nd_get_link(nd);
56917 if (!IS_ERR(page))
56918 free_page((unsigned long)page);
56919 }
56920 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
56921 index 69d4889..a810bd4 100644
56922 --- a/fs/sysv/sysv.h
56923 +++ b/fs/sysv/sysv.h
56924 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
56925 #endif
56926 }
56927
56928 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56929 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56930 {
56931 if (sbi->s_bytesex == BYTESEX_PDP)
56932 return PDP_swab((__force __u32)n);
56933 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
56934 index e18b988..f1d4ad0f 100644
56935 --- a/fs/ubifs/io.c
56936 +++ b/fs/ubifs/io.c
56937 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
56938 return err;
56939 }
56940
56941 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56942 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56943 {
56944 int err;
56945
56946 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
56947 index c175b4d..8f36a16 100644
56948 --- a/fs/udf/misc.c
56949 +++ b/fs/udf/misc.c
56950 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
56951
56952 u8 udf_tag_checksum(const struct tag *t)
56953 {
56954 - u8 *data = (u8 *)t;
56955 + const u8 *data = (const u8 *)t;
56956 u8 checksum = 0;
56957 int i;
56958 for (i = 0; i < sizeof(struct tag); ++i)
56959 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
56960 index 8d974c4..b82f6ec 100644
56961 --- a/fs/ufs/swab.h
56962 +++ b/fs/ufs/swab.h
56963 @@ -22,7 +22,7 @@ enum {
56964 BYTESEX_BE
56965 };
56966
56967 -static inline u64
56968 +static inline u64 __intentional_overflow(-1)
56969 fs64_to_cpu(struct super_block *sbp, __fs64 n)
56970 {
56971 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56972 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
56973 return (__force __fs64)cpu_to_be64(n);
56974 }
56975
56976 -static inline u32
56977 +static inline u32 __intentional_overflow(-1)
56978 fs32_to_cpu(struct super_block *sbp, __fs32 n)
56979 {
56980 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56981 diff --git a/fs/utimes.c b/fs/utimes.c
56982 index f4fb7ec..3fe03c0 100644
56983 --- a/fs/utimes.c
56984 +++ b/fs/utimes.c
56985 @@ -1,6 +1,7 @@
56986 #include <linux/compiler.h>
56987 #include <linux/file.h>
56988 #include <linux/fs.h>
56989 +#include <linux/security.h>
56990 #include <linux/linkage.h>
56991 #include <linux/mount.h>
56992 #include <linux/namei.h>
56993 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
56994 goto mnt_drop_write_and_out;
56995 }
56996 }
56997 +
56998 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
56999 + error = -EACCES;
57000 + goto mnt_drop_write_and_out;
57001 + }
57002 +
57003 mutex_lock(&inode->i_mutex);
57004 error = notify_change(path->dentry, &newattrs);
57005 mutex_unlock(&inode->i_mutex);
57006 diff --git a/fs/xattr.c b/fs/xattr.c
57007 index 3377dff..4feded6 100644
57008 --- a/fs/xattr.c
57009 +++ b/fs/xattr.c
57010 @@ -319,7 +319,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
57011 * Extended attribute SET operations
57012 */
57013 static long
57014 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
57015 +setxattr(struct path *path, const char __user *name, const void __user *value,
57016 size_t size, int flags)
57017 {
57018 int error;
57019 @@ -355,7 +355,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
57020 posix_acl_fix_xattr_from_user(kvalue, size);
57021 }
57022
57023 - error = vfs_setxattr(d, kname, kvalue, size, flags);
57024 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
57025 + error = -EACCES;
57026 + goto out;
57027 + }
57028 +
57029 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
57030 out:
57031 if (vvalue)
57032 vfree(vvalue);
57033 @@ -377,7 +382,7 @@ retry:
57034 return error;
57035 error = mnt_want_write(path.mnt);
57036 if (!error) {
57037 - error = setxattr(path.dentry, name, value, size, flags);
57038 + error = setxattr(&path, name, value, size, flags);
57039 mnt_drop_write(path.mnt);
57040 }
57041 path_put(&path);
57042 @@ -401,7 +406,7 @@ retry:
57043 return error;
57044 error = mnt_want_write(path.mnt);
57045 if (!error) {
57046 - error = setxattr(path.dentry, name, value, size, flags);
57047 + error = setxattr(&path, name, value, size, flags);
57048 mnt_drop_write(path.mnt);
57049 }
57050 path_put(&path);
57051 @@ -416,16 +421,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
57052 const void __user *,value, size_t, size, int, flags)
57053 {
57054 struct fd f = fdget(fd);
57055 - struct dentry *dentry;
57056 int error = -EBADF;
57057
57058 if (!f.file)
57059 return error;
57060 - dentry = f.file->f_path.dentry;
57061 - audit_inode(NULL, dentry, 0);
57062 + audit_inode(NULL, f.file->f_path.dentry, 0);
57063 error = mnt_want_write_file(f.file);
57064 if (!error) {
57065 - error = setxattr(dentry, name, value, size, flags);
57066 + error = setxattr(&f.file->f_path, name, value, size, flags);
57067 mnt_drop_write_file(f.file);
57068 }
57069 fdput(f);
57070 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
57071 index 9fbea87..6b19972 100644
57072 --- a/fs/xattr_acl.c
57073 +++ b/fs/xattr_acl.c
57074 @@ -76,8 +76,8 @@ struct posix_acl *
57075 posix_acl_from_xattr(struct user_namespace *user_ns,
57076 const void *value, size_t size)
57077 {
57078 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
57079 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
57080 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
57081 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
57082 int count;
57083 struct posix_acl *acl;
57084 struct posix_acl_entry *acl_e;
57085 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
57086 index 572a858..12a9b0d 100644
57087 --- a/fs/xfs/xfs_bmap.c
57088 +++ b/fs/xfs/xfs_bmap.c
57089 @@ -192,7 +192,7 @@ xfs_bmap_validate_ret(
57090 int nmap,
57091 int ret_nmap);
57092 #else
57093 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
57094 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do {} while (0)
57095 #endif /* DEBUG */
57096
57097 STATIC int
57098 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
57099 index 1b9fc3e..e1bdde0 100644
57100 --- a/fs/xfs/xfs_dir2_sf.c
57101 +++ b/fs/xfs/xfs_dir2_sf.c
57102 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
57103 }
57104
57105 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
57106 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
57107 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
57108 + char name[sfep->namelen];
57109 + memcpy(name, sfep->name, sfep->namelen);
57110 + if (filldir(dirent, name, sfep->namelen,
57111 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
57112 + *offset = off & 0x7fffffff;
57113 + return 0;
57114 + }
57115 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
57116 off & 0x7fffffff, ino, DT_UNKNOWN)) {
57117 *offset = off & 0x7fffffff;
57118 return 0;
57119 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
57120 index c1c3ef8..0952438 100644
57121 --- a/fs/xfs/xfs_ioctl.c
57122 +++ b/fs/xfs/xfs_ioctl.c
57123 @@ -127,7 +127,7 @@ xfs_find_handle(
57124 }
57125
57126 error = -EFAULT;
57127 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
57128 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
57129 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
57130 goto out_put;
57131
57132 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
57133 index d82efaa..0904a8e 100644
57134 --- a/fs/xfs/xfs_iops.c
57135 +++ b/fs/xfs/xfs_iops.c
57136 @@ -395,7 +395,7 @@ xfs_vn_put_link(
57137 struct nameidata *nd,
57138 void *p)
57139 {
57140 - char *s = nd_get_link(nd);
57141 + const char *s = nd_get_link(nd);
57142
57143 if (!IS_ERR(s))
57144 kfree(s);
57145 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
57146 new file mode 100644
57147 index 0000000..92247e4
57148 --- /dev/null
57149 +++ b/grsecurity/Kconfig
57150 @@ -0,0 +1,1021 @@
57151 +#
57152 +# grecurity configuration
57153 +#
57154 +menu "Memory Protections"
57155 +depends on GRKERNSEC
57156 +
57157 +config GRKERNSEC_KMEM
57158 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
57159 + default y if GRKERNSEC_CONFIG_AUTO
57160 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
57161 + help
57162 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
57163 + be written to or read from to modify or leak the contents of the running
57164 + kernel. /dev/port will also not be allowed to be opened and support
57165 + for /dev/cpu/*/msr will be removed. If you have module
57166 + support disabled, enabling this will close up five ways that are
57167 + currently used to insert malicious code into the running kernel.
57168 +
57169 + Even with all these features enabled, we still highly recommend that
57170 + you use the RBAC system, as it is still possible for an attacker to
57171 + modify the running kernel through privileged I/O granted by ioperm/iopl.
57172 +
57173 + If you are not using XFree86, you may be able to stop this additional
57174 + case by enabling the 'Disable privileged I/O' option. Though nothing
57175 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
57176 + but only to video memory, which is the only writing we allow in this
57177 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
57178 + not be allowed to mprotect it with PROT_WRITE later.
57179 + Enabling this feature will prevent the "cpupower" and "powertop" tools
57180 + from working.
57181 +
57182 + It is highly recommended that you say Y here if you meet all the
57183 + conditions above.
57184 +
57185 +config GRKERNSEC_VM86
57186 + bool "Restrict VM86 mode"
57187 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57188 + depends on X86_32
57189 +
57190 + help
57191 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
57192 + make use of a special execution mode on 32bit x86 processors called
57193 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
57194 + video cards and will still work with this option enabled. The purpose
57195 + of the option is to prevent exploitation of emulation errors in
57196 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
57197 + Nearly all users should be able to enable this option.
57198 +
57199 +config GRKERNSEC_IO
57200 + bool "Disable privileged I/O"
57201 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57202 + depends on X86
57203 + select RTC_CLASS
57204 + select RTC_INTF_DEV
57205 + select RTC_DRV_CMOS
57206 +
57207 + help
57208 + If you say Y here, all ioperm and iopl calls will return an error.
57209 + Ioperm and iopl can be used to modify the running kernel.
57210 + Unfortunately, some programs need this access to operate properly,
57211 + the most notable of which are XFree86 and hwclock. hwclock can be
57212 + remedied by having RTC support in the kernel, so real-time
57213 + clock support is enabled if this option is enabled, to ensure
57214 + that hwclock operates correctly. XFree86 still will not
57215 + operate correctly with this option enabled, so DO NOT CHOOSE Y
57216 + IF YOU USE XFree86. If you use XFree86 and you still want to
57217 + protect your kernel against modification, use the RBAC system.
57218 +
57219 +config GRKERNSEC_JIT_HARDEN
57220 + bool "Harden BPF JIT against spray attacks"
57221 + default y if GRKERNSEC_CONFIG_AUTO
57222 + depends on BPF_JIT
57223 + help
57224 + If you say Y here, the native code generated by the kernel's Berkeley
57225 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
57226 + attacks that attempt to fit attacker-beneficial instructions in
57227 + 32bit immediate fields of JIT-generated native instructions. The
57228 + attacker will generally aim to cause an unintended instruction sequence
57229 + of JIT-generated native code to execute by jumping into the middle of
57230 + a generated instruction. This feature effectively randomizes the 32bit
57231 + immediate constants present in the generated code to thwart such attacks.
57232 +
57233 + If you're using KERNEXEC, it's recommended that you enable this option
57234 + to supplement the hardening of the kernel.
57235 +
57236 +config GRKERNSEC_RAND_THREADSTACK
57237 + bool "Insert random gaps between thread stacks"
57238 + default y if GRKERNSEC_CONFIG_AUTO
57239 + depends on PAX_RANDMMAP && !PPC
57240 + help
57241 + If you say Y here, a random-sized gap will be enforced between allocated
57242 + thread stacks. Glibc's NPTL and other threading libraries that
57243 + pass MAP_STACK to the kernel for thread stack allocation are supported.
57244 + The implementation currently provides 8 bits of entropy for the gap.
57245 +
57246 + Many distributions do not compile threaded remote services with the
57247 + -fstack-check argument to GCC, causing the variable-sized stack-based
57248 + allocator, alloca(), to not probe the stack on allocation. This
57249 + permits an unbounded alloca() to skip over any guard page and potentially
57250 + modify another thread's stack reliably. An enforced random gap
57251 + reduces the reliability of such an attack and increases the chance
57252 + that such a read/write to another thread's stack instead lands in
57253 + an unmapped area, causing a crash and triggering grsecurity's
57254 + anti-bruteforcing logic.
57255 +
57256 +config GRKERNSEC_PROC_MEMMAP
57257 + bool "Harden ASLR against information leaks and entropy reduction"
57258 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
57259 + depends on PAX_NOEXEC || PAX_ASLR
57260 + help
57261 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
57262 + give no information about the addresses of its mappings if
57263 + PaX features that rely on random addresses are enabled on the task.
57264 + In addition to sanitizing this information and disabling other
57265 + dangerous sources of information, this option causes reads of sensitive
57266 + /proc/<pid> entries where the file descriptor was opened in a different
57267 + task than the one performing the read. Such attempts are logged.
57268 + This option also limits argv/env strings for suid/sgid binaries
57269 + to 512KB to prevent a complete exhaustion of the stack entropy provided
57270 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
57271 + binaries to prevent alternative mmap layouts from being abused.
57272 +
57273 + If you use PaX it is essential that you say Y here as it closes up
57274 + several holes that make full ASLR useless locally.
57275 +
57276 +config GRKERNSEC_BRUTE
57277 + bool "Deter exploit bruteforcing"
57278 + default y if GRKERNSEC_CONFIG_AUTO
57279 + help
57280 + If you say Y here, attempts to bruteforce exploits against forking
57281 + daemons such as apache or sshd, as well as against suid/sgid binaries
57282 + will be deterred. When a child of a forking daemon is killed by PaX
57283 + or crashes due to an illegal instruction or other suspicious signal,
57284 + the parent process will be delayed 30 seconds upon every subsequent
57285 + fork until the administrator is able to assess the situation and
57286 + restart the daemon.
57287 + In the suid/sgid case, the attempt is logged, the user has all their
57288 + processes terminated, and they are prevented from executing any further
57289 + processes for 15 minutes.
57290 + It is recommended that you also enable signal logging in the auditing
57291 + section so that logs are generated when a process triggers a suspicious
57292 + signal.
57293 + If the sysctl option is enabled, a sysctl option with name
57294 + "deter_bruteforce" is created.
57295 +
57296 +
57297 +config GRKERNSEC_MODHARDEN
57298 + bool "Harden module auto-loading"
57299 + default y if GRKERNSEC_CONFIG_AUTO
57300 + depends on MODULES
57301 + help
57302 + If you say Y here, module auto-loading in response to use of some
57303 + feature implemented by an unloaded module will be restricted to
57304 + root users. Enabling this option helps defend against attacks
57305 + by unprivileged users who abuse the auto-loading behavior to
57306 + cause a vulnerable module to load that is then exploited.
57307 +
57308 + If this option prevents a legitimate use of auto-loading for a
57309 + non-root user, the administrator can execute modprobe manually
57310 + with the exact name of the module mentioned in the alert log.
57311 + Alternatively, the administrator can add the module to the list
57312 + of modules loaded at boot by modifying init scripts.
57313 +
57314 + Modification of init scripts will most likely be needed on
57315 + Ubuntu servers with encrypted home directory support enabled,
57316 + as the first non-root user logging in will cause the ecb(aes),
57317 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
57318 +
57319 +config GRKERNSEC_HIDESYM
57320 + bool "Hide kernel symbols"
57321 + default y if GRKERNSEC_CONFIG_AUTO
57322 + select PAX_USERCOPY_SLABS
57323 + help
57324 + If you say Y here, getting information on loaded modules, and
57325 + displaying all kernel symbols through a syscall will be restricted
57326 + to users with CAP_SYS_MODULE. For software compatibility reasons,
57327 + /proc/kallsyms will be restricted to the root user. The RBAC
57328 + system can hide that entry even from root.
57329 +
57330 + This option also prevents leaking of kernel addresses through
57331 + several /proc entries.
57332 +
57333 + Note that this option is only effective provided the following
57334 + conditions are met:
57335 + 1) The kernel using grsecurity is not precompiled by some distribution
57336 + 2) You have also enabled GRKERNSEC_DMESG
57337 + 3) You are using the RBAC system and hiding other files such as your
57338 + kernel image and System.map. Alternatively, enabling this option
57339 + causes the permissions on /boot, /lib/modules, and the kernel
57340 + source directory to change at compile time to prevent
57341 + reading by non-root users.
57342 + If the above conditions are met, this option will aid in providing a
57343 + useful protection against local kernel exploitation of overflows
57344 + and arbitrary read/write vulnerabilities.
57345 +
57346 +config GRKERNSEC_KERN_LOCKOUT
57347 + bool "Active kernel exploit response"
57348 + default y if GRKERNSEC_CONFIG_AUTO
57349 + depends on X86 || ARM || PPC || SPARC
57350 + help
57351 + If you say Y here, when a PaX alert is triggered due to suspicious
57352 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
57353 + or an OOPS occurs due to bad memory accesses, instead of just
57354 + terminating the offending process (and potentially allowing
57355 + a subsequent exploit from the same user), we will take one of two
57356 + actions:
57357 + If the user was root, we will panic the system
57358 + If the user was non-root, we will log the attempt, terminate
57359 + all processes owned by the user, then prevent them from creating
57360 + any new processes until the system is restarted
57361 + This deters repeated kernel exploitation/bruteforcing attempts
57362 + and is useful for later forensics.
57363 +
57364 +endmenu
57365 +menu "Role Based Access Control Options"
57366 +depends on GRKERNSEC
57367 +
57368 +config GRKERNSEC_RBAC_DEBUG
57369 + bool
57370 +
57371 +config GRKERNSEC_NO_RBAC
57372 + bool "Disable RBAC system"
57373 + help
57374 + If you say Y here, the /dev/grsec device will be removed from the kernel,
57375 + preventing the RBAC system from being enabled. You should only say Y
57376 + here if you have no intention of using the RBAC system, so as to prevent
57377 + an attacker with root access from misusing the RBAC system to hide files
57378 + and processes when loadable module support and /dev/[k]mem have been
57379 + locked down.
57380 +
57381 +config GRKERNSEC_ACL_HIDEKERN
57382 + bool "Hide kernel processes"
57383 + help
57384 + If you say Y here, all kernel threads will be hidden to all
57385 + processes but those whose subject has the "view hidden processes"
57386 + flag.
57387 +
57388 +config GRKERNSEC_ACL_MAXTRIES
57389 + int "Maximum tries before password lockout"
57390 + default 3
57391 + help
57392 + This option enforces the maximum number of times a user can attempt
57393 + to authorize themselves with the grsecurity RBAC system before being
57394 + denied the ability to attempt authorization again for a specified time.
57395 + The lower the number, the harder it will be to brute-force a password.
57396 +
57397 +config GRKERNSEC_ACL_TIMEOUT
57398 + int "Time to wait after max password tries, in seconds"
57399 + default 30
57400 + help
57401 + This option specifies the time the user must wait after attempting to
57402 + authorize to the RBAC system with the maximum number of invalid
57403 + passwords. The higher the number, the harder it will be to brute-force
57404 + a password.
57405 +
57406 +endmenu
57407 +menu "Filesystem Protections"
57408 +depends on GRKERNSEC
57409 +
57410 +config GRKERNSEC_PROC
57411 + bool "Proc restrictions"
57412 + default y if GRKERNSEC_CONFIG_AUTO
57413 + help
57414 + If you say Y here, the permissions of the /proc filesystem
57415 + will be altered to enhance system security and privacy. You MUST
57416 + choose either a user only restriction or a user and group restriction.
57417 + Depending upon the option you choose, you can either restrict users to
57418 + see only the processes they themselves run, or choose a group that can
57419 + view all processes and files normally restricted to root if you choose
57420 + the "restrict to user only" option. NOTE: If you're running identd or
57421 + ntpd as a non-root user, you will have to run it as the group you
57422 + specify here.
57423 +
57424 +config GRKERNSEC_PROC_USER
57425 + bool "Restrict /proc to user only"
57426 + depends on GRKERNSEC_PROC
57427 + help
57428 + If you say Y here, non-root users will only be able to view their own
57429 + processes, and restricts them from viewing network-related information,
57430 + and viewing kernel symbol and module information.
57431 +
57432 +config GRKERNSEC_PROC_USERGROUP
57433 + bool "Allow special group"
57434 + default y if GRKERNSEC_CONFIG_AUTO
57435 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
57436 + help
57437 + If you say Y here, you will be able to select a group that will be
57438 + able to view all processes and network-related information. If you've
57439 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
57440 + remain hidden. This option is useful if you want to run identd as
57441 + a non-root user. The group you select may also be chosen at boot time
57442 + via "grsec_proc_gid=" on the kernel commandline.
57443 +
57444 +config GRKERNSEC_PROC_GID
57445 + int "GID for special group"
57446 + depends on GRKERNSEC_PROC_USERGROUP
57447 + default 1001
57448 +
57449 +config GRKERNSEC_PROC_ADD
57450 + bool "Additional restrictions"
57451 + default y if GRKERNSEC_CONFIG_AUTO
57452 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
57453 + help
57454 + If you say Y here, additional restrictions will be placed on
57455 + /proc that keep normal users from viewing device information and
57456 + slabinfo information that could be useful for exploits.
57457 +
57458 +config GRKERNSEC_LINK
57459 + bool "Linking restrictions"
57460 + default y if GRKERNSEC_CONFIG_AUTO
57461 + help
57462 + If you say Y here, /tmp race exploits will be prevented, since users
57463 + will no longer be able to follow symlinks owned by other users in
57464 + world-writable +t directories (e.g. /tmp), unless the owner of the
57465 + symlink is the owner of the directory. users will also not be
57466 + able to hardlink to files they do not own. If the sysctl option is
57467 + enabled, a sysctl option with name "linking_restrictions" is created.
57468 +
57469 +config GRKERNSEC_SYMLINKOWN
57470 + bool "Kernel-enforced SymlinksIfOwnerMatch"
57471 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57472 + help
57473 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
57474 + that prevents it from being used as a security feature. As Apache
57475 + verifies the symlink by performing a stat() against the target of
57476 + the symlink before it is followed, an attacker can setup a symlink
57477 + to point to a same-owned file, then replace the symlink with one
57478 + that targets another user's file just after Apache "validates" the
57479 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
57480 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
57481 + will be in place for the group you specify. If the sysctl option
57482 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
57483 + created.
57484 +
57485 +config GRKERNSEC_SYMLINKOWN_GID
57486 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
57487 + depends on GRKERNSEC_SYMLINKOWN
57488 + default 1006
57489 + help
57490 + Setting this GID determines what group kernel-enforced
57491 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
57492 + is enabled, a sysctl option with name "symlinkown_gid" is created.
57493 +
57494 +config GRKERNSEC_FIFO
57495 + bool "FIFO restrictions"
57496 + default y if GRKERNSEC_CONFIG_AUTO
57497 + help
57498 + If you say Y here, users will not be able to write to FIFOs they don't
57499 + own in world-writable +t directories (e.g. /tmp), unless the owner of
57500 + the FIFO is the same owner of the directory it's held in. If the sysctl
57501 + option is enabled, a sysctl option with name "fifo_restrictions" is
57502 + created.
57503 +
57504 +config GRKERNSEC_SYSFS_RESTRICT
57505 + bool "Sysfs/debugfs restriction"
57506 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57507 + depends on SYSFS
57508 + help
57509 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
57510 + any filesystem normally mounted under it (e.g. debugfs) will be
57511 + mostly accessible only by root. These filesystems generally provide access
57512 + to hardware and debug information that isn't appropriate for unprivileged
57513 + users of the system. Sysfs and debugfs have also become a large source
57514 + of new vulnerabilities, ranging from infoleaks to local compromise.
57515 + There has been very little oversight with an eye toward security involved
57516 + in adding new exporters of information to these filesystems, so their
57517 + use is discouraged.
57518 + For reasons of compatibility, a few directories have been whitelisted
57519 + for access by non-root users:
57520 + /sys/fs/selinux
57521 + /sys/fs/fuse
57522 + /sys/devices/system/cpu
57523 +
57524 +config GRKERNSEC_ROFS
57525 + bool "Runtime read-only mount protection"
57526 + help
57527 + If you say Y here, a sysctl option with name "romount_protect" will
57528 + be created. By setting this option to 1 at runtime, filesystems
57529 + will be protected in the following ways:
57530 + * No new writable mounts will be allowed
57531 + * Existing read-only mounts won't be able to be remounted read/write
57532 + * Write operations will be denied on all block devices
57533 + This option acts independently of grsec_lock: once it is set to 1,
57534 + it cannot be turned off. Therefore, please be mindful of the resulting
57535 + behavior if this option is enabled in an init script on a read-only
57536 + filesystem. This feature is mainly intended for secure embedded systems.
57537 +
57538 +config GRKERNSEC_DEVICE_SIDECHANNEL
57539 + bool "Eliminate stat/notify-based device sidechannels"
57540 + default y if GRKERNSEC_CONFIG_AUTO
57541 + help
57542 + If you say Y here, timing analyses on block or character
57543 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
57544 + will be thwarted for unprivileged users. If a process without
57545 + CAP_MKNOD stats such a device, the last access and last modify times
57546 + will match the device's create time. No access or modify events
57547 + will be triggered through inotify/dnotify/fanotify for such devices.
57548 + This feature will prevent attacks that may at a minimum
57549 + allow an attacker to determine the administrator's password length.
57550 +
57551 +config GRKERNSEC_CHROOT
57552 + bool "Chroot jail restrictions"
57553 + default y if GRKERNSEC_CONFIG_AUTO
57554 + help
57555 + If you say Y here, you will be able to choose several options that will
57556 + make breaking out of a chrooted jail much more difficult. If you
57557 + encounter no software incompatibilities with the following options, it
57558 + is recommended that you enable each one.
57559 +
57560 +config GRKERNSEC_CHROOT_MOUNT
57561 + bool "Deny mounts"
57562 + default y if GRKERNSEC_CONFIG_AUTO
57563 + depends on GRKERNSEC_CHROOT
57564 + help
57565 + If you say Y here, processes inside a chroot will not be able to
57566 + mount or remount filesystems. If the sysctl option is enabled, a
57567 + sysctl option with name "chroot_deny_mount" is created.
57568 +
57569 +config GRKERNSEC_CHROOT_DOUBLE
57570 + bool "Deny double-chroots"
57571 + default y if GRKERNSEC_CONFIG_AUTO
57572 + depends on GRKERNSEC_CHROOT
57573 + help
57574 + If you say Y here, processes inside a chroot will not be able to chroot
57575 + again outside the chroot. This is a widely used method of breaking
57576 + out of a chroot jail and should not be allowed. If the sysctl
57577 + option is enabled, a sysctl option with name
57578 + "chroot_deny_chroot" is created.
57579 +
57580 +config GRKERNSEC_CHROOT_PIVOT
57581 + bool "Deny pivot_root in chroot"
57582 + default y if GRKERNSEC_CONFIG_AUTO
57583 + depends on GRKERNSEC_CHROOT
57584 + help
57585 + If you say Y here, processes inside a chroot will not be able to use
57586 + a function called pivot_root() that was introduced in Linux 2.3.41. It
57587 + works similar to chroot in that it changes the root filesystem. This
57588 + function could be misused in a chrooted process to attempt to break out
57589 + of the chroot, and therefore should not be allowed. If the sysctl
57590 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
57591 + created.
57592 +
57593 +config GRKERNSEC_CHROOT_CHDIR
57594 + bool "Enforce chdir(\"/\") on all chroots"
57595 + default y if GRKERNSEC_CONFIG_AUTO
57596 + depends on GRKERNSEC_CHROOT
57597 + help
57598 + If you say Y here, the current working directory of all newly-chrooted
57599 + applications will be set to the the root directory of the chroot.
57600 + The man page on chroot(2) states:
57601 + Note that this call does not change the current working
57602 + directory, so that `.' can be outside the tree rooted at
57603 + `/'. In particular, the super-user can escape from a
57604 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
57605 +
57606 + It is recommended that you say Y here, since it's not known to break
57607 + any software. If the sysctl option is enabled, a sysctl option with
57608 + name "chroot_enforce_chdir" is created.
57609 +
57610 +config GRKERNSEC_CHROOT_CHMOD
57611 + bool "Deny (f)chmod +s"
57612 + default y if GRKERNSEC_CONFIG_AUTO
57613 + depends on GRKERNSEC_CHROOT
57614 + help
57615 + If you say Y here, processes inside a chroot will not be able to chmod
57616 + or fchmod files to make them have suid or sgid bits. This protects
57617 + against another published method of breaking a chroot. If the sysctl
57618 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
57619 + created.
57620 +
57621 +config GRKERNSEC_CHROOT_FCHDIR
57622 + bool "Deny fchdir out of chroot"
57623 + default y if GRKERNSEC_CONFIG_AUTO
57624 + depends on GRKERNSEC_CHROOT
57625 + help
57626 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
57627 + to a file descriptor of the chrooting process that points to a directory
57628 + outside the filesystem will be stopped. If the sysctl option
57629 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
57630 +
57631 +config GRKERNSEC_CHROOT_MKNOD
57632 + bool "Deny mknod"
57633 + default y if GRKERNSEC_CONFIG_AUTO
57634 + depends on GRKERNSEC_CHROOT
57635 + help
57636 + If you say Y here, processes inside a chroot will not be allowed to
57637 + mknod. The problem with using mknod inside a chroot is that it
57638 + would allow an attacker to create a device entry that is the same
57639 + as one on the physical root of your system, which could range from
57640 + anything from the console device to a device for your harddrive (which
57641 + they could then use to wipe the drive or steal data). It is recommended
57642 + that you say Y here, unless you run into software incompatibilities.
57643 + If the sysctl option is enabled, a sysctl option with name
57644 + "chroot_deny_mknod" is created.
57645 +
57646 +config GRKERNSEC_CHROOT_SHMAT
57647 + bool "Deny shmat() out of chroot"
57648 + default y if GRKERNSEC_CONFIG_AUTO
57649 + depends on GRKERNSEC_CHROOT
57650 + help
57651 + If you say Y here, processes inside a chroot will not be able to attach
57652 + to shared memory segments that were created outside of the chroot jail.
57653 + It is recommended that you say Y here. If the sysctl option is enabled,
57654 + a sysctl option with name "chroot_deny_shmat" is created.
57655 +
57656 +config GRKERNSEC_CHROOT_UNIX
57657 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
57658 + default y if GRKERNSEC_CONFIG_AUTO
57659 + depends on GRKERNSEC_CHROOT
57660 + help
57661 + If you say Y here, processes inside a chroot will not be able to
57662 + connect to abstract (meaning not belonging to a filesystem) Unix
57663 + domain sockets that were bound outside of a chroot. It is recommended
57664 + that you say Y here. If the sysctl option is enabled, a sysctl option
57665 + with name "chroot_deny_unix" is created.
57666 +
57667 +config GRKERNSEC_CHROOT_FINDTASK
57668 + bool "Protect outside processes"
57669 + default y if GRKERNSEC_CONFIG_AUTO
57670 + depends on GRKERNSEC_CHROOT
57671 + help
57672 + If you say Y here, processes inside a chroot will not be able to
57673 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
57674 + getsid, or view any process outside of the chroot. If the sysctl
57675 + option is enabled, a sysctl option with name "chroot_findtask" is
57676 + created.
57677 +
57678 +config GRKERNSEC_CHROOT_NICE
57679 + bool "Restrict priority changes"
57680 + default y if GRKERNSEC_CONFIG_AUTO
57681 + depends on GRKERNSEC_CHROOT
57682 + help
57683 + If you say Y here, processes inside a chroot will not be able to raise
57684 + the priority of processes in the chroot, or alter the priority of
57685 + processes outside the chroot. This provides more security than simply
57686 + removing CAP_SYS_NICE from the process' capability set. If the
57687 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
57688 + is created.
57689 +
57690 +config GRKERNSEC_CHROOT_SYSCTL
57691 + bool "Deny sysctl writes"
57692 + default y if GRKERNSEC_CONFIG_AUTO
57693 + depends on GRKERNSEC_CHROOT
57694 + help
57695 + If you say Y here, an attacker in a chroot will not be able to
57696 + write to sysctl entries, either by sysctl(2) or through a /proc
57697 + interface. It is strongly recommended that you say Y here. If the
57698 + sysctl option is enabled, a sysctl option with name
57699 + "chroot_deny_sysctl" is created.
57700 +
57701 +config GRKERNSEC_CHROOT_CAPS
57702 + bool "Capability restrictions"
57703 + default y if GRKERNSEC_CONFIG_AUTO
57704 + depends on GRKERNSEC_CHROOT
57705 + help
57706 + If you say Y here, the capabilities on all processes within a
57707 + chroot jail will be lowered to stop module insertion, raw i/o,
57708 + system and net admin tasks, rebooting the system, modifying immutable
57709 + files, modifying IPC owned by another, and changing the system time.
57710 + This is left an option because it can break some apps. Disable this
57711 + if your chrooted apps are having problems performing those kinds of
57712 + tasks. If the sysctl option is enabled, a sysctl option with
57713 + name "chroot_caps" is created.
57714 +
57715 +endmenu
57716 +menu "Kernel Auditing"
57717 +depends on GRKERNSEC
57718 +
57719 +config GRKERNSEC_AUDIT_GROUP
57720 + bool "Single group for auditing"
57721 + help
57722 + If you say Y here, the exec and chdir logging features will only operate
57723 + on a group you specify. This option is recommended if you only want to
57724 + watch certain users instead of having a large amount of logs from the
57725 + entire system. If the sysctl option is enabled, a sysctl option with
57726 + name "audit_group" is created.
57727 +
57728 +config GRKERNSEC_AUDIT_GID
57729 + int "GID for auditing"
57730 + depends on GRKERNSEC_AUDIT_GROUP
57731 + default 1007
57732 +
57733 +config GRKERNSEC_EXECLOG
57734 + bool "Exec logging"
57735 + help
57736 + If you say Y here, all execve() calls will be logged (since the
57737 + other exec*() calls are frontends to execve(), all execution
57738 + will be logged). Useful for shell-servers that like to keep track
57739 + of their users. If the sysctl option is enabled, a sysctl option with
57740 + name "exec_logging" is created.
57741 + WARNING: This option when enabled will produce a LOT of logs, especially
57742 + on an active system.
57743 +
57744 +config GRKERNSEC_RESLOG
57745 + bool "Resource logging"
57746 + default y if GRKERNSEC_CONFIG_AUTO
57747 + help
57748 + If you say Y here, all attempts to overstep resource limits will
57749 + be logged with the resource name, the requested size, and the current
57750 + limit. It is highly recommended that you say Y here. If the sysctl
57751 + option is enabled, a sysctl option with name "resource_logging" is
57752 + created. If the RBAC system is enabled, the sysctl value is ignored.
57753 +
57754 +config GRKERNSEC_CHROOT_EXECLOG
57755 + bool "Log execs within chroot"
57756 + help
57757 + If you say Y here, all executions inside a chroot jail will be logged
57758 + to syslog. This can cause a large amount of logs if certain
57759 + applications (eg. djb's daemontools) are installed on the system, and
57760 + is therefore left as an option. If the sysctl option is enabled, a
57761 + sysctl option with name "chroot_execlog" is created.
57762 +
57763 +config GRKERNSEC_AUDIT_PTRACE
57764 + bool "Ptrace logging"
57765 + help
57766 + If you say Y here, all attempts to attach to a process via ptrace
57767 + will be logged. If the sysctl option is enabled, a sysctl option
57768 + with name "audit_ptrace" is created.
57769 +
57770 +config GRKERNSEC_AUDIT_CHDIR
57771 + bool "Chdir logging"
57772 + help
57773 + If you say Y here, all chdir() calls will be logged. If the sysctl
57774 + option is enabled, a sysctl option with name "audit_chdir" is created.
57775 +
57776 +config GRKERNSEC_AUDIT_MOUNT
57777 + bool "(Un)Mount logging"
57778 + help
57779 + If you say Y here, all mounts and unmounts will be logged. If the
57780 + sysctl option is enabled, a sysctl option with name "audit_mount" is
57781 + created.
57782 +
57783 +config GRKERNSEC_SIGNAL
57784 + bool "Signal logging"
57785 + default y if GRKERNSEC_CONFIG_AUTO
57786 + help
57787 + If you say Y here, certain important signals will be logged, such as
57788 + SIGSEGV, which will as a result inform you of when a error in a program
57789 + occurred, which in some cases could mean a possible exploit attempt.
57790 + If the sysctl option is enabled, a sysctl option with name
57791 + "signal_logging" is created.
57792 +
57793 +config GRKERNSEC_FORKFAIL
57794 + bool "Fork failure logging"
57795 + help
57796 + If you say Y here, all failed fork() attempts will be logged.
57797 + This could suggest a fork bomb, or someone attempting to overstep
57798 + their process limit. If the sysctl option is enabled, a sysctl option
57799 + with name "forkfail_logging" is created.
57800 +
57801 +config GRKERNSEC_TIME
57802 + bool "Time change logging"
57803 + default y if GRKERNSEC_CONFIG_AUTO
57804 + help
57805 + If you say Y here, any changes of the system clock will be logged.
57806 + If the sysctl option is enabled, a sysctl option with name
57807 + "timechange_logging" is created.
57808 +
57809 +config GRKERNSEC_PROC_IPADDR
57810 + bool "/proc/<pid>/ipaddr support"
57811 + default y if GRKERNSEC_CONFIG_AUTO
57812 + help
57813 + If you say Y here, a new entry will be added to each /proc/<pid>
57814 + directory that contains the IP address of the person using the task.
57815 + The IP is carried across local TCP and AF_UNIX stream sockets.
57816 + This information can be useful for IDS/IPSes to perform remote response
57817 + to a local attack. The entry is readable by only the owner of the
57818 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
57819 + the RBAC system), and thus does not create privacy concerns.
57820 +
57821 +config GRKERNSEC_RWXMAP_LOG
57822 + bool 'Denied RWX mmap/mprotect logging'
57823 + default y if GRKERNSEC_CONFIG_AUTO
57824 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
57825 + help
57826 + If you say Y here, calls to mmap() and mprotect() with explicit
57827 + usage of PROT_WRITE and PROT_EXEC together will be logged when
57828 + denied by the PAX_MPROTECT feature. If the sysctl option is
57829 + enabled, a sysctl option with name "rwxmap_logging" is created.
57830 +
57831 +config GRKERNSEC_AUDIT_TEXTREL
57832 + bool 'ELF text relocations logging (READ HELP)'
57833 + depends on PAX_MPROTECT
57834 + help
57835 + If you say Y here, text relocations will be logged with the filename
57836 + of the offending library or binary. The purpose of the feature is
57837 + to help Linux distribution developers get rid of libraries and
57838 + binaries that need text relocations which hinder the future progress
57839 + of PaX. Only Linux distribution developers should say Y here, and
57840 + never on a production machine, as this option creates an information
57841 + leak that could aid an attacker in defeating the randomization of
57842 + a single memory region. If the sysctl option is enabled, a sysctl
57843 + option with name "audit_textrel" is created.
57844 +
57845 +endmenu
57846 +
57847 +menu "Executable Protections"
57848 +depends on GRKERNSEC
57849 +
57850 +config GRKERNSEC_DMESG
57851 + bool "Dmesg(8) restriction"
57852 + default y if GRKERNSEC_CONFIG_AUTO
57853 + help
57854 + If you say Y here, non-root users will not be able to use dmesg(8)
57855 + to view the contents of the kernel's circular log buffer.
57856 + The kernel's log buffer often contains kernel addresses and other
57857 + identifying information useful to an attacker in fingerprinting a
57858 + system for a targeted exploit.
57859 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
57860 + created.
57861 +
57862 +config GRKERNSEC_HARDEN_PTRACE
57863 + bool "Deter ptrace-based process snooping"
57864 + default y if GRKERNSEC_CONFIG_AUTO
57865 + help
57866 + If you say Y here, TTY sniffers and other malicious monitoring
57867 + programs implemented through ptrace will be defeated. If you
57868 + have been using the RBAC system, this option has already been
57869 + enabled for several years for all users, with the ability to make
57870 + fine-grained exceptions.
57871 +
57872 + This option only affects the ability of non-root users to ptrace
57873 + processes that are not a descendent of the ptracing process.
57874 + This means that strace ./binary and gdb ./binary will still work,
57875 + but attaching to arbitrary processes will not. If the sysctl
57876 + option is enabled, a sysctl option with name "harden_ptrace" is
57877 + created.
57878 +
57879 +config GRKERNSEC_PTRACE_READEXEC
57880 + bool "Require read access to ptrace sensitive binaries"
57881 + default y if GRKERNSEC_CONFIG_AUTO
57882 + help
57883 + If you say Y here, unprivileged users will not be able to ptrace unreadable
57884 + binaries. This option is useful in environments that
57885 + remove the read bits (e.g. file mode 4711) from suid binaries to
57886 + prevent infoleaking of their contents. This option adds
57887 + consistency to the use of that file mode, as the binary could normally
57888 + be read out when run without privileges while ptracing.
57889 +
57890 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
57891 + is created.
57892 +
57893 +config GRKERNSEC_SETXID
57894 + bool "Enforce consistent multithreaded privileges"
57895 + default y if GRKERNSEC_CONFIG_AUTO
57896 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
57897 + help
57898 + If you say Y here, a change from a root uid to a non-root uid
57899 + in a multithreaded application will cause the resulting uids,
57900 + gids, supplementary groups, and capabilities in that thread
57901 + to be propagated to the other threads of the process. In most
57902 + cases this is unnecessary, as glibc will emulate this behavior
57903 + on behalf of the application. Other libcs do not act in the
57904 + same way, allowing the other threads of the process to continue
57905 + running with root privileges. If the sysctl option is enabled,
57906 + a sysctl option with name "consistent_setxid" is created.
57907 +
57908 +config GRKERNSEC_TPE
57909 + bool "Trusted Path Execution (TPE)"
57910 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57911 + help
57912 + If you say Y here, you will be able to choose a gid to add to the
57913 + supplementary groups of users you want to mark as "untrusted."
57914 + These users will not be able to execute any files that are not in
57915 + root-owned directories writable only by root. If the sysctl option
57916 + is enabled, a sysctl option with name "tpe" is created.
57917 +
57918 +config GRKERNSEC_TPE_ALL
57919 + bool "Partially restrict all non-root users"
57920 + depends on GRKERNSEC_TPE
57921 + help
57922 + If you say Y here, all non-root users will be covered under
57923 + a weaker TPE restriction. This is separate from, and in addition to,
57924 + the main TPE options that you have selected elsewhere. Thus, if a
57925 + "trusted" GID is chosen, this restriction applies to even that GID.
57926 + Under this restriction, all non-root users will only be allowed to
57927 + execute files in directories they own that are not group or
57928 + world-writable, or in directories owned by root and writable only by
57929 + root. If the sysctl option is enabled, a sysctl option with name
57930 + "tpe_restrict_all" is created.
57931 +
57932 +config GRKERNSEC_TPE_INVERT
57933 + bool "Invert GID option"
57934 + depends on GRKERNSEC_TPE
57935 + help
57936 + If you say Y here, the group you specify in the TPE configuration will
57937 + decide what group TPE restrictions will be *disabled* for. This
57938 + option is useful if you want TPE restrictions to be applied to most
57939 + users on the system. If the sysctl option is enabled, a sysctl option
57940 + with name "tpe_invert" is created. Unlike other sysctl options, this
57941 + entry will default to on for backward-compatibility.
57942 +
57943 +config GRKERNSEC_TPE_GID
57944 + int
57945 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
57946 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
57947 +
57948 +config GRKERNSEC_TPE_UNTRUSTED_GID
57949 + int "GID for TPE-untrusted users"
57950 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
57951 + default 1005
57952 + help
57953 + Setting this GID determines what group TPE restrictions will be
57954 + *enabled* for. If the sysctl option is enabled, a sysctl option
57955 + with name "tpe_gid" is created.
57956 +
57957 +config GRKERNSEC_TPE_TRUSTED_GID
57958 + int "GID for TPE-trusted users"
57959 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
57960 + default 1005
57961 + help
57962 + Setting this GID determines what group TPE restrictions will be
57963 + *disabled* for. If the sysctl option is enabled, a sysctl option
57964 + with name "tpe_gid" is created.
57965 +
57966 +endmenu
57967 +menu "Network Protections"
57968 +depends on GRKERNSEC
57969 +
57970 +config GRKERNSEC_RANDNET
57971 + bool "Larger entropy pools"
57972 + default y if GRKERNSEC_CONFIG_AUTO
57973 + help
57974 + If you say Y here, the entropy pools used for many features of Linux
57975 + and grsecurity will be doubled in size. Since several grsecurity
57976 + features use additional randomness, it is recommended that you say Y
57977 + here. Saying Y here has a similar effect as modifying
57978 + /proc/sys/kernel/random/poolsize.
57979 +
57980 +config GRKERNSEC_BLACKHOLE
57981 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
57982 + default y if GRKERNSEC_CONFIG_AUTO
57983 + depends on NET
57984 + help
57985 + If you say Y here, neither TCP resets nor ICMP
57986 + destination-unreachable packets will be sent in response to packets
57987 + sent to ports for which no associated listening process exists.
57988 + This feature supports both IPV4 and IPV6 and exempts the
57989 + loopback interface from blackholing. Enabling this feature
57990 + makes a host more resilient to DoS attacks and reduces network
57991 + visibility against scanners.
57992 +
57993 + The blackhole feature as-implemented is equivalent to the FreeBSD
57994 + blackhole feature, as it prevents RST responses to all packets, not
57995 + just SYNs. Under most application behavior this causes no
57996 + problems, but applications (like haproxy) may not close certain
57997 + connections in a way that cleanly terminates them on the remote
57998 + end, leaving the remote host in LAST_ACK state. Because of this
57999 + side-effect and to prevent intentional LAST_ACK DoSes, this
58000 + feature also adds automatic mitigation against such attacks.
58001 + The mitigation drastically reduces the amount of time a socket
58002 + can spend in LAST_ACK state. If you're using haproxy and not
58003 + all servers it connects to have this option enabled, consider
58004 + disabling this feature on the haproxy host.
58005 +
58006 + If the sysctl option is enabled, two sysctl options with names
58007 + "ip_blackhole" and "lastack_retries" will be created.
58008 + While "ip_blackhole" takes the standard zero/non-zero on/off
58009 + toggle, "lastack_retries" uses the same kinds of values as
58010 + "tcp_retries1" and "tcp_retries2". The default value of 4
58011 + prevents a socket from lasting more than 45 seconds in LAST_ACK
58012 + state.
58013 +
58014 +config GRKERNSEC_NO_SIMULT_CONNECT
58015 + bool "Disable TCP Simultaneous Connect"
58016 + default y if GRKERNSEC_CONFIG_AUTO
58017 + depends on NET
58018 + help
58019 + If you say Y here, a feature by Willy Tarreau will be enabled that
58020 + removes a weakness in Linux's strict implementation of TCP that
58021 + allows two clients to connect to each other without either entering
58022 + a listening state. The weakness allows an attacker to easily prevent
58023 + a client from connecting to a known server provided the source port
58024 + for the connection is guessed correctly.
58025 +
58026 + As the weakness could be used to prevent an antivirus or IPS from
58027 + fetching updates, or prevent an SSL gateway from fetching a CRL,
58028 + it should be eliminated by enabling this option. Though Linux is
58029 + one of few operating systems supporting simultaneous connect, it
58030 + has no legitimate use in practice and is rarely supported by firewalls.
58031 +
58032 +config GRKERNSEC_SOCKET
58033 + bool "Socket restrictions"
58034 + depends on NET
58035 + help
58036 + If you say Y here, you will be able to choose from several options.
58037 + If you assign a GID on your system and add it to the supplementary
58038 + groups of users you want to restrict socket access to, this patch
58039 + will perform up to three things, based on the option(s) you choose.
58040 +
58041 +config GRKERNSEC_SOCKET_ALL
58042 + bool "Deny any sockets to group"
58043 + depends on GRKERNSEC_SOCKET
58044 + help
58045 + If you say Y here, you will be able to choose a GID of whose users will
58046 + be unable to connect to other hosts from your machine or run server
58047 + applications from your machine. If the sysctl option is enabled, a
58048 + sysctl option with name "socket_all" is created.
58049 +
58050 +config GRKERNSEC_SOCKET_ALL_GID
58051 + int "GID to deny all sockets for"
58052 + depends on GRKERNSEC_SOCKET_ALL
58053 + default 1004
58054 + help
58055 + Here you can choose the GID to disable socket access for. Remember to
58056 + add the users you want socket access disabled for to the GID
58057 + specified here. If the sysctl option is enabled, a sysctl option
58058 + with name "socket_all_gid" is created.
58059 +
58060 +config GRKERNSEC_SOCKET_CLIENT
58061 + bool "Deny client sockets to group"
58062 + depends on GRKERNSEC_SOCKET
58063 + help
58064 + If you say Y here, you will be able to choose a GID of whose users will
58065 + be unable to connect to other hosts from your machine, but will be
58066 + able to run servers. If this option is enabled, all users in the group
58067 + you specify will have to use passive mode when initiating ftp transfers
58068 + from the shell on your machine. If the sysctl option is enabled, a
58069 + sysctl option with name "socket_client" is created.
58070 +
58071 +config GRKERNSEC_SOCKET_CLIENT_GID
58072 + int "GID to deny client sockets for"
58073 + depends on GRKERNSEC_SOCKET_CLIENT
58074 + default 1003
58075 + help
58076 + Here you can choose the GID to disable client socket access for.
58077 + Remember to add the users you want client socket access disabled for to
58078 + the GID specified here. If the sysctl option is enabled, a sysctl
58079 + option with name "socket_client_gid" is created.
58080 +
58081 +config GRKERNSEC_SOCKET_SERVER
58082 + bool "Deny server sockets to group"
58083 + depends on GRKERNSEC_SOCKET
58084 + help
58085 + If you say Y here, you will be able to choose a GID of whose users will
58086 + be unable to run server applications from your machine. If the sysctl
58087 + option is enabled, a sysctl option with name "socket_server" is created.
58088 +
58089 +config GRKERNSEC_SOCKET_SERVER_GID
58090 + int "GID to deny server sockets for"
58091 + depends on GRKERNSEC_SOCKET_SERVER
58092 + default 1002
58093 + help
58094 + Here you can choose the GID to disable server socket access for.
58095 + Remember to add the users you want server socket access disabled for to
58096 + the GID specified here. If the sysctl option is enabled, a sysctl
58097 + option with name "socket_server_gid" is created.
58098 +
58099 +endmenu
58100 +menu "Sysctl Support"
58101 +depends on GRKERNSEC && SYSCTL
58102 +
58103 +config GRKERNSEC_SYSCTL
58104 + bool "Sysctl support"
58105 + default y if GRKERNSEC_CONFIG_AUTO
58106 + help
58107 + If you say Y here, you will be able to change the options that
58108 + grsecurity runs with at bootup, without having to recompile your
58109 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
58110 + to enable (1) or disable (0) various features. All the sysctl entries
58111 + are mutable until the "grsec_lock" entry is set to a non-zero value.
58112 + All features enabled in the kernel configuration are disabled at boot
58113 + if you do not say Y to the "Turn on features by default" option.
58114 + All options should be set at startup, and the grsec_lock entry should
58115 + be set to a non-zero value after all the options are set.
58116 + *THIS IS EXTREMELY IMPORTANT*
58117 +
58118 +config GRKERNSEC_SYSCTL_DISTRO
58119 + bool "Extra sysctl support for distro makers (READ HELP)"
58120 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
58121 + help
58122 + If you say Y here, additional sysctl options will be created
58123 + for features that affect processes running as root. Therefore,
58124 + it is critical when using this option that the grsec_lock entry be
58125 + enabled after boot. Only distros with prebuilt kernel packages
58126 + with this option enabled that can ensure grsec_lock is enabled
58127 + after boot should use this option.
58128 + *Failure to set grsec_lock after boot makes all grsec features
58129 + this option covers useless*
58130 +
58131 + Currently this option creates the following sysctl entries:
58132 + "Disable Privileged I/O": "disable_priv_io"
58133 +
58134 +config GRKERNSEC_SYSCTL_ON
58135 + bool "Turn on features by default"
58136 + default y if GRKERNSEC_CONFIG_AUTO
58137 + depends on GRKERNSEC_SYSCTL
58138 + help
58139 + If you say Y here, instead of having all features enabled in the
58140 + kernel configuration disabled at boot time, the features will be
58141 + enabled at boot time. It is recommended you say Y here unless
58142 + there is some reason you would want all sysctl-tunable features to
58143 + be disabled by default. As mentioned elsewhere, it is important
58144 + to enable the grsec_lock entry once you have finished modifying
58145 + the sysctl entries.
58146 +
58147 +endmenu
58148 +menu "Logging Options"
58149 +depends on GRKERNSEC
58150 +
58151 +config GRKERNSEC_FLOODTIME
58152 + int "Seconds in between log messages (minimum)"
58153 + default 10
58154 + help
58155 + This option allows you to enforce the number of seconds between
58156 + grsecurity log messages. The default should be suitable for most
58157 + people, however, if you choose to change it, choose a value small enough
58158 + to allow informative logs to be produced, but large enough to
58159 + prevent flooding.
58160 +
58161 +config GRKERNSEC_FLOODBURST
58162 + int "Number of messages in a burst (maximum)"
58163 + default 6
58164 + help
58165 + This option allows you to choose the maximum number of messages allowed
58166 + within the flood time interval you chose in a separate option. The
58167 + default should be suitable for most people, however if you find that
58168 + many of your logs are being interpreted as flooding, you may want to
58169 + raise this value.
58170 +
58171 +endmenu
58172 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
58173 new file mode 100644
58174 index 0000000..1b9afa9
58175 --- /dev/null
58176 +++ b/grsecurity/Makefile
58177 @@ -0,0 +1,38 @@
58178 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
58179 +# during 2001-2009 it has been completely redesigned by Brad Spengler
58180 +# into an RBAC system
58181 +#
58182 +# All code in this directory and various hooks inserted throughout the kernel
58183 +# are copyright Brad Spengler - Open Source Security, Inc., and released
58184 +# under the GPL v2 or higher
58185 +
58186 +KBUILD_CFLAGS += -Werror
58187 +
58188 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
58189 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
58190 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
58191 +
58192 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
58193 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
58194 + gracl_learn.o grsec_log.o
58195 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
58196 +
58197 +ifdef CONFIG_NET
58198 +obj-y += grsec_sock.o
58199 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
58200 +endif
58201 +
58202 +ifndef CONFIG_GRKERNSEC
58203 +obj-y += grsec_disabled.o
58204 +endif
58205 +
58206 +ifdef CONFIG_GRKERNSEC_HIDESYM
58207 +extra-y := grsec_hidesym.o
58208 +$(obj)/grsec_hidesym.o:
58209 + @-chmod -f 500 /boot
58210 + @-chmod -f 500 /lib/modules
58211 + @-chmod -f 500 /lib64/modules
58212 + @-chmod -f 500 /lib32/modules
58213 + @-chmod -f 700 .
58214 + @echo ' grsec: protected kernel image paths'
58215 +endif
58216 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
58217 new file mode 100644
58218 index 0000000..b306b36
58219 --- /dev/null
58220 +++ b/grsecurity/gracl.c
58221 @@ -0,0 +1,4071 @@
58222 +#include <linux/kernel.h>
58223 +#include <linux/module.h>
58224 +#include <linux/sched.h>
58225 +#include <linux/mm.h>
58226 +#include <linux/file.h>
58227 +#include <linux/fs.h>
58228 +#include <linux/namei.h>
58229 +#include <linux/mount.h>
58230 +#include <linux/tty.h>
58231 +#include <linux/proc_fs.h>
58232 +#include <linux/lglock.h>
58233 +#include <linux/slab.h>
58234 +#include <linux/vmalloc.h>
58235 +#include <linux/types.h>
58236 +#include <linux/sysctl.h>
58237 +#include <linux/netdevice.h>
58238 +#include <linux/ptrace.h>
58239 +#include <linux/gracl.h>
58240 +#include <linux/gralloc.h>
58241 +#include <linux/security.h>
58242 +#include <linux/grinternal.h>
58243 +#include <linux/pid_namespace.h>
58244 +#include <linux/stop_machine.h>
58245 +#include <linux/fdtable.h>
58246 +#include <linux/percpu.h>
58247 +#include <linux/lglock.h>
58248 +#include <linux/hugetlb.h>
58249 +#include <linux/posix-timers.h>
58250 +#include "../fs/mount.h"
58251 +
58252 +#include <asm/uaccess.h>
58253 +#include <asm/errno.h>
58254 +#include <asm/mman.h>
58255 +
58256 +extern struct lglock vfsmount_lock;
58257 +
58258 +static struct acl_role_db acl_role_set;
58259 +static struct name_db name_set;
58260 +static struct inodev_db inodev_set;
58261 +
58262 +/* for keeping track of userspace pointers used for subjects, so we
58263 + can share references in the kernel as well
58264 +*/
58265 +
58266 +static struct path real_root;
58267 +
58268 +static struct acl_subj_map_db subj_map_set;
58269 +
58270 +static struct acl_role_label *default_role;
58271 +
58272 +static struct acl_role_label *role_list;
58273 +
58274 +static u16 acl_sp_role_value;
58275 +
58276 +extern char *gr_shared_page[4];
58277 +static DEFINE_MUTEX(gr_dev_mutex);
58278 +DEFINE_RWLOCK(gr_inode_lock);
58279 +
58280 +struct gr_arg *gr_usermode;
58281 +
58282 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
58283 +
58284 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
58285 +extern void gr_clear_learn_entries(void);
58286 +
58287 +unsigned char *gr_system_salt;
58288 +unsigned char *gr_system_sum;
58289 +
58290 +static struct sprole_pw **acl_special_roles = NULL;
58291 +static __u16 num_sprole_pws = 0;
58292 +
58293 +static struct acl_role_label *kernel_role = NULL;
58294 +
58295 +static unsigned int gr_auth_attempts = 0;
58296 +static unsigned long gr_auth_expires = 0UL;
58297 +
58298 +#ifdef CONFIG_NET
58299 +extern struct vfsmount *sock_mnt;
58300 +#endif
58301 +
58302 +extern struct vfsmount *pipe_mnt;
58303 +extern struct vfsmount *shm_mnt;
58304 +
58305 +#ifdef CONFIG_HUGETLBFS
58306 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58307 +#endif
58308 +
58309 +static struct acl_object_label *fakefs_obj_rw;
58310 +static struct acl_object_label *fakefs_obj_rwx;
58311 +
58312 +extern int gr_init_uidset(void);
58313 +extern void gr_free_uidset(void);
58314 +extern void gr_remove_uid(uid_t uid);
58315 +extern int gr_find_uid(uid_t uid);
58316 +
58317 +__inline__ int
58318 +gr_acl_is_enabled(void)
58319 +{
58320 + return (gr_status & GR_READY);
58321 +}
58322 +
58323 +#ifdef CONFIG_BTRFS_FS
58324 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
58325 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
58326 +#endif
58327 +
58328 +static inline dev_t __get_dev(const struct dentry *dentry)
58329 +{
58330 +#ifdef CONFIG_BTRFS_FS
58331 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
58332 + return get_btrfs_dev_from_inode(dentry->d_inode);
58333 + else
58334 +#endif
58335 + return dentry->d_inode->i_sb->s_dev;
58336 +}
58337 +
58338 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
58339 +{
58340 + return __get_dev(dentry);
58341 +}
58342 +
58343 +static char gr_task_roletype_to_char(struct task_struct *task)
58344 +{
58345 + switch (task->role->roletype &
58346 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
58347 + GR_ROLE_SPECIAL)) {
58348 + case GR_ROLE_DEFAULT:
58349 + return 'D';
58350 + case GR_ROLE_USER:
58351 + return 'U';
58352 + case GR_ROLE_GROUP:
58353 + return 'G';
58354 + case GR_ROLE_SPECIAL:
58355 + return 'S';
58356 + }
58357 +
58358 + return 'X';
58359 +}
58360 +
58361 +char gr_roletype_to_char(void)
58362 +{
58363 + return gr_task_roletype_to_char(current);
58364 +}
58365 +
58366 +__inline__ int
58367 +gr_acl_tpe_check(void)
58368 +{
58369 + if (unlikely(!(gr_status & GR_READY)))
58370 + return 0;
58371 + if (current->role->roletype & GR_ROLE_TPE)
58372 + return 1;
58373 + else
58374 + return 0;
58375 +}
58376 +
58377 +int
58378 +gr_handle_rawio(const struct inode *inode)
58379 +{
58380 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
58381 + if (inode && S_ISBLK(inode->i_mode) &&
58382 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
58383 + !capable(CAP_SYS_RAWIO))
58384 + return 1;
58385 +#endif
58386 + return 0;
58387 +}
58388 +
58389 +static int
58390 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
58391 +{
58392 + if (likely(lena != lenb))
58393 + return 0;
58394 +
58395 + return !memcmp(a, b, lena);
58396 +}
58397 +
58398 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
58399 +{
58400 + *buflen -= namelen;
58401 + if (*buflen < 0)
58402 + return -ENAMETOOLONG;
58403 + *buffer -= namelen;
58404 + memcpy(*buffer, str, namelen);
58405 + return 0;
58406 +}
58407 +
58408 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
58409 +{
58410 + return prepend(buffer, buflen, name->name, name->len);
58411 +}
58412 +
58413 +static int prepend_path(const struct path *path, struct path *root,
58414 + char **buffer, int *buflen)
58415 +{
58416 + struct dentry *dentry = path->dentry;
58417 + struct vfsmount *vfsmnt = path->mnt;
58418 + struct mount *mnt = real_mount(vfsmnt);
58419 + bool slash = false;
58420 + int error = 0;
58421 +
58422 + while (dentry != root->dentry || vfsmnt != root->mnt) {
58423 + struct dentry * parent;
58424 +
58425 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
58426 + /* Global root? */
58427 + if (!mnt_has_parent(mnt)) {
58428 + goto out;
58429 + }
58430 + dentry = mnt->mnt_mountpoint;
58431 + mnt = mnt->mnt_parent;
58432 + vfsmnt = &mnt->mnt;
58433 + continue;
58434 + }
58435 + parent = dentry->d_parent;
58436 + prefetch(parent);
58437 + spin_lock(&dentry->d_lock);
58438 + error = prepend_name(buffer, buflen, &dentry->d_name);
58439 + spin_unlock(&dentry->d_lock);
58440 + if (!error)
58441 + error = prepend(buffer, buflen, "/", 1);
58442 + if (error)
58443 + break;
58444 +
58445 + slash = true;
58446 + dentry = parent;
58447 + }
58448 +
58449 +out:
58450 + if (!error && !slash)
58451 + error = prepend(buffer, buflen, "/", 1);
58452 +
58453 + return error;
58454 +}
58455 +
58456 +/* this must be called with vfsmount_lock and rename_lock held */
58457 +
58458 +static char *__our_d_path(const struct path *path, struct path *root,
58459 + char *buf, int buflen)
58460 +{
58461 + char *res = buf + buflen;
58462 + int error;
58463 +
58464 + prepend(&res, &buflen, "\0", 1);
58465 + error = prepend_path(path, root, &res, &buflen);
58466 + if (error)
58467 + return ERR_PTR(error);
58468 +
58469 + return res;
58470 +}
58471 +
58472 +static char *
58473 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
58474 +{
58475 + char *retval;
58476 +
58477 + retval = __our_d_path(path, root, buf, buflen);
58478 + if (unlikely(IS_ERR(retval)))
58479 + retval = strcpy(buf, "<path too long>");
58480 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
58481 + retval[1] = '\0';
58482 +
58483 + return retval;
58484 +}
58485 +
58486 +static char *
58487 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58488 + char *buf, int buflen)
58489 +{
58490 + struct path path;
58491 + char *res;
58492 +
58493 + path.dentry = (struct dentry *)dentry;
58494 + path.mnt = (struct vfsmount *)vfsmnt;
58495 +
58496 + /* we can use real_root.dentry, real_root.mnt, because this is only called
58497 + by the RBAC system */
58498 + res = gen_full_path(&path, &real_root, buf, buflen);
58499 +
58500 + return res;
58501 +}
58502 +
58503 +static char *
58504 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58505 + char *buf, int buflen)
58506 +{
58507 + char *res;
58508 + struct path path;
58509 + struct path root;
58510 + struct task_struct *reaper = init_pid_ns.child_reaper;
58511 +
58512 + path.dentry = (struct dentry *)dentry;
58513 + path.mnt = (struct vfsmount *)vfsmnt;
58514 +
58515 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
58516 + get_fs_root(reaper->fs, &root);
58517 +
58518 + br_read_lock(&vfsmount_lock);
58519 + write_seqlock(&rename_lock);
58520 + res = gen_full_path(&path, &root, buf, buflen);
58521 + write_sequnlock(&rename_lock);
58522 + br_read_unlock(&vfsmount_lock);
58523 +
58524 + path_put(&root);
58525 + return res;
58526 +}
58527 +
58528 +static char *
58529 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58530 +{
58531 + char *ret;
58532 + br_read_lock(&vfsmount_lock);
58533 + write_seqlock(&rename_lock);
58534 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58535 + PAGE_SIZE);
58536 + write_sequnlock(&rename_lock);
58537 + br_read_unlock(&vfsmount_lock);
58538 + return ret;
58539 +}
58540 +
58541 +static char *
58542 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58543 +{
58544 + char *ret;
58545 + char *buf;
58546 + int buflen;
58547 +
58548 + br_read_lock(&vfsmount_lock);
58549 + write_seqlock(&rename_lock);
58550 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
58551 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
58552 + buflen = (int)(ret - buf);
58553 + if (buflen >= 5)
58554 + prepend(&ret, &buflen, "/proc", 5);
58555 + else
58556 + ret = strcpy(buf, "<path too long>");
58557 + write_sequnlock(&rename_lock);
58558 + br_read_unlock(&vfsmount_lock);
58559 + return ret;
58560 +}
58561 +
58562 +char *
58563 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
58564 +{
58565 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58566 + PAGE_SIZE);
58567 +}
58568 +
58569 +char *
58570 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
58571 +{
58572 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
58573 + PAGE_SIZE);
58574 +}
58575 +
58576 +char *
58577 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
58578 +{
58579 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
58580 + PAGE_SIZE);
58581 +}
58582 +
58583 +char *
58584 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
58585 +{
58586 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
58587 + PAGE_SIZE);
58588 +}
58589 +
58590 +char *
58591 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
58592 +{
58593 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
58594 + PAGE_SIZE);
58595 +}
58596 +
58597 +__inline__ __u32
58598 +to_gr_audit(const __u32 reqmode)
58599 +{
58600 + /* masks off auditable permission flags, then shifts them to create
58601 + auditing flags, and adds the special case of append auditing if
58602 + we're requesting write */
58603 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
58604 +}
58605 +
58606 +struct acl_subject_label *
58607 +lookup_subject_map(const struct acl_subject_label *userp)
58608 +{
58609 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
58610 + struct subject_map *match;
58611 +
58612 + match = subj_map_set.s_hash[index];
58613 +
58614 + while (match && match->user != userp)
58615 + match = match->next;
58616 +
58617 + if (match != NULL)
58618 + return match->kernel;
58619 + else
58620 + return NULL;
58621 +}
58622 +
58623 +static void
58624 +insert_subj_map_entry(struct subject_map *subjmap)
58625 +{
58626 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
58627 + struct subject_map **curr;
58628 +
58629 + subjmap->prev = NULL;
58630 +
58631 + curr = &subj_map_set.s_hash[index];
58632 + if (*curr != NULL)
58633 + (*curr)->prev = subjmap;
58634 +
58635 + subjmap->next = *curr;
58636 + *curr = subjmap;
58637 +
58638 + return;
58639 +}
58640 +
58641 +static struct acl_role_label *
58642 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
58643 + const gid_t gid)
58644 +{
58645 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
58646 + struct acl_role_label *match;
58647 + struct role_allowed_ip *ipp;
58648 + unsigned int x;
58649 + u32 curr_ip = task->signal->curr_ip;
58650 +
58651 + task->signal->saved_ip = curr_ip;
58652 +
58653 + match = acl_role_set.r_hash[index];
58654 +
58655 + while (match) {
58656 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
58657 + for (x = 0; x < match->domain_child_num; x++) {
58658 + if (match->domain_children[x] == uid)
58659 + goto found;
58660 + }
58661 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
58662 + break;
58663 + match = match->next;
58664 + }
58665 +found:
58666 + if (match == NULL) {
58667 + try_group:
58668 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
58669 + match = acl_role_set.r_hash[index];
58670 +
58671 + while (match) {
58672 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
58673 + for (x = 0; x < match->domain_child_num; x++) {
58674 + if (match->domain_children[x] == gid)
58675 + goto found2;
58676 + }
58677 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
58678 + break;
58679 + match = match->next;
58680 + }
58681 +found2:
58682 + if (match == NULL)
58683 + match = default_role;
58684 + if (match->allowed_ips == NULL)
58685 + return match;
58686 + else {
58687 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58688 + if (likely
58689 + ((ntohl(curr_ip) & ipp->netmask) ==
58690 + (ntohl(ipp->addr) & ipp->netmask)))
58691 + return match;
58692 + }
58693 + match = default_role;
58694 + }
58695 + } else if (match->allowed_ips == NULL) {
58696 + return match;
58697 + } else {
58698 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58699 + if (likely
58700 + ((ntohl(curr_ip) & ipp->netmask) ==
58701 + (ntohl(ipp->addr) & ipp->netmask)))
58702 + return match;
58703 + }
58704 + goto try_group;
58705 + }
58706 +
58707 + return match;
58708 +}
58709 +
58710 +struct acl_subject_label *
58711 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
58712 + const struct acl_role_label *role)
58713 +{
58714 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58715 + struct acl_subject_label *match;
58716 +
58717 + match = role->subj_hash[index];
58718 +
58719 + while (match && (match->inode != ino || match->device != dev ||
58720 + (match->mode & GR_DELETED))) {
58721 + match = match->next;
58722 + }
58723 +
58724 + if (match && !(match->mode & GR_DELETED))
58725 + return match;
58726 + else
58727 + return NULL;
58728 +}
58729 +
58730 +struct acl_subject_label *
58731 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
58732 + const struct acl_role_label *role)
58733 +{
58734 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58735 + struct acl_subject_label *match;
58736 +
58737 + match = role->subj_hash[index];
58738 +
58739 + while (match && (match->inode != ino || match->device != dev ||
58740 + !(match->mode & GR_DELETED))) {
58741 + match = match->next;
58742 + }
58743 +
58744 + if (match && (match->mode & GR_DELETED))
58745 + return match;
58746 + else
58747 + return NULL;
58748 +}
58749 +
58750 +static struct acl_object_label *
58751 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
58752 + const struct acl_subject_label *subj)
58753 +{
58754 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58755 + struct acl_object_label *match;
58756 +
58757 + match = subj->obj_hash[index];
58758 +
58759 + while (match && (match->inode != ino || match->device != dev ||
58760 + (match->mode & GR_DELETED))) {
58761 + match = match->next;
58762 + }
58763 +
58764 + if (match && !(match->mode & GR_DELETED))
58765 + return match;
58766 + else
58767 + return NULL;
58768 +}
58769 +
58770 +static struct acl_object_label *
58771 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
58772 + const struct acl_subject_label *subj)
58773 +{
58774 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58775 + struct acl_object_label *match;
58776 +
58777 + match = subj->obj_hash[index];
58778 +
58779 + while (match && (match->inode != ino || match->device != dev ||
58780 + !(match->mode & GR_DELETED))) {
58781 + match = match->next;
58782 + }
58783 +
58784 + if (match && (match->mode & GR_DELETED))
58785 + return match;
58786 +
58787 + match = subj->obj_hash[index];
58788 +
58789 + while (match && (match->inode != ino || match->device != dev ||
58790 + (match->mode & GR_DELETED))) {
58791 + match = match->next;
58792 + }
58793 +
58794 + if (match && !(match->mode & GR_DELETED))
58795 + return match;
58796 + else
58797 + return NULL;
58798 +}
58799 +
58800 +static struct name_entry *
58801 +lookup_name_entry(const char *name)
58802 +{
58803 + unsigned int len = strlen(name);
58804 + unsigned int key = full_name_hash(name, len);
58805 + unsigned int index = key % name_set.n_size;
58806 + struct name_entry *match;
58807 +
58808 + match = name_set.n_hash[index];
58809 +
58810 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
58811 + match = match->next;
58812 +
58813 + return match;
58814 +}
58815 +
58816 +static struct name_entry *
58817 +lookup_name_entry_create(const char *name)
58818 +{
58819 + unsigned int len = strlen(name);
58820 + unsigned int key = full_name_hash(name, len);
58821 + unsigned int index = key % name_set.n_size;
58822 + struct name_entry *match;
58823 +
58824 + match = name_set.n_hash[index];
58825 +
58826 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58827 + !match->deleted))
58828 + match = match->next;
58829 +
58830 + if (match && match->deleted)
58831 + return match;
58832 +
58833 + match = name_set.n_hash[index];
58834 +
58835 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58836 + match->deleted))
58837 + match = match->next;
58838 +
58839 + if (match && !match->deleted)
58840 + return match;
58841 + else
58842 + return NULL;
58843 +}
58844 +
58845 +static struct inodev_entry *
58846 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
58847 +{
58848 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
58849 + struct inodev_entry *match;
58850 +
58851 + match = inodev_set.i_hash[index];
58852 +
58853 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
58854 + match = match->next;
58855 +
58856 + return match;
58857 +}
58858 +
58859 +static void
58860 +insert_inodev_entry(struct inodev_entry *entry)
58861 +{
58862 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
58863 + inodev_set.i_size);
58864 + struct inodev_entry **curr;
58865 +
58866 + entry->prev = NULL;
58867 +
58868 + curr = &inodev_set.i_hash[index];
58869 + if (*curr != NULL)
58870 + (*curr)->prev = entry;
58871 +
58872 + entry->next = *curr;
58873 + *curr = entry;
58874 +
58875 + return;
58876 +}
58877 +
58878 +static void
58879 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
58880 +{
58881 + unsigned int index =
58882 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
58883 + struct acl_role_label **curr;
58884 + struct acl_role_label *tmp, *tmp2;
58885 +
58886 + curr = &acl_role_set.r_hash[index];
58887 +
58888 + /* simple case, slot is empty, just set it to our role */
58889 + if (*curr == NULL) {
58890 + *curr = role;
58891 + } else {
58892 + /* example:
58893 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
58894 + 2 -> 3
58895 + */
58896 + /* first check to see if we can already be reached via this slot */
58897 + tmp = *curr;
58898 + while (tmp && tmp != role)
58899 + tmp = tmp->next;
58900 + if (tmp == role) {
58901 + /* we don't need to add ourselves to this slot's chain */
58902 + return;
58903 + }
58904 + /* we need to add ourselves to this chain, two cases */
58905 + if (role->next == NULL) {
58906 + /* simple case, append the current chain to our role */
58907 + role->next = *curr;
58908 + *curr = role;
58909 + } else {
58910 + /* 1 -> 2 -> 3 -> 4
58911 + 2 -> 3 -> 4
58912 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
58913 + */
58914 + /* trickier case: walk our role's chain until we find
58915 + the role for the start of the current slot's chain */
58916 + tmp = role;
58917 + tmp2 = *curr;
58918 + while (tmp->next && tmp->next != tmp2)
58919 + tmp = tmp->next;
58920 + if (tmp->next == tmp2) {
58921 + /* from example above, we found 3, so just
58922 + replace this slot's chain with ours */
58923 + *curr = role;
58924 + } else {
58925 + /* we didn't find a subset of our role's chain
58926 + in the current slot's chain, so append their
58927 + chain to ours, and set us as the first role in
58928 + the slot's chain
58929 +
58930 + we could fold this case with the case above,
58931 + but making it explicit for clarity
58932 + */
58933 + tmp->next = tmp2;
58934 + *curr = role;
58935 + }
58936 + }
58937 + }
58938 +
58939 + return;
58940 +}
58941 +
58942 +static void
58943 +insert_acl_role_label(struct acl_role_label *role)
58944 +{
58945 + int i;
58946 +
58947 + if (role_list == NULL) {
58948 + role_list = role;
58949 + role->prev = NULL;
58950 + } else {
58951 + role->prev = role_list;
58952 + role_list = role;
58953 + }
58954 +
58955 + /* used for hash chains */
58956 + role->next = NULL;
58957 +
58958 + if (role->roletype & GR_ROLE_DOMAIN) {
58959 + for (i = 0; i < role->domain_child_num; i++)
58960 + __insert_acl_role_label(role, role->domain_children[i]);
58961 + } else
58962 + __insert_acl_role_label(role, role->uidgid);
58963 +}
58964 +
58965 +static int
58966 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
58967 +{
58968 + struct name_entry **curr, *nentry;
58969 + struct inodev_entry *ientry;
58970 + unsigned int len = strlen(name);
58971 + unsigned int key = full_name_hash(name, len);
58972 + unsigned int index = key % name_set.n_size;
58973 +
58974 + curr = &name_set.n_hash[index];
58975 +
58976 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
58977 + curr = &((*curr)->next);
58978 +
58979 + if (*curr != NULL)
58980 + return 1;
58981 +
58982 + nentry = acl_alloc(sizeof (struct name_entry));
58983 + if (nentry == NULL)
58984 + return 0;
58985 + ientry = acl_alloc(sizeof (struct inodev_entry));
58986 + if (ientry == NULL)
58987 + return 0;
58988 + ientry->nentry = nentry;
58989 +
58990 + nentry->key = key;
58991 + nentry->name = name;
58992 + nentry->inode = inode;
58993 + nentry->device = device;
58994 + nentry->len = len;
58995 + nentry->deleted = deleted;
58996 +
58997 + nentry->prev = NULL;
58998 + curr = &name_set.n_hash[index];
58999 + if (*curr != NULL)
59000 + (*curr)->prev = nentry;
59001 + nentry->next = *curr;
59002 + *curr = nentry;
59003 +
59004 + /* insert us into the table searchable by inode/dev */
59005 + insert_inodev_entry(ientry);
59006 +
59007 + return 1;
59008 +}
59009 +
59010 +static void
59011 +insert_acl_obj_label(struct acl_object_label *obj,
59012 + struct acl_subject_label *subj)
59013 +{
59014 + unsigned int index =
59015 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
59016 + struct acl_object_label **curr;
59017 +
59018 +
59019 + obj->prev = NULL;
59020 +
59021 + curr = &subj->obj_hash[index];
59022 + if (*curr != NULL)
59023 + (*curr)->prev = obj;
59024 +
59025 + obj->next = *curr;
59026 + *curr = obj;
59027 +
59028 + return;
59029 +}
59030 +
59031 +static void
59032 +insert_acl_subj_label(struct acl_subject_label *obj,
59033 + struct acl_role_label *role)
59034 +{
59035 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
59036 + struct acl_subject_label **curr;
59037 +
59038 + obj->prev = NULL;
59039 +
59040 + curr = &role->subj_hash[index];
59041 + if (*curr != NULL)
59042 + (*curr)->prev = obj;
59043 +
59044 + obj->next = *curr;
59045 + *curr = obj;
59046 +
59047 + return;
59048 +}
59049 +
59050 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
59051 +
59052 +static void *
59053 +create_table(__u32 * len, int elementsize)
59054 +{
59055 + unsigned int table_sizes[] = {
59056 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
59057 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
59058 + 4194301, 8388593, 16777213, 33554393, 67108859
59059 + };
59060 + void *newtable = NULL;
59061 + unsigned int pwr = 0;
59062 +
59063 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
59064 + table_sizes[pwr] <= *len)
59065 + pwr++;
59066 +
59067 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
59068 + return newtable;
59069 +
59070 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
59071 + newtable =
59072 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
59073 + else
59074 + newtable = vmalloc(table_sizes[pwr] * elementsize);
59075 +
59076 + *len = table_sizes[pwr];
59077 +
59078 + return newtable;
59079 +}
59080 +
59081 +static int
59082 +init_variables(const struct gr_arg *arg)
59083 +{
59084 + struct task_struct *reaper = init_pid_ns.child_reaper;
59085 + unsigned int stacksize;
59086 +
59087 + subj_map_set.s_size = arg->role_db.num_subjects;
59088 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
59089 + name_set.n_size = arg->role_db.num_objects;
59090 + inodev_set.i_size = arg->role_db.num_objects;
59091 +
59092 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
59093 + !name_set.n_size || !inodev_set.i_size)
59094 + return 1;
59095 +
59096 + if (!gr_init_uidset())
59097 + return 1;
59098 +
59099 + /* set up the stack that holds allocation info */
59100 +
59101 + stacksize = arg->role_db.num_pointers + 5;
59102 +
59103 + if (!acl_alloc_stack_init(stacksize))
59104 + return 1;
59105 +
59106 + /* grab reference for the real root dentry and vfsmount */
59107 + get_fs_root(reaper->fs, &real_root);
59108 +
59109 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59110 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
59111 +#endif
59112 +
59113 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
59114 + if (fakefs_obj_rw == NULL)
59115 + return 1;
59116 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
59117 +
59118 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
59119 + if (fakefs_obj_rwx == NULL)
59120 + return 1;
59121 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
59122 +
59123 + subj_map_set.s_hash =
59124 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
59125 + acl_role_set.r_hash =
59126 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
59127 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
59128 + inodev_set.i_hash =
59129 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
59130 +
59131 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
59132 + !name_set.n_hash || !inodev_set.i_hash)
59133 + return 1;
59134 +
59135 + memset(subj_map_set.s_hash, 0,
59136 + sizeof(struct subject_map *) * subj_map_set.s_size);
59137 + memset(acl_role_set.r_hash, 0,
59138 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
59139 + memset(name_set.n_hash, 0,
59140 + sizeof (struct name_entry *) * name_set.n_size);
59141 + memset(inodev_set.i_hash, 0,
59142 + sizeof (struct inodev_entry *) * inodev_set.i_size);
59143 +
59144 + return 0;
59145 +}
59146 +
59147 +/* free information not needed after startup
59148 + currently contains user->kernel pointer mappings for subjects
59149 +*/
59150 +
59151 +static void
59152 +free_init_variables(void)
59153 +{
59154 + __u32 i;
59155 +
59156 + if (subj_map_set.s_hash) {
59157 + for (i = 0; i < subj_map_set.s_size; i++) {
59158 + if (subj_map_set.s_hash[i]) {
59159 + kfree(subj_map_set.s_hash[i]);
59160 + subj_map_set.s_hash[i] = NULL;
59161 + }
59162 + }
59163 +
59164 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
59165 + PAGE_SIZE)
59166 + kfree(subj_map_set.s_hash);
59167 + else
59168 + vfree(subj_map_set.s_hash);
59169 + }
59170 +
59171 + return;
59172 +}
59173 +
59174 +static void
59175 +free_variables(void)
59176 +{
59177 + struct acl_subject_label *s;
59178 + struct acl_role_label *r;
59179 + struct task_struct *task, *task2;
59180 + unsigned int x;
59181 +
59182 + gr_clear_learn_entries();
59183 +
59184 + read_lock(&tasklist_lock);
59185 + do_each_thread(task2, task) {
59186 + task->acl_sp_role = 0;
59187 + task->acl_role_id = 0;
59188 + task->acl = NULL;
59189 + task->role = NULL;
59190 + } while_each_thread(task2, task);
59191 + read_unlock(&tasklist_lock);
59192 +
59193 + /* release the reference to the real root dentry and vfsmount */
59194 + path_put(&real_root);
59195 + memset(&real_root, 0, sizeof(real_root));
59196 +
59197 + /* free all object hash tables */
59198 +
59199 + FOR_EACH_ROLE_START(r)
59200 + if (r->subj_hash == NULL)
59201 + goto next_role;
59202 + FOR_EACH_SUBJECT_START(r, s, x)
59203 + if (s->obj_hash == NULL)
59204 + break;
59205 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59206 + kfree(s->obj_hash);
59207 + else
59208 + vfree(s->obj_hash);
59209 + FOR_EACH_SUBJECT_END(s, x)
59210 + FOR_EACH_NESTED_SUBJECT_START(r, s)
59211 + if (s->obj_hash == NULL)
59212 + break;
59213 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59214 + kfree(s->obj_hash);
59215 + else
59216 + vfree(s->obj_hash);
59217 + FOR_EACH_NESTED_SUBJECT_END(s)
59218 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
59219 + kfree(r->subj_hash);
59220 + else
59221 + vfree(r->subj_hash);
59222 + r->subj_hash = NULL;
59223 +next_role:
59224 + FOR_EACH_ROLE_END(r)
59225 +
59226 + acl_free_all();
59227 +
59228 + if (acl_role_set.r_hash) {
59229 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
59230 + PAGE_SIZE)
59231 + kfree(acl_role_set.r_hash);
59232 + else
59233 + vfree(acl_role_set.r_hash);
59234 + }
59235 + if (name_set.n_hash) {
59236 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
59237 + PAGE_SIZE)
59238 + kfree(name_set.n_hash);
59239 + else
59240 + vfree(name_set.n_hash);
59241 + }
59242 +
59243 + if (inodev_set.i_hash) {
59244 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
59245 + PAGE_SIZE)
59246 + kfree(inodev_set.i_hash);
59247 + else
59248 + vfree(inodev_set.i_hash);
59249 + }
59250 +
59251 + gr_free_uidset();
59252 +
59253 + memset(&name_set, 0, sizeof (struct name_db));
59254 + memset(&inodev_set, 0, sizeof (struct inodev_db));
59255 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
59256 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
59257 +
59258 + default_role = NULL;
59259 + kernel_role = NULL;
59260 + role_list = NULL;
59261 +
59262 + return;
59263 +}
59264 +
59265 +static __u32
59266 +count_user_objs(struct acl_object_label *userp)
59267 +{
59268 + struct acl_object_label o_tmp;
59269 + __u32 num = 0;
59270 +
59271 + while (userp) {
59272 + if (copy_from_user(&o_tmp, userp,
59273 + sizeof (struct acl_object_label)))
59274 + break;
59275 +
59276 + userp = o_tmp.prev;
59277 + num++;
59278 + }
59279 +
59280 + return num;
59281 +}
59282 +
59283 +static struct acl_subject_label *
59284 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
59285 +
59286 +static int
59287 +copy_user_glob(struct acl_object_label *obj)
59288 +{
59289 + struct acl_object_label *g_tmp, **guser;
59290 + unsigned int len;
59291 + char *tmp;
59292 +
59293 + if (obj->globbed == NULL)
59294 + return 0;
59295 +
59296 + guser = &obj->globbed;
59297 + while (*guser) {
59298 + g_tmp = (struct acl_object_label *)
59299 + acl_alloc(sizeof (struct acl_object_label));
59300 + if (g_tmp == NULL)
59301 + return -ENOMEM;
59302 +
59303 + if (copy_from_user(g_tmp, *guser,
59304 + sizeof (struct acl_object_label)))
59305 + return -EFAULT;
59306 +
59307 + len = strnlen_user(g_tmp->filename, PATH_MAX);
59308 +
59309 + if (!len || len >= PATH_MAX)
59310 + return -EINVAL;
59311 +
59312 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59313 + return -ENOMEM;
59314 +
59315 + if (copy_from_user(tmp, g_tmp->filename, len))
59316 + return -EFAULT;
59317 + tmp[len-1] = '\0';
59318 + g_tmp->filename = tmp;
59319 +
59320 + *guser = g_tmp;
59321 + guser = &(g_tmp->next);
59322 + }
59323 +
59324 + return 0;
59325 +}
59326 +
59327 +static int
59328 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
59329 + struct acl_role_label *role)
59330 +{
59331 + struct acl_object_label *o_tmp;
59332 + unsigned int len;
59333 + int ret;
59334 + char *tmp;
59335 +
59336 + while (userp) {
59337 + if ((o_tmp = (struct acl_object_label *)
59338 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
59339 + return -ENOMEM;
59340 +
59341 + if (copy_from_user(o_tmp, userp,
59342 + sizeof (struct acl_object_label)))
59343 + return -EFAULT;
59344 +
59345 + userp = o_tmp->prev;
59346 +
59347 + len = strnlen_user(o_tmp->filename, PATH_MAX);
59348 +
59349 + if (!len || len >= PATH_MAX)
59350 + return -EINVAL;
59351 +
59352 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59353 + return -ENOMEM;
59354 +
59355 + if (copy_from_user(tmp, o_tmp->filename, len))
59356 + return -EFAULT;
59357 + tmp[len-1] = '\0';
59358 + o_tmp->filename = tmp;
59359 +
59360 + insert_acl_obj_label(o_tmp, subj);
59361 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
59362 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
59363 + return -ENOMEM;
59364 +
59365 + ret = copy_user_glob(o_tmp);
59366 + if (ret)
59367 + return ret;
59368 +
59369 + if (o_tmp->nested) {
59370 + int already_copied;
59371 +
59372 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
59373 + if (IS_ERR(o_tmp->nested))
59374 + return PTR_ERR(o_tmp->nested);
59375 +
59376 + /* insert into nested subject list if we haven't copied this one yet
59377 + to prevent duplicate entries */
59378 + if (!already_copied) {
59379 + o_tmp->nested->next = role->hash->first;
59380 + role->hash->first = o_tmp->nested;
59381 + }
59382 + }
59383 + }
59384 +
59385 + return 0;
59386 +}
59387 +
59388 +static __u32
59389 +count_user_subjs(struct acl_subject_label *userp)
59390 +{
59391 + struct acl_subject_label s_tmp;
59392 + __u32 num = 0;
59393 +
59394 + while (userp) {
59395 + if (copy_from_user(&s_tmp, userp,
59396 + sizeof (struct acl_subject_label)))
59397 + break;
59398 +
59399 + userp = s_tmp.prev;
59400 + }
59401 +
59402 + return num;
59403 +}
59404 +
59405 +static int
59406 +copy_user_allowedips(struct acl_role_label *rolep)
59407 +{
59408 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
59409 +
59410 + ruserip = rolep->allowed_ips;
59411 +
59412 + while (ruserip) {
59413 + rlast = rtmp;
59414 +
59415 + if ((rtmp = (struct role_allowed_ip *)
59416 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
59417 + return -ENOMEM;
59418 +
59419 + if (copy_from_user(rtmp, ruserip,
59420 + sizeof (struct role_allowed_ip)))
59421 + return -EFAULT;
59422 +
59423 + ruserip = rtmp->prev;
59424 +
59425 + if (!rlast) {
59426 + rtmp->prev = NULL;
59427 + rolep->allowed_ips = rtmp;
59428 + } else {
59429 + rlast->next = rtmp;
59430 + rtmp->prev = rlast;
59431 + }
59432 +
59433 + if (!ruserip)
59434 + rtmp->next = NULL;
59435 + }
59436 +
59437 + return 0;
59438 +}
59439 +
59440 +static int
59441 +copy_user_transitions(struct acl_role_label *rolep)
59442 +{
59443 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
59444 +
59445 + unsigned int len;
59446 + char *tmp;
59447 +
59448 + rusertp = rolep->transitions;
59449 +
59450 + while (rusertp) {
59451 + rlast = rtmp;
59452 +
59453 + if ((rtmp = (struct role_transition *)
59454 + acl_alloc(sizeof (struct role_transition))) == NULL)
59455 + return -ENOMEM;
59456 +
59457 + if (copy_from_user(rtmp, rusertp,
59458 + sizeof (struct role_transition)))
59459 + return -EFAULT;
59460 +
59461 + rusertp = rtmp->prev;
59462 +
59463 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
59464 +
59465 + if (!len || len >= GR_SPROLE_LEN)
59466 + return -EINVAL;
59467 +
59468 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59469 + return -ENOMEM;
59470 +
59471 + if (copy_from_user(tmp, rtmp->rolename, len))
59472 + return -EFAULT;
59473 + tmp[len-1] = '\0';
59474 + rtmp->rolename = tmp;
59475 +
59476 + if (!rlast) {
59477 + rtmp->prev = NULL;
59478 + rolep->transitions = rtmp;
59479 + } else {
59480 + rlast->next = rtmp;
59481 + rtmp->prev = rlast;
59482 + }
59483 +
59484 + if (!rusertp)
59485 + rtmp->next = NULL;
59486 + }
59487 +
59488 + return 0;
59489 +}
59490 +
59491 +static struct acl_subject_label *
59492 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
59493 +{
59494 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
59495 + unsigned int len;
59496 + char *tmp;
59497 + __u32 num_objs;
59498 + struct acl_ip_label **i_tmp, *i_utmp2;
59499 + struct gr_hash_struct ghash;
59500 + struct subject_map *subjmap;
59501 + unsigned int i_num;
59502 + int err;
59503 +
59504 + if (already_copied != NULL)
59505 + *already_copied = 0;
59506 +
59507 + s_tmp = lookup_subject_map(userp);
59508 +
59509 + /* we've already copied this subject into the kernel, just return
59510 + the reference to it, and don't copy it over again
59511 + */
59512 + if (s_tmp) {
59513 + if (already_copied != NULL)
59514 + *already_copied = 1;
59515 + return(s_tmp);
59516 + }
59517 +
59518 + if ((s_tmp = (struct acl_subject_label *)
59519 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
59520 + return ERR_PTR(-ENOMEM);
59521 +
59522 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
59523 + if (subjmap == NULL)
59524 + return ERR_PTR(-ENOMEM);
59525 +
59526 + subjmap->user = userp;
59527 + subjmap->kernel = s_tmp;
59528 + insert_subj_map_entry(subjmap);
59529 +
59530 + if (copy_from_user(s_tmp, userp,
59531 + sizeof (struct acl_subject_label)))
59532 + return ERR_PTR(-EFAULT);
59533 +
59534 + len = strnlen_user(s_tmp->filename, PATH_MAX);
59535 +
59536 + if (!len || len >= PATH_MAX)
59537 + return ERR_PTR(-EINVAL);
59538 +
59539 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59540 + return ERR_PTR(-ENOMEM);
59541 +
59542 + if (copy_from_user(tmp, s_tmp->filename, len))
59543 + return ERR_PTR(-EFAULT);
59544 + tmp[len-1] = '\0';
59545 + s_tmp->filename = tmp;
59546 +
59547 + if (!strcmp(s_tmp->filename, "/"))
59548 + role->root_label = s_tmp;
59549 +
59550 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
59551 + return ERR_PTR(-EFAULT);
59552 +
59553 + /* copy user and group transition tables */
59554 +
59555 + if (s_tmp->user_trans_num) {
59556 + uid_t *uidlist;
59557 +
59558 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
59559 + if (uidlist == NULL)
59560 + return ERR_PTR(-ENOMEM);
59561 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
59562 + return ERR_PTR(-EFAULT);
59563 +
59564 + s_tmp->user_transitions = uidlist;
59565 + }
59566 +
59567 + if (s_tmp->group_trans_num) {
59568 + gid_t *gidlist;
59569 +
59570 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
59571 + if (gidlist == NULL)
59572 + return ERR_PTR(-ENOMEM);
59573 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
59574 + return ERR_PTR(-EFAULT);
59575 +
59576 + s_tmp->group_transitions = gidlist;
59577 + }
59578 +
59579 + /* set up object hash table */
59580 + num_objs = count_user_objs(ghash.first);
59581 +
59582 + s_tmp->obj_hash_size = num_objs;
59583 + s_tmp->obj_hash =
59584 + (struct acl_object_label **)
59585 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
59586 +
59587 + if (!s_tmp->obj_hash)
59588 + return ERR_PTR(-ENOMEM);
59589 +
59590 + memset(s_tmp->obj_hash, 0,
59591 + s_tmp->obj_hash_size *
59592 + sizeof (struct acl_object_label *));
59593 +
59594 + /* add in objects */
59595 + err = copy_user_objs(ghash.first, s_tmp, role);
59596 +
59597 + if (err)
59598 + return ERR_PTR(err);
59599 +
59600 + /* set pointer for parent subject */
59601 + if (s_tmp->parent_subject) {
59602 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
59603 +
59604 + if (IS_ERR(s_tmp2))
59605 + return s_tmp2;
59606 +
59607 + s_tmp->parent_subject = s_tmp2;
59608 + }
59609 +
59610 + /* add in ip acls */
59611 +
59612 + if (!s_tmp->ip_num) {
59613 + s_tmp->ips = NULL;
59614 + goto insert;
59615 + }
59616 +
59617 + i_tmp =
59618 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
59619 + sizeof (struct acl_ip_label *));
59620 +
59621 + if (!i_tmp)
59622 + return ERR_PTR(-ENOMEM);
59623 +
59624 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
59625 + *(i_tmp + i_num) =
59626 + (struct acl_ip_label *)
59627 + acl_alloc(sizeof (struct acl_ip_label));
59628 + if (!*(i_tmp + i_num))
59629 + return ERR_PTR(-ENOMEM);
59630 +
59631 + if (copy_from_user
59632 + (&i_utmp2, s_tmp->ips + i_num,
59633 + sizeof (struct acl_ip_label *)))
59634 + return ERR_PTR(-EFAULT);
59635 +
59636 + if (copy_from_user
59637 + (*(i_tmp + i_num), i_utmp2,
59638 + sizeof (struct acl_ip_label)))
59639 + return ERR_PTR(-EFAULT);
59640 +
59641 + if ((*(i_tmp + i_num))->iface == NULL)
59642 + continue;
59643 +
59644 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
59645 + if (!len || len >= IFNAMSIZ)
59646 + return ERR_PTR(-EINVAL);
59647 + tmp = acl_alloc(len);
59648 + if (tmp == NULL)
59649 + return ERR_PTR(-ENOMEM);
59650 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
59651 + return ERR_PTR(-EFAULT);
59652 + (*(i_tmp + i_num))->iface = tmp;
59653 + }
59654 +
59655 + s_tmp->ips = i_tmp;
59656 +
59657 +insert:
59658 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
59659 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
59660 + return ERR_PTR(-ENOMEM);
59661 +
59662 + return s_tmp;
59663 +}
59664 +
59665 +static int
59666 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
59667 +{
59668 + struct acl_subject_label s_pre;
59669 + struct acl_subject_label * ret;
59670 + int err;
59671 +
59672 + while (userp) {
59673 + if (copy_from_user(&s_pre, userp,
59674 + sizeof (struct acl_subject_label)))
59675 + return -EFAULT;
59676 +
59677 + ret = do_copy_user_subj(userp, role, NULL);
59678 +
59679 + err = PTR_ERR(ret);
59680 + if (IS_ERR(ret))
59681 + return err;
59682 +
59683 + insert_acl_subj_label(ret, role);
59684 +
59685 + userp = s_pre.prev;
59686 + }
59687 +
59688 + return 0;
59689 +}
59690 +
59691 +static int
59692 +copy_user_acl(struct gr_arg *arg)
59693 +{
59694 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
59695 + struct acl_subject_label *subj_list;
59696 + struct sprole_pw *sptmp;
59697 + struct gr_hash_struct *ghash;
59698 + uid_t *domainlist;
59699 + unsigned int r_num;
59700 + unsigned int len;
59701 + char *tmp;
59702 + int err = 0;
59703 + __u16 i;
59704 + __u32 num_subjs;
59705 +
59706 + /* we need a default and kernel role */
59707 + if (arg->role_db.num_roles < 2)
59708 + return -EINVAL;
59709 +
59710 + /* copy special role authentication info from userspace */
59711 +
59712 + num_sprole_pws = arg->num_sprole_pws;
59713 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
59714 +
59715 + if (!acl_special_roles && num_sprole_pws)
59716 + return -ENOMEM;
59717 +
59718 + for (i = 0; i < num_sprole_pws; i++) {
59719 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
59720 + if (!sptmp)
59721 + return -ENOMEM;
59722 + if (copy_from_user(sptmp, arg->sprole_pws + i,
59723 + sizeof (struct sprole_pw)))
59724 + return -EFAULT;
59725 +
59726 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
59727 +
59728 + if (!len || len >= GR_SPROLE_LEN)
59729 + return -EINVAL;
59730 +
59731 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59732 + return -ENOMEM;
59733 +
59734 + if (copy_from_user(tmp, sptmp->rolename, len))
59735 + return -EFAULT;
59736 +
59737 + tmp[len-1] = '\0';
59738 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59739 + printk(KERN_ALERT "Copying special role %s\n", tmp);
59740 +#endif
59741 + sptmp->rolename = tmp;
59742 + acl_special_roles[i] = sptmp;
59743 + }
59744 +
59745 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
59746 +
59747 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
59748 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
59749 +
59750 + if (!r_tmp)
59751 + return -ENOMEM;
59752 +
59753 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
59754 + sizeof (struct acl_role_label *)))
59755 + return -EFAULT;
59756 +
59757 + if (copy_from_user(r_tmp, r_utmp2,
59758 + sizeof (struct acl_role_label)))
59759 + return -EFAULT;
59760 +
59761 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
59762 +
59763 + if (!len || len >= PATH_MAX)
59764 + return -EINVAL;
59765 +
59766 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59767 + return -ENOMEM;
59768 +
59769 + if (copy_from_user(tmp, r_tmp->rolename, len))
59770 + return -EFAULT;
59771 +
59772 + tmp[len-1] = '\0';
59773 + r_tmp->rolename = tmp;
59774 +
59775 + if (!strcmp(r_tmp->rolename, "default")
59776 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
59777 + default_role = r_tmp;
59778 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
59779 + kernel_role = r_tmp;
59780 + }
59781 +
59782 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
59783 + return -ENOMEM;
59784 +
59785 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
59786 + return -EFAULT;
59787 +
59788 + r_tmp->hash = ghash;
59789 +
59790 + num_subjs = count_user_subjs(r_tmp->hash->first);
59791 +
59792 + r_tmp->subj_hash_size = num_subjs;
59793 + r_tmp->subj_hash =
59794 + (struct acl_subject_label **)
59795 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
59796 +
59797 + if (!r_tmp->subj_hash)
59798 + return -ENOMEM;
59799 +
59800 + err = copy_user_allowedips(r_tmp);
59801 + if (err)
59802 + return err;
59803 +
59804 + /* copy domain info */
59805 + if (r_tmp->domain_children != NULL) {
59806 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
59807 + if (domainlist == NULL)
59808 + return -ENOMEM;
59809 +
59810 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
59811 + return -EFAULT;
59812 +
59813 + r_tmp->domain_children = domainlist;
59814 + }
59815 +
59816 + err = copy_user_transitions(r_tmp);
59817 + if (err)
59818 + return err;
59819 +
59820 + memset(r_tmp->subj_hash, 0,
59821 + r_tmp->subj_hash_size *
59822 + sizeof (struct acl_subject_label *));
59823 +
59824 + /* acquire the list of subjects, then NULL out
59825 + the list prior to parsing the subjects for this role,
59826 + as during this parsing the list is replaced with a list
59827 + of *nested* subjects for the role
59828 + */
59829 + subj_list = r_tmp->hash->first;
59830 +
59831 + /* set nested subject list to null */
59832 + r_tmp->hash->first = NULL;
59833 +
59834 + err = copy_user_subjs(subj_list, r_tmp);
59835 +
59836 + if (err)
59837 + return err;
59838 +
59839 + insert_acl_role_label(r_tmp);
59840 + }
59841 +
59842 + if (default_role == NULL || kernel_role == NULL)
59843 + return -EINVAL;
59844 +
59845 + return err;
59846 +}
59847 +
59848 +static int
59849 +gracl_init(struct gr_arg *args)
59850 +{
59851 + int error = 0;
59852 +
59853 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
59854 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
59855 +
59856 + if (init_variables(args)) {
59857 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
59858 + error = -ENOMEM;
59859 + free_variables();
59860 + goto out;
59861 + }
59862 +
59863 + error = copy_user_acl(args);
59864 + free_init_variables();
59865 + if (error) {
59866 + free_variables();
59867 + goto out;
59868 + }
59869 +
59870 + if ((error = gr_set_acls(0))) {
59871 + free_variables();
59872 + goto out;
59873 + }
59874 +
59875 + pax_open_kernel();
59876 + gr_status |= GR_READY;
59877 + pax_close_kernel();
59878 +
59879 + out:
59880 + return error;
59881 +}
59882 +
59883 +/* derived from glibc fnmatch() 0: match, 1: no match*/
59884 +
59885 +static int
59886 +glob_match(const char *p, const char *n)
59887 +{
59888 + char c;
59889 +
59890 + while ((c = *p++) != '\0') {
59891 + switch (c) {
59892 + case '?':
59893 + if (*n == '\0')
59894 + return 1;
59895 + else if (*n == '/')
59896 + return 1;
59897 + break;
59898 + case '\\':
59899 + if (*n != c)
59900 + return 1;
59901 + break;
59902 + case '*':
59903 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
59904 + if (*n == '/')
59905 + return 1;
59906 + else if (c == '?') {
59907 + if (*n == '\0')
59908 + return 1;
59909 + else
59910 + ++n;
59911 + }
59912 + }
59913 + if (c == '\0') {
59914 + return 0;
59915 + } else {
59916 + const char *endp;
59917 +
59918 + if ((endp = strchr(n, '/')) == NULL)
59919 + endp = n + strlen(n);
59920 +
59921 + if (c == '[') {
59922 + for (--p; n < endp; ++n)
59923 + if (!glob_match(p, n))
59924 + return 0;
59925 + } else if (c == '/') {
59926 + while (*n != '\0' && *n != '/')
59927 + ++n;
59928 + if (*n == '/' && !glob_match(p, n + 1))
59929 + return 0;
59930 + } else {
59931 + for (--p; n < endp; ++n)
59932 + if (*n == c && !glob_match(p, n))
59933 + return 0;
59934 + }
59935 +
59936 + return 1;
59937 + }
59938 + case '[':
59939 + {
59940 + int not;
59941 + char cold;
59942 +
59943 + if (*n == '\0' || *n == '/')
59944 + return 1;
59945 +
59946 + not = (*p == '!' || *p == '^');
59947 + if (not)
59948 + ++p;
59949 +
59950 + c = *p++;
59951 + for (;;) {
59952 + unsigned char fn = (unsigned char)*n;
59953 +
59954 + if (c == '\0')
59955 + return 1;
59956 + else {
59957 + if (c == fn)
59958 + goto matched;
59959 + cold = c;
59960 + c = *p++;
59961 +
59962 + if (c == '-' && *p != ']') {
59963 + unsigned char cend = *p++;
59964 +
59965 + if (cend == '\0')
59966 + return 1;
59967 +
59968 + if (cold <= fn && fn <= cend)
59969 + goto matched;
59970 +
59971 + c = *p++;
59972 + }
59973 + }
59974 +
59975 + if (c == ']')
59976 + break;
59977 + }
59978 + if (!not)
59979 + return 1;
59980 + break;
59981 + matched:
59982 + while (c != ']') {
59983 + if (c == '\0')
59984 + return 1;
59985 +
59986 + c = *p++;
59987 + }
59988 + if (not)
59989 + return 1;
59990 + }
59991 + break;
59992 + default:
59993 + if (c != *n)
59994 + return 1;
59995 + }
59996 +
59997 + ++n;
59998 + }
59999 +
60000 + if (*n == '\0')
60001 + return 0;
60002 +
60003 + if (*n == '/')
60004 + return 0;
60005 +
60006 + return 1;
60007 +}
60008 +
60009 +static struct acl_object_label *
60010 +chk_glob_label(struct acl_object_label *globbed,
60011 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
60012 +{
60013 + struct acl_object_label *tmp;
60014 +
60015 + if (*path == NULL)
60016 + *path = gr_to_filename_nolock(dentry, mnt);
60017 +
60018 + tmp = globbed;
60019 +
60020 + while (tmp) {
60021 + if (!glob_match(tmp->filename, *path))
60022 + return tmp;
60023 + tmp = tmp->next;
60024 + }
60025 +
60026 + return NULL;
60027 +}
60028 +
60029 +static struct acl_object_label *
60030 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
60031 + const ino_t curr_ino, const dev_t curr_dev,
60032 + const struct acl_subject_label *subj, char **path, const int checkglob)
60033 +{
60034 + struct acl_subject_label *tmpsubj;
60035 + struct acl_object_label *retval;
60036 + struct acl_object_label *retval2;
60037 +
60038 + tmpsubj = (struct acl_subject_label *) subj;
60039 + read_lock(&gr_inode_lock);
60040 + do {
60041 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
60042 + if (retval) {
60043 + if (checkglob && retval->globbed) {
60044 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
60045 + if (retval2)
60046 + retval = retval2;
60047 + }
60048 + break;
60049 + }
60050 + } while ((tmpsubj = tmpsubj->parent_subject));
60051 + read_unlock(&gr_inode_lock);
60052 +
60053 + return retval;
60054 +}
60055 +
60056 +static __inline__ struct acl_object_label *
60057 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
60058 + struct dentry *curr_dentry,
60059 + const struct acl_subject_label *subj, char **path, const int checkglob)
60060 +{
60061 + int newglob = checkglob;
60062 + ino_t inode;
60063 + dev_t device;
60064 +
60065 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
60066 + as we don't want a / * rule to match instead of the / object
60067 + don't do this for create lookups that call this function though, since they're looking up
60068 + on the parent and thus need globbing checks on all paths
60069 + */
60070 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
60071 + newglob = GR_NO_GLOB;
60072 +
60073 + spin_lock(&curr_dentry->d_lock);
60074 + inode = curr_dentry->d_inode->i_ino;
60075 + device = __get_dev(curr_dentry);
60076 + spin_unlock(&curr_dentry->d_lock);
60077 +
60078 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
60079 +}
60080 +
60081 +#ifdef CONFIG_HUGETLBFS
60082 +static inline bool
60083 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
60084 +{
60085 + int i;
60086 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
60087 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
60088 + return true;
60089 + }
60090 +
60091 + return false;
60092 +}
60093 +#endif
60094 +
60095 +static struct acl_object_label *
60096 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60097 + const struct acl_subject_label *subj, char *path, const int checkglob)
60098 +{
60099 + struct dentry *dentry = (struct dentry *) l_dentry;
60100 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60101 + struct mount *real_mnt = real_mount(mnt);
60102 + struct acl_object_label *retval;
60103 + struct dentry *parent;
60104 +
60105 + br_read_lock(&vfsmount_lock);
60106 + write_seqlock(&rename_lock);
60107 +
60108 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
60109 +#ifdef CONFIG_NET
60110 + mnt == sock_mnt ||
60111 +#endif
60112 +#ifdef CONFIG_HUGETLBFS
60113 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
60114 +#endif
60115 + /* ignore Eric Biederman */
60116 + IS_PRIVATE(l_dentry->d_inode))) {
60117 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
60118 + goto out;
60119 + }
60120 +
60121 + for (;;) {
60122 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60123 + break;
60124 +
60125 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60126 + if (!mnt_has_parent(real_mnt))
60127 + break;
60128 +
60129 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60130 + if (retval != NULL)
60131 + goto out;
60132 +
60133 + dentry = real_mnt->mnt_mountpoint;
60134 + real_mnt = real_mnt->mnt_parent;
60135 + mnt = &real_mnt->mnt;
60136 + continue;
60137 + }
60138 +
60139 + parent = dentry->d_parent;
60140 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60141 + if (retval != NULL)
60142 + goto out;
60143 +
60144 + dentry = parent;
60145 + }
60146 +
60147 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60148 +
60149 + /* real_root is pinned so we don't have to hold a reference */
60150 + if (retval == NULL)
60151 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
60152 +out:
60153 + write_sequnlock(&rename_lock);
60154 + br_read_unlock(&vfsmount_lock);
60155 +
60156 + BUG_ON(retval == NULL);
60157 +
60158 + return retval;
60159 +}
60160 +
60161 +static __inline__ struct acl_object_label *
60162 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60163 + const struct acl_subject_label *subj)
60164 +{
60165 + char *path = NULL;
60166 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
60167 +}
60168 +
60169 +static __inline__ struct acl_object_label *
60170 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60171 + const struct acl_subject_label *subj)
60172 +{
60173 + char *path = NULL;
60174 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
60175 +}
60176 +
60177 +static __inline__ struct acl_object_label *
60178 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60179 + const struct acl_subject_label *subj, char *path)
60180 +{
60181 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
60182 +}
60183 +
60184 +static struct acl_subject_label *
60185 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60186 + const struct acl_role_label *role)
60187 +{
60188 + struct dentry *dentry = (struct dentry *) l_dentry;
60189 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60190 + struct mount *real_mnt = real_mount(mnt);
60191 + struct acl_subject_label *retval;
60192 + struct dentry *parent;
60193 +
60194 + br_read_lock(&vfsmount_lock);
60195 + write_seqlock(&rename_lock);
60196 +
60197 + for (;;) {
60198 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60199 + break;
60200 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60201 + if (!mnt_has_parent(real_mnt))
60202 + break;
60203 +
60204 + spin_lock(&dentry->d_lock);
60205 + read_lock(&gr_inode_lock);
60206 + retval =
60207 + lookup_acl_subj_label(dentry->d_inode->i_ino,
60208 + __get_dev(dentry), role);
60209 + read_unlock(&gr_inode_lock);
60210 + spin_unlock(&dentry->d_lock);
60211 + if (retval != NULL)
60212 + goto out;
60213 +
60214 + dentry = real_mnt->mnt_mountpoint;
60215 + real_mnt = real_mnt->mnt_parent;
60216 + mnt = &real_mnt->mnt;
60217 + continue;
60218 + }
60219 +
60220 + spin_lock(&dentry->d_lock);
60221 + read_lock(&gr_inode_lock);
60222 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60223 + __get_dev(dentry), role);
60224 + read_unlock(&gr_inode_lock);
60225 + parent = dentry->d_parent;
60226 + spin_unlock(&dentry->d_lock);
60227 +
60228 + if (retval != NULL)
60229 + goto out;
60230 +
60231 + dentry = parent;
60232 + }
60233 +
60234 + spin_lock(&dentry->d_lock);
60235 + read_lock(&gr_inode_lock);
60236 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60237 + __get_dev(dentry), role);
60238 + read_unlock(&gr_inode_lock);
60239 + spin_unlock(&dentry->d_lock);
60240 +
60241 + if (unlikely(retval == NULL)) {
60242 + /* real_root is pinned, we don't need to hold a reference */
60243 + read_lock(&gr_inode_lock);
60244 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
60245 + __get_dev(real_root.dentry), role);
60246 + read_unlock(&gr_inode_lock);
60247 + }
60248 +out:
60249 + write_sequnlock(&rename_lock);
60250 + br_read_unlock(&vfsmount_lock);
60251 +
60252 + BUG_ON(retval == NULL);
60253 +
60254 + return retval;
60255 +}
60256 +
60257 +static void
60258 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
60259 +{
60260 + struct task_struct *task = current;
60261 + const struct cred *cred = current_cred();
60262 +
60263 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
60264 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60265 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60266 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
60267 +
60268 + return;
60269 +}
60270 +
60271 +static void
60272 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
60273 +{
60274 + struct task_struct *task = current;
60275 + const struct cred *cred = current_cred();
60276 +
60277 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60278 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60279 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60280 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
60281 +
60282 + return;
60283 +}
60284 +
60285 +static void
60286 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
60287 +{
60288 + struct task_struct *task = current;
60289 + const struct cred *cred = current_cred();
60290 +
60291 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60292 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60293 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60294 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
60295 +
60296 + return;
60297 +}
60298 +
60299 +__u32
60300 +gr_search_file(const struct dentry * dentry, const __u32 mode,
60301 + const struct vfsmount * mnt)
60302 +{
60303 + __u32 retval = mode;
60304 + struct acl_subject_label *curracl;
60305 + struct acl_object_label *currobj;
60306 +
60307 + if (unlikely(!(gr_status & GR_READY)))
60308 + return (mode & ~GR_AUDITS);
60309 +
60310 + curracl = current->acl;
60311 +
60312 + currobj = chk_obj_label(dentry, mnt, curracl);
60313 + retval = currobj->mode & mode;
60314 +
60315 + /* if we're opening a specified transfer file for writing
60316 + (e.g. /dev/initctl), then transfer our role to init
60317 + */
60318 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
60319 + current->role->roletype & GR_ROLE_PERSIST)) {
60320 + struct task_struct *task = init_pid_ns.child_reaper;
60321 +
60322 + if (task->role != current->role) {
60323 + task->acl_sp_role = 0;
60324 + task->acl_role_id = current->acl_role_id;
60325 + task->role = current->role;
60326 + rcu_read_lock();
60327 + read_lock(&grsec_exec_file_lock);
60328 + gr_apply_subject_to_task(task);
60329 + read_unlock(&grsec_exec_file_lock);
60330 + rcu_read_unlock();
60331 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
60332 + }
60333 + }
60334 +
60335 + if (unlikely
60336 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
60337 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
60338 + __u32 new_mode = mode;
60339 +
60340 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60341 +
60342 + retval = new_mode;
60343 +
60344 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
60345 + new_mode |= GR_INHERIT;
60346 +
60347 + if (!(mode & GR_NOLEARN))
60348 + gr_log_learn(dentry, mnt, new_mode);
60349 + }
60350 +
60351 + return retval;
60352 +}
60353 +
60354 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
60355 + const struct dentry *parent,
60356 + const struct vfsmount *mnt)
60357 +{
60358 + struct name_entry *match;
60359 + struct acl_object_label *matchpo;
60360 + struct acl_subject_label *curracl;
60361 + char *path;
60362 +
60363 + if (unlikely(!(gr_status & GR_READY)))
60364 + return NULL;
60365 +
60366 + preempt_disable();
60367 + path = gr_to_filename_rbac(new_dentry, mnt);
60368 + match = lookup_name_entry_create(path);
60369 +
60370 + curracl = current->acl;
60371 +
60372 + if (match) {
60373 + read_lock(&gr_inode_lock);
60374 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
60375 + read_unlock(&gr_inode_lock);
60376 +
60377 + if (matchpo) {
60378 + preempt_enable();
60379 + return matchpo;
60380 + }
60381 + }
60382 +
60383 + // lookup parent
60384 +
60385 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
60386 +
60387 + preempt_enable();
60388 + return matchpo;
60389 +}
60390 +
60391 +__u32
60392 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
60393 + const struct vfsmount * mnt, const __u32 mode)
60394 +{
60395 + struct acl_object_label *matchpo;
60396 + __u32 retval;
60397 +
60398 + if (unlikely(!(gr_status & GR_READY)))
60399 + return (mode & ~GR_AUDITS);
60400 +
60401 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
60402 +
60403 + retval = matchpo->mode & mode;
60404 +
60405 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
60406 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60407 + __u32 new_mode = mode;
60408 +
60409 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60410 +
60411 + gr_log_learn(new_dentry, mnt, new_mode);
60412 + return new_mode;
60413 + }
60414 +
60415 + return retval;
60416 +}
60417 +
60418 +__u32
60419 +gr_check_link(const struct dentry * new_dentry,
60420 + const struct dentry * parent_dentry,
60421 + const struct vfsmount * parent_mnt,
60422 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
60423 +{
60424 + struct acl_object_label *obj;
60425 + __u32 oldmode, newmode;
60426 + __u32 needmode;
60427 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
60428 + GR_DELETE | GR_INHERIT;
60429 +
60430 + if (unlikely(!(gr_status & GR_READY)))
60431 + return (GR_CREATE | GR_LINK);
60432 +
60433 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
60434 + oldmode = obj->mode;
60435 +
60436 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
60437 + newmode = obj->mode;
60438 +
60439 + needmode = newmode & checkmodes;
60440 +
60441 + // old name for hardlink must have at least the permissions of the new name
60442 + if ((oldmode & needmode) != needmode)
60443 + goto bad;
60444 +
60445 + // if old name had restrictions/auditing, make sure the new name does as well
60446 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
60447 +
60448 + // don't allow hardlinking of suid/sgid/fcapped files without permission
60449 + if (is_privileged_binary(old_dentry))
60450 + needmode |= GR_SETID;
60451 +
60452 + if ((newmode & needmode) != needmode)
60453 + goto bad;
60454 +
60455 + // enforce minimum permissions
60456 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
60457 + return newmode;
60458 +bad:
60459 + needmode = oldmode;
60460 + if (is_privileged_binary(old_dentry))
60461 + needmode |= GR_SETID;
60462 +
60463 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
60464 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
60465 + return (GR_CREATE | GR_LINK);
60466 + } else if (newmode & GR_SUPPRESS)
60467 + return GR_SUPPRESS;
60468 + else
60469 + return 0;
60470 +}
60471 +
60472 +int
60473 +gr_check_hidden_task(const struct task_struct *task)
60474 +{
60475 + if (unlikely(!(gr_status & GR_READY)))
60476 + return 0;
60477 +
60478 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
60479 + return 1;
60480 +
60481 + return 0;
60482 +}
60483 +
60484 +int
60485 +gr_check_protected_task(const struct task_struct *task)
60486 +{
60487 + if (unlikely(!(gr_status & GR_READY) || !task))
60488 + return 0;
60489 +
60490 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60491 + task->acl != current->acl)
60492 + return 1;
60493 +
60494 + return 0;
60495 +}
60496 +
60497 +int
60498 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
60499 +{
60500 + struct task_struct *p;
60501 + int ret = 0;
60502 +
60503 + if (unlikely(!(gr_status & GR_READY) || !pid))
60504 + return ret;
60505 +
60506 + read_lock(&tasklist_lock);
60507 + do_each_pid_task(pid, type, p) {
60508 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60509 + p->acl != current->acl) {
60510 + ret = 1;
60511 + goto out;
60512 + }
60513 + } while_each_pid_task(pid, type, p);
60514 +out:
60515 + read_unlock(&tasklist_lock);
60516 +
60517 + return ret;
60518 +}
60519 +
60520 +void
60521 +gr_copy_label(struct task_struct *tsk)
60522 +{
60523 + tsk->signal->used_accept = 0;
60524 + tsk->acl_sp_role = 0;
60525 + tsk->acl_role_id = current->acl_role_id;
60526 + tsk->acl = current->acl;
60527 + tsk->role = current->role;
60528 + tsk->signal->curr_ip = current->signal->curr_ip;
60529 + tsk->signal->saved_ip = current->signal->saved_ip;
60530 + if (current->exec_file)
60531 + get_file(current->exec_file);
60532 + tsk->exec_file = current->exec_file;
60533 + tsk->is_writable = current->is_writable;
60534 + if (unlikely(current->signal->used_accept)) {
60535 + current->signal->curr_ip = 0;
60536 + current->signal->saved_ip = 0;
60537 + }
60538 +
60539 + return;
60540 +}
60541 +
60542 +static void
60543 +gr_set_proc_res(struct task_struct *task)
60544 +{
60545 + struct acl_subject_label *proc;
60546 + unsigned short i;
60547 +
60548 + proc = task->acl;
60549 +
60550 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
60551 + return;
60552 +
60553 + for (i = 0; i < RLIM_NLIMITS; i++) {
60554 + if (!(proc->resmask & (1U << i)))
60555 + continue;
60556 +
60557 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
60558 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
60559 +
60560 + if (i == RLIMIT_CPU)
60561 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
60562 + }
60563 +
60564 + return;
60565 +}
60566 +
60567 +extern int __gr_process_user_ban(struct user_struct *user);
60568 +
60569 +int
60570 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
60571 +{
60572 + unsigned int i;
60573 + __u16 num;
60574 + uid_t *uidlist;
60575 + uid_t curuid;
60576 + int realok = 0;
60577 + int effectiveok = 0;
60578 + int fsok = 0;
60579 + uid_t globalreal, globaleffective, globalfs;
60580 +
60581 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
60582 + struct user_struct *user;
60583 +
60584 + if (!uid_valid(real))
60585 + goto skipit;
60586 +
60587 + /* find user based on global namespace */
60588 +
60589 + globalreal = GR_GLOBAL_UID(real);
60590 +
60591 + user = find_user(make_kuid(&init_user_ns, globalreal));
60592 + if (user == NULL)
60593 + goto skipit;
60594 +
60595 + if (__gr_process_user_ban(user)) {
60596 + /* for find_user */
60597 + free_uid(user);
60598 + return 1;
60599 + }
60600 +
60601 + /* for find_user */
60602 + free_uid(user);
60603 +
60604 +skipit:
60605 +#endif
60606 +
60607 + if (unlikely(!(gr_status & GR_READY)))
60608 + return 0;
60609 +
60610 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60611 + gr_log_learn_uid_change(real, effective, fs);
60612 +
60613 + num = current->acl->user_trans_num;
60614 + uidlist = current->acl->user_transitions;
60615 +
60616 + if (uidlist == NULL)
60617 + return 0;
60618 +
60619 + if (!uid_valid(real)) {
60620 + realok = 1;
60621 + globalreal = (uid_t)-1;
60622 + } else {
60623 + globalreal = GR_GLOBAL_UID(real);
60624 + }
60625 + if (!uid_valid(effective)) {
60626 + effectiveok = 1;
60627 + globaleffective = (uid_t)-1;
60628 + } else {
60629 + globaleffective = GR_GLOBAL_UID(effective);
60630 + }
60631 + if (!uid_valid(fs)) {
60632 + fsok = 1;
60633 + globalfs = (uid_t)-1;
60634 + } else {
60635 + globalfs = GR_GLOBAL_UID(fs);
60636 + }
60637 +
60638 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
60639 + for (i = 0; i < num; i++) {
60640 + curuid = uidlist[i];
60641 + if (globalreal == curuid)
60642 + realok = 1;
60643 + if (globaleffective == curuid)
60644 + effectiveok = 1;
60645 + if (globalfs == curuid)
60646 + fsok = 1;
60647 + }
60648 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
60649 + for (i = 0; i < num; i++) {
60650 + curuid = uidlist[i];
60651 + if (globalreal == curuid)
60652 + break;
60653 + if (globaleffective == curuid)
60654 + break;
60655 + if (globalfs == curuid)
60656 + break;
60657 + }
60658 + /* not in deny list */
60659 + if (i == num) {
60660 + realok = 1;
60661 + effectiveok = 1;
60662 + fsok = 1;
60663 + }
60664 + }
60665 +
60666 + if (realok && effectiveok && fsok)
60667 + return 0;
60668 + else {
60669 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60670 + return 1;
60671 + }
60672 +}
60673 +
60674 +int
60675 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
60676 +{
60677 + unsigned int i;
60678 + __u16 num;
60679 + gid_t *gidlist;
60680 + gid_t curgid;
60681 + int realok = 0;
60682 + int effectiveok = 0;
60683 + int fsok = 0;
60684 + gid_t globalreal, globaleffective, globalfs;
60685 +
60686 + if (unlikely(!(gr_status & GR_READY)))
60687 + return 0;
60688 +
60689 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60690 + gr_log_learn_gid_change(real, effective, fs);
60691 +
60692 + num = current->acl->group_trans_num;
60693 + gidlist = current->acl->group_transitions;
60694 +
60695 + if (gidlist == NULL)
60696 + return 0;
60697 +
60698 + if (!gid_valid(real)) {
60699 + realok = 1;
60700 + globalreal = (gid_t)-1;
60701 + } else {
60702 + globalreal = GR_GLOBAL_GID(real);
60703 + }
60704 + if (!gid_valid(effective)) {
60705 + effectiveok = 1;
60706 + globaleffective = (gid_t)-1;
60707 + } else {
60708 + globaleffective = GR_GLOBAL_GID(effective);
60709 + }
60710 + if (!gid_valid(fs)) {
60711 + fsok = 1;
60712 + globalfs = (gid_t)-1;
60713 + } else {
60714 + globalfs = GR_GLOBAL_GID(fs);
60715 + }
60716 +
60717 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
60718 + for (i = 0; i < num; i++) {
60719 + curgid = gidlist[i];
60720 + if (globalreal == curgid)
60721 + realok = 1;
60722 + if (globaleffective == curgid)
60723 + effectiveok = 1;
60724 + if (globalfs == curgid)
60725 + fsok = 1;
60726 + }
60727 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
60728 + for (i = 0; i < num; i++) {
60729 + curgid = gidlist[i];
60730 + if (globalreal == curgid)
60731 + break;
60732 + if (globaleffective == curgid)
60733 + break;
60734 + if (globalfs == curgid)
60735 + break;
60736 + }
60737 + /* not in deny list */
60738 + if (i == num) {
60739 + realok = 1;
60740 + effectiveok = 1;
60741 + fsok = 1;
60742 + }
60743 + }
60744 +
60745 + if (realok && effectiveok && fsok)
60746 + return 0;
60747 + else {
60748 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60749 + return 1;
60750 + }
60751 +}
60752 +
60753 +extern int gr_acl_is_capable(const int cap);
60754 +
60755 +void
60756 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
60757 +{
60758 + struct acl_role_label *role = task->role;
60759 + struct acl_subject_label *subj = NULL;
60760 + struct acl_object_label *obj;
60761 + struct file *filp;
60762 + uid_t uid;
60763 + gid_t gid;
60764 +
60765 + if (unlikely(!(gr_status & GR_READY)))
60766 + return;
60767 +
60768 + uid = GR_GLOBAL_UID(kuid);
60769 + gid = GR_GLOBAL_GID(kgid);
60770 +
60771 + filp = task->exec_file;
60772 +
60773 + /* kernel process, we'll give them the kernel role */
60774 + if (unlikely(!filp)) {
60775 + task->role = kernel_role;
60776 + task->acl = kernel_role->root_label;
60777 + return;
60778 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
60779 + role = lookup_acl_role_label(task, uid, gid);
60780 +
60781 + /* don't change the role if we're not a privileged process */
60782 + if (role && task->role != role &&
60783 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
60784 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
60785 + return;
60786 +
60787 + /* perform subject lookup in possibly new role
60788 + we can use this result below in the case where role == task->role
60789 + */
60790 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
60791 +
60792 + /* if we changed uid/gid, but result in the same role
60793 + and are using inheritance, don't lose the inherited subject
60794 + if current subject is other than what normal lookup
60795 + would result in, we arrived via inheritance, don't
60796 + lose subject
60797 + */
60798 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
60799 + (subj == task->acl)))
60800 + task->acl = subj;
60801 +
60802 + task->role = role;
60803 +
60804 + task->is_writable = 0;
60805 +
60806 + /* ignore additional mmap checks for processes that are writable
60807 + by the default ACL */
60808 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60809 + if (unlikely(obj->mode & GR_WRITE))
60810 + task->is_writable = 1;
60811 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
60812 + if (unlikely(obj->mode & GR_WRITE))
60813 + task->is_writable = 1;
60814 +
60815 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60816 + 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);
60817 +#endif
60818 +
60819 + gr_set_proc_res(task);
60820 +
60821 + return;
60822 +}
60823 +
60824 +int
60825 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
60826 + const int unsafe_flags)
60827 +{
60828 + struct task_struct *task = current;
60829 + struct acl_subject_label *newacl;
60830 + struct acl_object_label *obj;
60831 + __u32 retmode;
60832 +
60833 + if (unlikely(!(gr_status & GR_READY)))
60834 + return 0;
60835 +
60836 + newacl = chk_subj_label(dentry, mnt, task->role);
60837 +
60838 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
60839 + did an exec
60840 + */
60841 + rcu_read_lock();
60842 + read_lock(&tasklist_lock);
60843 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
60844 + (task->parent->acl->mode & GR_POVERRIDE))) {
60845 + read_unlock(&tasklist_lock);
60846 + rcu_read_unlock();
60847 + goto skip_check;
60848 + }
60849 + read_unlock(&tasklist_lock);
60850 + rcu_read_unlock();
60851 +
60852 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
60853 + !(task->role->roletype & GR_ROLE_GOD) &&
60854 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
60855 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60856 + if (unsafe_flags & LSM_UNSAFE_SHARE)
60857 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
60858 + else
60859 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
60860 + return -EACCES;
60861 + }
60862 +
60863 +skip_check:
60864 +
60865 + obj = chk_obj_label(dentry, mnt, task->acl);
60866 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
60867 +
60868 + if (!(task->acl->mode & GR_INHERITLEARN) &&
60869 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
60870 + if (obj->nested)
60871 + task->acl = obj->nested;
60872 + else
60873 + task->acl = newacl;
60874 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
60875 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
60876 +
60877 + task->is_writable = 0;
60878 +
60879 + /* ignore additional mmap checks for processes that are writable
60880 + by the default ACL */
60881 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
60882 + if (unlikely(obj->mode & GR_WRITE))
60883 + task->is_writable = 1;
60884 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
60885 + if (unlikely(obj->mode & GR_WRITE))
60886 + task->is_writable = 1;
60887 +
60888 + gr_set_proc_res(task);
60889 +
60890 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60891 + 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);
60892 +#endif
60893 + return 0;
60894 +}
60895 +
60896 +/* always called with valid inodev ptr */
60897 +static void
60898 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
60899 +{
60900 + struct acl_object_label *matchpo;
60901 + struct acl_subject_label *matchps;
60902 + struct acl_subject_label *subj;
60903 + struct acl_role_label *role;
60904 + unsigned int x;
60905 +
60906 + FOR_EACH_ROLE_START(role)
60907 + FOR_EACH_SUBJECT_START(role, subj, x)
60908 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60909 + matchpo->mode |= GR_DELETED;
60910 + FOR_EACH_SUBJECT_END(subj,x)
60911 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60912 + /* nested subjects aren't in the role's subj_hash table */
60913 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60914 + matchpo->mode |= GR_DELETED;
60915 + FOR_EACH_NESTED_SUBJECT_END(subj)
60916 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
60917 + matchps->mode |= GR_DELETED;
60918 + FOR_EACH_ROLE_END(role)
60919 +
60920 + inodev->nentry->deleted = 1;
60921 +
60922 + return;
60923 +}
60924 +
60925 +void
60926 +gr_handle_delete(const ino_t ino, const dev_t dev)
60927 +{
60928 + struct inodev_entry *inodev;
60929 +
60930 + if (unlikely(!(gr_status & GR_READY)))
60931 + return;
60932 +
60933 + write_lock(&gr_inode_lock);
60934 + inodev = lookup_inodev_entry(ino, dev);
60935 + if (inodev != NULL)
60936 + do_handle_delete(inodev, ino, dev);
60937 + write_unlock(&gr_inode_lock);
60938 +
60939 + return;
60940 +}
60941 +
60942 +static void
60943 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
60944 + const ino_t newinode, const dev_t newdevice,
60945 + struct acl_subject_label *subj)
60946 +{
60947 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
60948 + struct acl_object_label *match;
60949 +
60950 + match = subj->obj_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 + subj->obj_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_obj_label(match, subj);
60976 + }
60977 +
60978 + return;
60979 +}
60980 +
60981 +static void
60982 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
60983 + const ino_t newinode, const dev_t newdevice,
60984 + struct acl_role_label *role)
60985 +{
60986 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
60987 + struct acl_subject_label *match;
60988 +
60989 + match = role->subj_hash[index];
60990 +
60991 + while (match && (match->inode != oldinode ||
60992 + match->device != olddevice ||
60993 + !(match->mode & GR_DELETED)))
60994 + match = match->next;
60995 +
60996 + if (match && (match->inode == oldinode)
60997 + && (match->device == olddevice)
60998 + && (match->mode & GR_DELETED)) {
60999 + if (match->prev == NULL) {
61000 + role->subj_hash[index] = match->next;
61001 + if (match->next != NULL)
61002 + match->next->prev = NULL;
61003 + } else {
61004 + match->prev->next = match->next;
61005 + if (match->next != NULL)
61006 + match->next->prev = match->prev;
61007 + }
61008 + match->prev = NULL;
61009 + match->next = NULL;
61010 + match->inode = newinode;
61011 + match->device = newdevice;
61012 + match->mode &= ~GR_DELETED;
61013 +
61014 + insert_acl_subj_label(match, role);
61015 + }
61016 +
61017 + return;
61018 +}
61019 +
61020 +static void
61021 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
61022 + const ino_t newinode, const dev_t newdevice)
61023 +{
61024 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
61025 + struct inodev_entry *match;
61026 +
61027 + match = inodev_set.i_hash[index];
61028 +
61029 + while (match && (match->nentry->inode != oldinode ||
61030 + match->nentry->device != olddevice || !match->nentry->deleted))
61031 + match = match->next;
61032 +
61033 + if (match && (match->nentry->inode == oldinode)
61034 + && (match->nentry->device == olddevice) &&
61035 + match->nentry->deleted) {
61036 + if (match->prev == NULL) {
61037 + inodev_set.i_hash[index] = match->next;
61038 + if (match->next != NULL)
61039 + match->next->prev = NULL;
61040 + } else {
61041 + match->prev->next = match->next;
61042 + if (match->next != NULL)
61043 + match->next->prev = match->prev;
61044 + }
61045 + match->prev = NULL;
61046 + match->next = NULL;
61047 + match->nentry->inode = newinode;
61048 + match->nentry->device = newdevice;
61049 + match->nentry->deleted = 0;
61050 +
61051 + insert_inodev_entry(match);
61052 + }
61053 +
61054 + return;
61055 +}
61056 +
61057 +static void
61058 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
61059 +{
61060 + struct acl_subject_label *subj;
61061 + struct acl_role_label *role;
61062 + unsigned int x;
61063 +
61064 + FOR_EACH_ROLE_START(role)
61065 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
61066 +
61067 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
61068 + if ((subj->inode == ino) && (subj->device == dev)) {
61069 + subj->inode = ino;
61070 + subj->device = dev;
61071 + }
61072 + /* nested subjects aren't in the role's subj_hash table */
61073 + update_acl_obj_label(matchn->inode, matchn->device,
61074 + ino, dev, subj);
61075 + FOR_EACH_NESTED_SUBJECT_END(subj)
61076 + FOR_EACH_SUBJECT_START(role, subj, x)
61077 + update_acl_obj_label(matchn->inode, matchn->device,
61078 + ino, dev, subj);
61079 + FOR_EACH_SUBJECT_END(subj,x)
61080 + FOR_EACH_ROLE_END(role)
61081 +
61082 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
61083 +
61084 + return;
61085 +}
61086 +
61087 +static void
61088 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
61089 + const struct vfsmount *mnt)
61090 +{
61091 + ino_t ino = dentry->d_inode->i_ino;
61092 + dev_t dev = __get_dev(dentry);
61093 +
61094 + __do_handle_create(matchn, ino, dev);
61095 +
61096 + return;
61097 +}
61098 +
61099 +void
61100 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
61101 +{
61102 + struct name_entry *matchn;
61103 +
61104 + if (unlikely(!(gr_status & GR_READY)))
61105 + return;
61106 +
61107 + preempt_disable();
61108 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
61109 +
61110 + if (unlikely((unsigned long)matchn)) {
61111 + write_lock(&gr_inode_lock);
61112 + do_handle_create(matchn, dentry, mnt);
61113 + write_unlock(&gr_inode_lock);
61114 + }
61115 + preempt_enable();
61116 +
61117 + return;
61118 +}
61119 +
61120 +void
61121 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
61122 +{
61123 + struct name_entry *matchn;
61124 +
61125 + if (unlikely(!(gr_status & GR_READY)))
61126 + return;
61127 +
61128 + preempt_disable();
61129 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
61130 +
61131 + if (unlikely((unsigned long)matchn)) {
61132 + write_lock(&gr_inode_lock);
61133 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
61134 + write_unlock(&gr_inode_lock);
61135 + }
61136 + preempt_enable();
61137 +
61138 + return;
61139 +}
61140 +
61141 +void
61142 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
61143 + struct dentry *old_dentry,
61144 + struct dentry *new_dentry,
61145 + struct vfsmount *mnt, const __u8 replace)
61146 +{
61147 + struct name_entry *matchn;
61148 + struct inodev_entry *inodev;
61149 + struct inode *inode = new_dentry->d_inode;
61150 + ino_t old_ino = old_dentry->d_inode->i_ino;
61151 + dev_t old_dev = __get_dev(old_dentry);
61152 +
61153 + /* vfs_rename swaps the name and parent link for old_dentry and
61154 + new_dentry
61155 + at this point, old_dentry has the new name, parent link, and inode
61156 + for the renamed file
61157 + if a file is being replaced by a rename, new_dentry has the inode
61158 + and name for the replaced file
61159 + */
61160 +
61161 + if (unlikely(!(gr_status & GR_READY)))
61162 + return;
61163 +
61164 + preempt_disable();
61165 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
61166 +
61167 + /* we wouldn't have to check d_inode if it weren't for
61168 + NFS silly-renaming
61169 + */
61170 +
61171 + write_lock(&gr_inode_lock);
61172 + if (unlikely(replace && inode)) {
61173 + ino_t new_ino = inode->i_ino;
61174 + dev_t new_dev = __get_dev(new_dentry);
61175 +
61176 + inodev = lookup_inodev_entry(new_ino, new_dev);
61177 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
61178 + do_handle_delete(inodev, new_ino, new_dev);
61179 + }
61180 +
61181 + inodev = lookup_inodev_entry(old_ino, old_dev);
61182 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
61183 + do_handle_delete(inodev, old_ino, old_dev);
61184 +
61185 + if (unlikely((unsigned long)matchn))
61186 + do_handle_create(matchn, old_dentry, mnt);
61187 +
61188 + write_unlock(&gr_inode_lock);
61189 + preempt_enable();
61190 +
61191 + return;
61192 +}
61193 +
61194 +static int
61195 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
61196 + unsigned char **sum)
61197 +{
61198 + struct acl_role_label *r;
61199 + struct role_allowed_ip *ipp;
61200 + struct role_transition *trans;
61201 + unsigned int i;
61202 + int found = 0;
61203 + u32 curr_ip = current->signal->curr_ip;
61204 +
61205 + current->signal->saved_ip = curr_ip;
61206 +
61207 + /* check transition table */
61208 +
61209 + for (trans = current->role->transitions; trans; trans = trans->next) {
61210 + if (!strcmp(rolename, trans->rolename)) {
61211 + found = 1;
61212 + break;
61213 + }
61214 + }
61215 +
61216 + if (!found)
61217 + return 0;
61218 +
61219 + /* handle special roles that do not require authentication
61220 + and check ip */
61221 +
61222 + FOR_EACH_ROLE_START(r)
61223 + if (!strcmp(rolename, r->rolename) &&
61224 + (r->roletype & GR_ROLE_SPECIAL)) {
61225 + found = 0;
61226 + if (r->allowed_ips != NULL) {
61227 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
61228 + if ((ntohl(curr_ip) & ipp->netmask) ==
61229 + (ntohl(ipp->addr) & ipp->netmask))
61230 + found = 1;
61231 + }
61232 + } else
61233 + found = 2;
61234 + if (!found)
61235 + return 0;
61236 +
61237 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
61238 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
61239 + *salt = NULL;
61240 + *sum = NULL;
61241 + return 1;
61242 + }
61243 + }
61244 + FOR_EACH_ROLE_END(r)
61245 +
61246 + for (i = 0; i < num_sprole_pws; i++) {
61247 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
61248 + *salt = acl_special_roles[i]->salt;
61249 + *sum = acl_special_roles[i]->sum;
61250 + return 1;
61251 + }
61252 + }
61253 +
61254 + return 0;
61255 +}
61256 +
61257 +static void
61258 +assign_special_role(char *rolename)
61259 +{
61260 + struct acl_object_label *obj;
61261 + struct acl_role_label *r;
61262 + struct acl_role_label *assigned = NULL;
61263 + struct task_struct *tsk;
61264 + struct file *filp;
61265 +
61266 + FOR_EACH_ROLE_START(r)
61267 + if (!strcmp(rolename, r->rolename) &&
61268 + (r->roletype & GR_ROLE_SPECIAL)) {
61269 + assigned = r;
61270 + break;
61271 + }
61272 + FOR_EACH_ROLE_END(r)
61273 +
61274 + if (!assigned)
61275 + return;
61276 +
61277 + read_lock(&tasklist_lock);
61278 + read_lock(&grsec_exec_file_lock);
61279 +
61280 + tsk = current->real_parent;
61281 + if (tsk == NULL)
61282 + goto out_unlock;
61283 +
61284 + filp = tsk->exec_file;
61285 + if (filp == NULL)
61286 + goto out_unlock;
61287 +
61288 + tsk->is_writable = 0;
61289 +
61290 + tsk->acl_sp_role = 1;
61291 + tsk->acl_role_id = ++acl_sp_role_value;
61292 + tsk->role = assigned;
61293 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
61294 +
61295 + /* ignore additional mmap checks for processes that are writable
61296 + by the default ACL */
61297 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61298 + if (unlikely(obj->mode & GR_WRITE))
61299 + tsk->is_writable = 1;
61300 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
61301 + if (unlikely(obj->mode & GR_WRITE))
61302 + tsk->is_writable = 1;
61303 +
61304 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61305 + 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));
61306 +#endif
61307 +
61308 +out_unlock:
61309 + read_unlock(&grsec_exec_file_lock);
61310 + read_unlock(&tasklist_lock);
61311 + return;
61312 +}
61313 +
61314 +int gr_check_secure_terminal(struct task_struct *task)
61315 +{
61316 + struct task_struct *p, *p2, *p3;
61317 + struct files_struct *files;
61318 + struct fdtable *fdt;
61319 + struct file *our_file = NULL, *file;
61320 + int i;
61321 +
61322 + if (task->signal->tty == NULL)
61323 + return 1;
61324 +
61325 + files = get_files_struct(task);
61326 + if (files != NULL) {
61327 + rcu_read_lock();
61328 + fdt = files_fdtable(files);
61329 + for (i=0; i < fdt->max_fds; i++) {
61330 + file = fcheck_files(files, i);
61331 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
61332 + get_file(file);
61333 + our_file = file;
61334 + }
61335 + }
61336 + rcu_read_unlock();
61337 + put_files_struct(files);
61338 + }
61339 +
61340 + if (our_file == NULL)
61341 + return 1;
61342 +
61343 + read_lock(&tasklist_lock);
61344 + do_each_thread(p2, p) {
61345 + files = get_files_struct(p);
61346 + if (files == NULL ||
61347 + (p->signal && p->signal->tty == task->signal->tty)) {
61348 + if (files != NULL)
61349 + put_files_struct(files);
61350 + continue;
61351 + }
61352 + rcu_read_lock();
61353 + fdt = files_fdtable(files);
61354 + for (i=0; i < fdt->max_fds; i++) {
61355 + file = fcheck_files(files, i);
61356 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
61357 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
61358 + p3 = task;
61359 + while (task_pid_nr(p3) > 0) {
61360 + if (p3 == p)
61361 + break;
61362 + p3 = p3->real_parent;
61363 + }
61364 + if (p3 == p)
61365 + break;
61366 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
61367 + gr_handle_alertkill(p);
61368 + rcu_read_unlock();
61369 + put_files_struct(files);
61370 + read_unlock(&tasklist_lock);
61371 + fput(our_file);
61372 + return 0;
61373 + }
61374 + }
61375 + rcu_read_unlock();
61376 + put_files_struct(files);
61377 + } while_each_thread(p2, p);
61378 + read_unlock(&tasklist_lock);
61379 +
61380 + fput(our_file);
61381 + return 1;
61382 +}
61383 +
61384 +static int gr_rbac_disable(void *unused)
61385 +{
61386 + pax_open_kernel();
61387 + gr_status &= ~GR_READY;
61388 + pax_close_kernel();
61389 +
61390 + return 0;
61391 +}
61392 +
61393 +ssize_t
61394 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
61395 +{
61396 + struct gr_arg_wrapper uwrap;
61397 + unsigned char *sprole_salt = NULL;
61398 + unsigned char *sprole_sum = NULL;
61399 + int error = sizeof (struct gr_arg_wrapper);
61400 + int error2 = 0;
61401 +
61402 + mutex_lock(&gr_dev_mutex);
61403 +
61404 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
61405 + error = -EPERM;
61406 + goto out;
61407 + }
61408 +
61409 + if (count != sizeof (struct gr_arg_wrapper)) {
61410 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
61411 + error = -EINVAL;
61412 + goto out;
61413 + }
61414 +
61415 +
61416 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
61417 + gr_auth_expires = 0;
61418 + gr_auth_attempts = 0;
61419 + }
61420 +
61421 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
61422 + error = -EFAULT;
61423 + goto out;
61424 + }
61425 +
61426 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
61427 + error = -EINVAL;
61428 + goto out;
61429 + }
61430 +
61431 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
61432 + error = -EFAULT;
61433 + goto out;
61434 + }
61435 +
61436 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61437 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61438 + time_after(gr_auth_expires, get_seconds())) {
61439 + error = -EBUSY;
61440 + goto out;
61441 + }
61442 +
61443 + /* if non-root trying to do anything other than use a special role,
61444 + do not attempt authentication, do not count towards authentication
61445 + locking
61446 + */
61447 +
61448 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
61449 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61450 + gr_is_global_nonroot(current_uid())) {
61451 + error = -EPERM;
61452 + goto out;
61453 + }
61454 +
61455 + /* ensure pw and special role name are null terminated */
61456 +
61457 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
61458 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
61459 +
61460 + /* Okay.
61461 + * We have our enough of the argument structure..(we have yet
61462 + * to copy_from_user the tables themselves) . Copy the tables
61463 + * only if we need them, i.e. for loading operations. */
61464 +
61465 + switch (gr_usermode->mode) {
61466 + case GR_STATUS:
61467 + if (gr_status & GR_READY) {
61468 + error = 1;
61469 + if (!gr_check_secure_terminal(current))
61470 + error = 3;
61471 + } else
61472 + error = 2;
61473 + goto out;
61474 + case GR_SHUTDOWN:
61475 + if ((gr_status & GR_READY)
61476 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61477 + stop_machine(gr_rbac_disable, NULL, NULL);
61478 + free_variables();
61479 + memset(gr_usermode, 0, sizeof (struct gr_arg));
61480 + memset(gr_system_salt, 0, GR_SALT_LEN);
61481 + memset(gr_system_sum, 0, GR_SHA_LEN);
61482 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
61483 + } else if (gr_status & GR_READY) {
61484 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
61485 + error = -EPERM;
61486 + } else {
61487 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
61488 + error = -EAGAIN;
61489 + }
61490 + break;
61491 + case GR_ENABLE:
61492 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
61493 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
61494 + else {
61495 + if (gr_status & GR_READY)
61496 + error = -EAGAIN;
61497 + else
61498 + error = error2;
61499 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
61500 + }
61501 + break;
61502 + case GR_RELOAD:
61503 + if (!(gr_status & GR_READY)) {
61504 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
61505 + error = -EAGAIN;
61506 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61507 + stop_machine(gr_rbac_disable, NULL, NULL);
61508 + free_variables();
61509 + error2 = gracl_init(gr_usermode);
61510 + if (!error2)
61511 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
61512 + else {
61513 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61514 + error = error2;
61515 + }
61516 + } else {
61517 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61518 + error = -EPERM;
61519 + }
61520 + break;
61521 + case GR_SEGVMOD:
61522 + if (unlikely(!(gr_status & GR_READY))) {
61523 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
61524 + error = -EAGAIN;
61525 + break;
61526 + }
61527 +
61528 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61529 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
61530 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
61531 + struct acl_subject_label *segvacl;
61532 + segvacl =
61533 + lookup_acl_subj_label(gr_usermode->segv_inode,
61534 + gr_usermode->segv_device,
61535 + current->role);
61536 + if (segvacl) {
61537 + segvacl->crashes = 0;
61538 + segvacl->expires = 0;
61539 + }
61540 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
61541 + gr_remove_uid(gr_usermode->segv_uid);
61542 + }
61543 + } else {
61544 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
61545 + error = -EPERM;
61546 + }
61547 + break;
61548 + case GR_SPROLE:
61549 + case GR_SPROLEPAM:
61550 + if (unlikely(!(gr_status & GR_READY))) {
61551 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
61552 + error = -EAGAIN;
61553 + break;
61554 + }
61555 +
61556 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
61557 + current->role->expires = 0;
61558 + current->role->auth_attempts = 0;
61559 + }
61560 +
61561 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61562 + time_after(current->role->expires, get_seconds())) {
61563 + error = -EBUSY;
61564 + goto out;
61565 + }
61566 +
61567 + if (lookup_special_role_auth
61568 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
61569 + && ((!sprole_salt && !sprole_sum)
61570 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
61571 + char *p = "";
61572 + assign_special_role(gr_usermode->sp_role);
61573 + read_lock(&tasklist_lock);
61574 + if (current->real_parent)
61575 + p = current->real_parent->role->rolename;
61576 + read_unlock(&tasklist_lock);
61577 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
61578 + p, acl_sp_role_value);
61579 + } else {
61580 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
61581 + error = -EPERM;
61582 + if(!(current->role->auth_attempts++))
61583 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61584 +
61585 + goto out;
61586 + }
61587 + break;
61588 + case GR_UNSPROLE:
61589 + if (unlikely(!(gr_status & GR_READY))) {
61590 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
61591 + error = -EAGAIN;
61592 + break;
61593 + }
61594 +
61595 + if (current->role->roletype & GR_ROLE_SPECIAL) {
61596 + char *p = "";
61597 + int i = 0;
61598 +
61599 + read_lock(&tasklist_lock);
61600 + if (current->real_parent) {
61601 + p = current->real_parent->role->rolename;
61602 + i = current->real_parent->acl_role_id;
61603 + }
61604 + read_unlock(&tasklist_lock);
61605 +
61606 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
61607 + gr_set_acls(1);
61608 + } else {
61609 + error = -EPERM;
61610 + goto out;
61611 + }
61612 + break;
61613 + default:
61614 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
61615 + error = -EINVAL;
61616 + break;
61617 + }
61618 +
61619 + if (error != -EPERM)
61620 + goto out;
61621 +
61622 + if(!(gr_auth_attempts++))
61623 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61624 +
61625 + out:
61626 + mutex_unlock(&gr_dev_mutex);
61627 + return error;
61628 +}
61629 +
61630 +/* must be called with
61631 + rcu_read_lock();
61632 + read_lock(&tasklist_lock);
61633 + read_lock(&grsec_exec_file_lock);
61634 +*/
61635 +int gr_apply_subject_to_task(struct task_struct *task)
61636 +{
61637 + struct acl_object_label *obj;
61638 + char *tmpname;
61639 + struct acl_subject_label *tmpsubj;
61640 + struct file *filp;
61641 + struct name_entry *nmatch;
61642 +
61643 + filp = task->exec_file;
61644 + if (filp == NULL)
61645 + return 0;
61646 +
61647 + /* the following is to apply the correct subject
61648 + on binaries running when the RBAC system
61649 + is enabled, when the binaries have been
61650 + replaced or deleted since their execution
61651 + -----
61652 + when the RBAC system starts, the inode/dev
61653 + from exec_file will be one the RBAC system
61654 + is unaware of. It only knows the inode/dev
61655 + of the present file on disk, or the absence
61656 + of it.
61657 + */
61658 + preempt_disable();
61659 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
61660 +
61661 + nmatch = lookup_name_entry(tmpname);
61662 + preempt_enable();
61663 + tmpsubj = NULL;
61664 + if (nmatch) {
61665 + if (nmatch->deleted)
61666 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
61667 + else
61668 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
61669 + if (tmpsubj != NULL)
61670 + task->acl = tmpsubj;
61671 + }
61672 + if (tmpsubj == NULL)
61673 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
61674 + task->role);
61675 + if (task->acl) {
61676 + task->is_writable = 0;
61677 + /* ignore additional mmap checks for processes that are writable
61678 + by the default ACL */
61679 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61680 + if (unlikely(obj->mode & GR_WRITE))
61681 + task->is_writable = 1;
61682 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
61683 + if (unlikely(obj->mode & GR_WRITE))
61684 + task->is_writable = 1;
61685 +
61686 + gr_set_proc_res(task);
61687 +
61688 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61689 + 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);
61690 +#endif
61691 + } else {
61692 + return 1;
61693 + }
61694 +
61695 + return 0;
61696 +}
61697 +
61698 +int
61699 +gr_set_acls(const int type)
61700 +{
61701 + struct task_struct *task, *task2;
61702 + struct acl_role_label *role = current->role;
61703 + __u16 acl_role_id = current->acl_role_id;
61704 + const struct cred *cred;
61705 + int ret;
61706 +
61707 + rcu_read_lock();
61708 + read_lock(&tasklist_lock);
61709 + read_lock(&grsec_exec_file_lock);
61710 + do_each_thread(task2, task) {
61711 + /* check to see if we're called from the exit handler,
61712 + if so, only replace ACLs that have inherited the admin
61713 + ACL */
61714 +
61715 + if (type && (task->role != role ||
61716 + task->acl_role_id != acl_role_id))
61717 + continue;
61718 +
61719 + task->acl_role_id = 0;
61720 + task->acl_sp_role = 0;
61721 +
61722 + if (task->exec_file) {
61723 + cred = __task_cred(task);
61724 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
61725 + ret = gr_apply_subject_to_task(task);
61726 + if (ret) {
61727 + read_unlock(&grsec_exec_file_lock);
61728 + read_unlock(&tasklist_lock);
61729 + rcu_read_unlock();
61730 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
61731 + return ret;
61732 + }
61733 + } else {
61734 + // it's a kernel process
61735 + task->role = kernel_role;
61736 + task->acl = kernel_role->root_label;
61737 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
61738 + task->acl->mode &= ~GR_PROCFIND;
61739 +#endif
61740 + }
61741 + } while_each_thread(task2, task);
61742 + read_unlock(&grsec_exec_file_lock);
61743 + read_unlock(&tasklist_lock);
61744 + rcu_read_unlock();
61745 +
61746 + return 0;
61747 +}
61748 +
61749 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
61750 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
61751 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
61752 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
61753 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
61754 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
61755 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
61756 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
61757 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
61758 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
61759 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
61760 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
61761 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
61762 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
61763 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
61764 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
61765 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
61766 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
61767 +};
61768 +
61769 +void
61770 +gr_learn_resource(const struct task_struct *task,
61771 + const int res, const unsigned long wanted, const int gt)
61772 +{
61773 + struct acl_subject_label *acl;
61774 + const struct cred *cred;
61775 +
61776 + if (unlikely((gr_status & GR_READY) &&
61777 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
61778 + goto skip_reslog;
61779 +
61780 + gr_log_resource(task, res, wanted, gt);
61781 +skip_reslog:
61782 +
61783 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
61784 + return;
61785 +
61786 + acl = task->acl;
61787 +
61788 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
61789 + !(acl->resmask & (1U << (unsigned short) res))))
61790 + return;
61791 +
61792 + if (wanted >= acl->res[res].rlim_cur) {
61793 + unsigned long res_add;
61794 +
61795 + res_add = wanted + res_learn_bumps[res];
61796 +
61797 + acl->res[res].rlim_cur = res_add;
61798 +
61799 + if (wanted > acl->res[res].rlim_max)
61800 + acl->res[res].rlim_max = res_add;
61801 +
61802 + /* only log the subject filename, since resource logging is supported for
61803 + single-subject learning only */
61804 + rcu_read_lock();
61805 + cred = __task_cred(task);
61806 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61807 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
61808 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
61809 + "", (unsigned long) res, &task->signal->saved_ip);
61810 + rcu_read_unlock();
61811 + }
61812 +
61813 + return;
61814 +}
61815 +EXPORT_SYMBOL(gr_learn_resource);
61816 +#endif
61817 +
61818 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
61819 +void
61820 +pax_set_initial_flags(struct linux_binprm *bprm)
61821 +{
61822 + struct task_struct *task = current;
61823 + struct acl_subject_label *proc;
61824 + unsigned long flags;
61825 +
61826 + if (unlikely(!(gr_status & GR_READY)))
61827 + return;
61828 +
61829 + flags = pax_get_flags(task);
61830 +
61831 + proc = task->acl;
61832 +
61833 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
61834 + flags &= ~MF_PAX_PAGEEXEC;
61835 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
61836 + flags &= ~MF_PAX_SEGMEXEC;
61837 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
61838 + flags &= ~MF_PAX_RANDMMAP;
61839 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
61840 + flags &= ~MF_PAX_EMUTRAMP;
61841 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
61842 + flags &= ~MF_PAX_MPROTECT;
61843 +
61844 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
61845 + flags |= MF_PAX_PAGEEXEC;
61846 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
61847 + flags |= MF_PAX_SEGMEXEC;
61848 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
61849 + flags |= MF_PAX_RANDMMAP;
61850 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
61851 + flags |= MF_PAX_EMUTRAMP;
61852 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
61853 + flags |= MF_PAX_MPROTECT;
61854 +
61855 + pax_set_flags(task, flags);
61856 +
61857 + return;
61858 +}
61859 +#endif
61860 +
61861 +int
61862 +gr_handle_proc_ptrace(struct task_struct *task)
61863 +{
61864 + struct file *filp;
61865 + struct task_struct *tmp = task;
61866 + struct task_struct *curtemp = current;
61867 + __u32 retmode;
61868 +
61869 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61870 + if (unlikely(!(gr_status & GR_READY)))
61871 + return 0;
61872 +#endif
61873 +
61874 + read_lock(&tasklist_lock);
61875 + read_lock(&grsec_exec_file_lock);
61876 + filp = task->exec_file;
61877 +
61878 + while (task_pid_nr(tmp) > 0) {
61879 + if (tmp == curtemp)
61880 + break;
61881 + tmp = tmp->real_parent;
61882 + }
61883 +
61884 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61885 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
61886 + read_unlock(&grsec_exec_file_lock);
61887 + read_unlock(&tasklist_lock);
61888 + return 1;
61889 + }
61890 +
61891 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61892 + if (!(gr_status & GR_READY)) {
61893 + read_unlock(&grsec_exec_file_lock);
61894 + read_unlock(&tasklist_lock);
61895 + return 0;
61896 + }
61897 +#endif
61898 +
61899 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
61900 + read_unlock(&grsec_exec_file_lock);
61901 + read_unlock(&tasklist_lock);
61902 +
61903 + if (retmode & GR_NOPTRACE)
61904 + return 1;
61905 +
61906 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
61907 + && (current->acl != task->acl || (current->acl != current->role->root_label
61908 + && task_pid_nr(current) != task_pid_nr(task))))
61909 + return 1;
61910 +
61911 + return 0;
61912 +}
61913 +
61914 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
61915 +{
61916 + if (unlikely(!(gr_status & GR_READY)))
61917 + return;
61918 +
61919 + if (!(current->role->roletype & GR_ROLE_GOD))
61920 + return;
61921 +
61922 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
61923 + p->role->rolename, gr_task_roletype_to_char(p),
61924 + p->acl->filename);
61925 +}
61926 +
61927 +int
61928 +gr_handle_ptrace(struct task_struct *task, const long request)
61929 +{
61930 + struct task_struct *tmp = task;
61931 + struct task_struct *curtemp = current;
61932 + __u32 retmode;
61933 +
61934 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61935 + if (unlikely(!(gr_status & GR_READY)))
61936 + return 0;
61937 +#endif
61938 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
61939 + read_lock(&tasklist_lock);
61940 + while (task_pid_nr(tmp) > 0) {
61941 + if (tmp == curtemp)
61942 + break;
61943 + tmp = tmp->real_parent;
61944 + }
61945 +
61946 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61947 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
61948 + read_unlock(&tasklist_lock);
61949 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61950 + return 1;
61951 + }
61952 + read_unlock(&tasklist_lock);
61953 + }
61954 +
61955 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61956 + if (!(gr_status & GR_READY))
61957 + return 0;
61958 +#endif
61959 +
61960 + read_lock(&grsec_exec_file_lock);
61961 + if (unlikely(!task->exec_file)) {
61962 + read_unlock(&grsec_exec_file_lock);
61963 + return 0;
61964 + }
61965 +
61966 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
61967 + read_unlock(&grsec_exec_file_lock);
61968 +
61969 + if (retmode & GR_NOPTRACE) {
61970 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61971 + return 1;
61972 + }
61973 +
61974 + if (retmode & GR_PTRACERD) {
61975 + switch (request) {
61976 + case PTRACE_SEIZE:
61977 + case PTRACE_POKETEXT:
61978 + case PTRACE_POKEDATA:
61979 + case PTRACE_POKEUSR:
61980 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
61981 + case PTRACE_SETREGS:
61982 + case PTRACE_SETFPREGS:
61983 +#endif
61984 +#ifdef CONFIG_X86
61985 + case PTRACE_SETFPXREGS:
61986 +#endif
61987 +#ifdef CONFIG_ALTIVEC
61988 + case PTRACE_SETVRREGS:
61989 +#endif
61990 + return 1;
61991 + default:
61992 + return 0;
61993 + }
61994 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
61995 + !(current->role->roletype & GR_ROLE_GOD) &&
61996 + (current->acl != task->acl)) {
61997 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61998 + return 1;
61999 + }
62000 +
62001 + return 0;
62002 +}
62003 +
62004 +static int is_writable_mmap(const struct file *filp)
62005 +{
62006 + struct task_struct *task = current;
62007 + struct acl_object_label *obj, *obj2;
62008 +
62009 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
62010 + !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))) {
62011 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
62012 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
62013 + task->role->root_label);
62014 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
62015 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
62016 + return 1;
62017 + }
62018 + }
62019 + return 0;
62020 +}
62021 +
62022 +int
62023 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
62024 +{
62025 + __u32 mode;
62026 +
62027 + if (unlikely(!file || !(prot & PROT_EXEC)))
62028 + return 1;
62029 +
62030 + if (is_writable_mmap(file))
62031 + return 0;
62032 +
62033 + mode =
62034 + gr_search_file(file->f_path.dentry,
62035 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
62036 + file->f_path.mnt);
62037 +
62038 + if (!gr_tpe_allow(file))
62039 + return 0;
62040 +
62041 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
62042 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62043 + return 0;
62044 + } else if (unlikely(!(mode & GR_EXEC))) {
62045 + return 0;
62046 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
62047 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62048 + return 1;
62049 + }
62050 +
62051 + return 1;
62052 +}
62053 +
62054 +int
62055 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
62056 +{
62057 + __u32 mode;
62058 +
62059 + if (unlikely(!file || !(prot & PROT_EXEC)))
62060 + return 1;
62061 +
62062 + if (is_writable_mmap(file))
62063 + return 0;
62064 +
62065 + mode =
62066 + gr_search_file(file->f_path.dentry,
62067 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
62068 + file->f_path.mnt);
62069 +
62070 + if (!gr_tpe_allow(file))
62071 + return 0;
62072 +
62073 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
62074 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62075 + return 0;
62076 + } else if (unlikely(!(mode & GR_EXEC))) {
62077 + return 0;
62078 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
62079 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62080 + return 1;
62081 + }
62082 +
62083 + return 1;
62084 +}
62085 +
62086 +void
62087 +gr_acl_handle_psacct(struct task_struct *task, const long code)
62088 +{
62089 + unsigned long runtime;
62090 + unsigned long cputime;
62091 + unsigned int wday, cday;
62092 + __u8 whr, chr;
62093 + __u8 wmin, cmin;
62094 + __u8 wsec, csec;
62095 + struct timespec timeval;
62096 +
62097 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
62098 + !(task->acl->mode & GR_PROCACCT)))
62099 + return;
62100 +
62101 + do_posix_clock_monotonic_gettime(&timeval);
62102 + runtime = timeval.tv_sec - task->start_time.tv_sec;
62103 + wday = runtime / (3600 * 24);
62104 + runtime -= wday * (3600 * 24);
62105 + whr = runtime / 3600;
62106 + runtime -= whr * 3600;
62107 + wmin = runtime / 60;
62108 + runtime -= wmin * 60;
62109 + wsec = runtime;
62110 +
62111 + cputime = (task->utime + task->stime) / HZ;
62112 + cday = cputime / (3600 * 24);
62113 + cputime -= cday * (3600 * 24);
62114 + chr = cputime / 3600;
62115 + cputime -= chr * 3600;
62116 + cmin = cputime / 60;
62117 + cputime -= cmin * 60;
62118 + csec = cputime;
62119 +
62120 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
62121 +
62122 + return;
62123 +}
62124 +
62125 +void gr_set_kernel_label(struct task_struct *task)
62126 +{
62127 + if (gr_status & GR_READY) {
62128 + task->role = kernel_role;
62129 + task->acl = kernel_role->root_label;
62130 + }
62131 + return;
62132 +}
62133 +
62134 +#ifdef CONFIG_TASKSTATS
62135 +int gr_is_taskstats_denied(int pid)
62136 +{
62137 + struct task_struct *task;
62138 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62139 + const struct cred *cred;
62140 +#endif
62141 + int ret = 0;
62142 +
62143 + /* restrict taskstats viewing to un-chrooted root users
62144 + who have the 'view' subject flag if the RBAC system is enabled
62145 + */
62146 +
62147 + rcu_read_lock();
62148 + read_lock(&tasklist_lock);
62149 + task = find_task_by_vpid(pid);
62150 + if (task) {
62151 +#ifdef CONFIG_GRKERNSEC_CHROOT
62152 + if (proc_is_chrooted(task))
62153 + ret = -EACCES;
62154 +#endif
62155 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62156 + cred = __task_cred(task);
62157 +#ifdef CONFIG_GRKERNSEC_PROC_USER
62158 + if (gr_is_global_nonroot(cred->uid))
62159 + ret = -EACCES;
62160 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62161 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
62162 + ret = -EACCES;
62163 +#endif
62164 +#endif
62165 + if (gr_status & GR_READY) {
62166 + if (!(task->acl->mode & GR_VIEW))
62167 + ret = -EACCES;
62168 + }
62169 + } else
62170 + ret = -ENOENT;
62171 +
62172 + read_unlock(&tasklist_lock);
62173 + rcu_read_unlock();
62174 +
62175 + return ret;
62176 +}
62177 +#endif
62178 +
62179 +/* AUXV entries are filled via a descendant of search_binary_handler
62180 + after we've already applied the subject for the target
62181 +*/
62182 +int gr_acl_enable_at_secure(void)
62183 +{
62184 + if (unlikely(!(gr_status & GR_READY)))
62185 + return 0;
62186 +
62187 + if (current->acl->mode & GR_ATSECURE)
62188 + return 1;
62189 +
62190 + return 0;
62191 +}
62192 +
62193 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
62194 +{
62195 + struct task_struct *task = current;
62196 + struct dentry *dentry = file->f_path.dentry;
62197 + struct vfsmount *mnt = file->f_path.mnt;
62198 + struct acl_object_label *obj, *tmp;
62199 + struct acl_subject_label *subj;
62200 + unsigned int bufsize;
62201 + int is_not_root;
62202 + char *path;
62203 + dev_t dev = __get_dev(dentry);
62204 +
62205 + if (unlikely(!(gr_status & GR_READY)))
62206 + return 1;
62207 +
62208 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
62209 + return 1;
62210 +
62211 + /* ignore Eric Biederman */
62212 + if (IS_PRIVATE(dentry->d_inode))
62213 + return 1;
62214 +
62215 + subj = task->acl;
62216 + read_lock(&gr_inode_lock);
62217 + do {
62218 + obj = lookup_acl_obj_label(ino, dev, subj);
62219 + if (obj != NULL) {
62220 + read_unlock(&gr_inode_lock);
62221 + return (obj->mode & GR_FIND) ? 1 : 0;
62222 + }
62223 + } while ((subj = subj->parent_subject));
62224 + read_unlock(&gr_inode_lock);
62225 +
62226 + /* this is purely an optimization since we're looking for an object
62227 + for the directory we're doing a readdir on
62228 + if it's possible for any globbed object to match the entry we're
62229 + filling into the directory, then the object we find here will be
62230 + an anchor point with attached globbed objects
62231 + */
62232 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
62233 + if (obj->globbed == NULL)
62234 + return (obj->mode & GR_FIND) ? 1 : 0;
62235 +
62236 + is_not_root = ((obj->filename[0] == '/') &&
62237 + (obj->filename[1] == '\0')) ? 0 : 1;
62238 + bufsize = PAGE_SIZE - namelen - is_not_root;
62239 +
62240 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
62241 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
62242 + return 1;
62243 +
62244 + preempt_disable();
62245 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62246 + bufsize);
62247 +
62248 + bufsize = strlen(path);
62249 +
62250 + /* if base is "/", don't append an additional slash */
62251 + if (is_not_root)
62252 + *(path + bufsize) = '/';
62253 + memcpy(path + bufsize + is_not_root, name, namelen);
62254 + *(path + bufsize + namelen + is_not_root) = '\0';
62255 +
62256 + tmp = obj->globbed;
62257 + while (tmp) {
62258 + if (!glob_match(tmp->filename, path)) {
62259 + preempt_enable();
62260 + return (tmp->mode & GR_FIND) ? 1 : 0;
62261 + }
62262 + tmp = tmp->next;
62263 + }
62264 + preempt_enable();
62265 + return (obj->mode & GR_FIND) ? 1 : 0;
62266 +}
62267 +
62268 +void gr_put_exec_file(struct task_struct *task)
62269 +{
62270 + struct file *filp;
62271 +
62272 + write_lock(&grsec_exec_file_lock);
62273 + filp = task->exec_file;
62274 + task->exec_file = NULL;
62275 + write_unlock(&grsec_exec_file_lock);
62276 +
62277 + if (filp)
62278 + fput(filp);
62279 +
62280 + return;
62281 +}
62282 +
62283 +
62284 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
62285 +EXPORT_SYMBOL(gr_acl_is_enabled);
62286 +#endif
62287 +EXPORT_SYMBOL(gr_set_kernel_label);
62288 +#ifdef CONFIG_SECURITY
62289 +EXPORT_SYMBOL(gr_check_user_change);
62290 +EXPORT_SYMBOL(gr_check_group_change);
62291 +#endif
62292 +
62293 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
62294 new file mode 100644
62295 index 0000000..34fefda
62296 --- /dev/null
62297 +++ b/grsecurity/gracl_alloc.c
62298 @@ -0,0 +1,105 @@
62299 +#include <linux/kernel.h>
62300 +#include <linux/mm.h>
62301 +#include <linux/slab.h>
62302 +#include <linux/vmalloc.h>
62303 +#include <linux/gracl.h>
62304 +#include <linux/grsecurity.h>
62305 +
62306 +static unsigned long alloc_stack_next = 1;
62307 +static unsigned long alloc_stack_size = 1;
62308 +static void **alloc_stack;
62309 +
62310 +static __inline__ int
62311 +alloc_pop(void)
62312 +{
62313 + if (alloc_stack_next == 1)
62314 + return 0;
62315 +
62316 + kfree(alloc_stack[alloc_stack_next - 2]);
62317 +
62318 + alloc_stack_next--;
62319 +
62320 + return 1;
62321 +}
62322 +
62323 +static __inline__ int
62324 +alloc_push(void *buf)
62325 +{
62326 + if (alloc_stack_next >= alloc_stack_size)
62327 + return 1;
62328 +
62329 + alloc_stack[alloc_stack_next - 1] = buf;
62330 +
62331 + alloc_stack_next++;
62332 +
62333 + return 0;
62334 +}
62335 +
62336 +void *
62337 +acl_alloc(unsigned long len)
62338 +{
62339 + void *ret = NULL;
62340 +
62341 + if (!len || len > PAGE_SIZE)
62342 + goto out;
62343 +
62344 + ret = kmalloc(len, GFP_KERNEL);
62345 +
62346 + if (ret) {
62347 + if (alloc_push(ret)) {
62348 + kfree(ret);
62349 + ret = NULL;
62350 + }
62351 + }
62352 +
62353 +out:
62354 + return ret;
62355 +}
62356 +
62357 +void *
62358 +acl_alloc_num(unsigned long num, unsigned long len)
62359 +{
62360 + if (!len || (num > (PAGE_SIZE / len)))
62361 + return NULL;
62362 +
62363 + return acl_alloc(num * len);
62364 +}
62365 +
62366 +void
62367 +acl_free_all(void)
62368 +{
62369 + if (gr_acl_is_enabled() || !alloc_stack)
62370 + return;
62371 +
62372 + while (alloc_pop()) ;
62373 +
62374 + if (alloc_stack) {
62375 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
62376 + kfree(alloc_stack);
62377 + else
62378 + vfree(alloc_stack);
62379 + }
62380 +
62381 + alloc_stack = NULL;
62382 + alloc_stack_size = 1;
62383 + alloc_stack_next = 1;
62384 +
62385 + return;
62386 +}
62387 +
62388 +int
62389 +acl_alloc_stack_init(unsigned long size)
62390 +{
62391 + if ((size * sizeof (void *)) <= PAGE_SIZE)
62392 + alloc_stack =
62393 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
62394 + else
62395 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
62396 +
62397 + alloc_stack_size = size;
62398 +
62399 + if (!alloc_stack)
62400 + return 0;
62401 + else
62402 + return 1;
62403 +}
62404 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
62405 new file mode 100644
62406 index 0000000..bdd51ea
62407 --- /dev/null
62408 +++ b/grsecurity/gracl_cap.c
62409 @@ -0,0 +1,110 @@
62410 +#include <linux/kernel.h>
62411 +#include <linux/module.h>
62412 +#include <linux/sched.h>
62413 +#include <linux/gracl.h>
62414 +#include <linux/grsecurity.h>
62415 +#include <linux/grinternal.h>
62416 +
62417 +extern const char *captab_log[];
62418 +extern int captab_log_entries;
62419 +
62420 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
62421 +{
62422 + struct acl_subject_label *curracl;
62423 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62424 + kernel_cap_t cap_audit = __cap_empty_set;
62425 +
62426 + if (!gr_acl_is_enabled())
62427 + return 1;
62428 +
62429 + curracl = task->acl;
62430 +
62431 + cap_drop = curracl->cap_lower;
62432 + cap_mask = curracl->cap_mask;
62433 + cap_audit = curracl->cap_invert_audit;
62434 +
62435 + while ((curracl = curracl->parent_subject)) {
62436 + /* if the cap isn't specified in the current computed mask but is specified in the
62437 + current level subject, and is lowered in the current level subject, then add
62438 + it to the set of dropped capabilities
62439 + otherwise, add the current level subject's mask to the current computed mask
62440 + */
62441 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62442 + cap_raise(cap_mask, cap);
62443 + if (cap_raised(curracl->cap_lower, cap))
62444 + cap_raise(cap_drop, cap);
62445 + if (cap_raised(curracl->cap_invert_audit, cap))
62446 + cap_raise(cap_audit, cap);
62447 + }
62448 + }
62449 +
62450 + if (!cap_raised(cap_drop, cap)) {
62451 + if (cap_raised(cap_audit, cap))
62452 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
62453 + return 1;
62454 + }
62455 +
62456 + curracl = task->acl;
62457 +
62458 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
62459 + && cap_raised(cred->cap_effective, cap)) {
62460 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
62461 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
62462 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
62463 + gr_to_filename(task->exec_file->f_path.dentry,
62464 + task->exec_file->f_path.mnt) : curracl->filename,
62465 + curracl->filename, 0UL,
62466 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
62467 + return 1;
62468 + }
62469 +
62470 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
62471 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
62472 +
62473 + return 0;
62474 +}
62475 +
62476 +int
62477 +gr_acl_is_capable(const int cap)
62478 +{
62479 + return gr_task_acl_is_capable(current, current_cred(), cap);
62480 +}
62481 +
62482 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
62483 +{
62484 + struct acl_subject_label *curracl;
62485 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62486 +
62487 + if (!gr_acl_is_enabled())
62488 + return 1;
62489 +
62490 + curracl = task->acl;
62491 +
62492 + cap_drop = curracl->cap_lower;
62493 + cap_mask = curracl->cap_mask;
62494 +
62495 + while ((curracl = curracl->parent_subject)) {
62496 + /* if the cap isn't specified in the current computed mask but is specified in the
62497 + current level subject, and is lowered in the current level subject, then add
62498 + it to the set of dropped capabilities
62499 + otherwise, add the current level subject's mask to the current computed mask
62500 + */
62501 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62502 + cap_raise(cap_mask, cap);
62503 + if (cap_raised(curracl->cap_lower, cap))
62504 + cap_raise(cap_drop, cap);
62505 + }
62506 + }
62507 +
62508 + if (!cap_raised(cap_drop, cap))
62509 + return 1;
62510 +
62511 + return 0;
62512 +}
62513 +
62514 +int
62515 +gr_acl_is_capable_nolog(const int cap)
62516 +{
62517 + return gr_task_acl_is_capable_nolog(current, cap);
62518 +}
62519 +
62520 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
62521 new file mode 100644
62522 index 0000000..a340c17
62523 --- /dev/null
62524 +++ b/grsecurity/gracl_fs.c
62525 @@ -0,0 +1,431 @@
62526 +#include <linux/kernel.h>
62527 +#include <linux/sched.h>
62528 +#include <linux/types.h>
62529 +#include <linux/fs.h>
62530 +#include <linux/file.h>
62531 +#include <linux/stat.h>
62532 +#include <linux/grsecurity.h>
62533 +#include <linux/grinternal.h>
62534 +#include <linux/gracl.h>
62535 +
62536 +umode_t
62537 +gr_acl_umask(void)
62538 +{
62539 + if (unlikely(!gr_acl_is_enabled()))
62540 + return 0;
62541 +
62542 + return current->role->umask;
62543 +}
62544 +
62545 +__u32
62546 +gr_acl_handle_hidden_file(const struct dentry * dentry,
62547 + const struct vfsmount * mnt)
62548 +{
62549 + __u32 mode;
62550 +
62551 + if (unlikely(!dentry->d_inode))
62552 + return GR_FIND;
62553 +
62554 + mode =
62555 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
62556 +
62557 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
62558 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62559 + return mode;
62560 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
62561 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62562 + return 0;
62563 + } else if (unlikely(!(mode & GR_FIND)))
62564 + return 0;
62565 +
62566 + return GR_FIND;
62567 +}
62568 +
62569 +__u32
62570 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
62571 + int acc_mode)
62572 +{
62573 + __u32 reqmode = GR_FIND;
62574 + __u32 mode;
62575 +
62576 + if (unlikely(!dentry->d_inode))
62577 + return reqmode;
62578 +
62579 + if (acc_mode & MAY_APPEND)
62580 + reqmode |= GR_APPEND;
62581 + else if (acc_mode & MAY_WRITE)
62582 + reqmode |= GR_WRITE;
62583 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
62584 + reqmode |= GR_READ;
62585 +
62586 + mode =
62587 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62588 + mnt);
62589 +
62590 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62591 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62592 + reqmode & GR_READ ? " reading" : "",
62593 + reqmode & GR_WRITE ? " writing" : reqmode &
62594 + GR_APPEND ? " appending" : "");
62595 + return reqmode;
62596 + } else
62597 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62598 + {
62599 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62600 + reqmode & GR_READ ? " reading" : "",
62601 + reqmode & GR_WRITE ? " writing" : reqmode &
62602 + GR_APPEND ? " appending" : "");
62603 + return 0;
62604 + } else if (unlikely((mode & reqmode) != reqmode))
62605 + return 0;
62606 +
62607 + return reqmode;
62608 +}
62609 +
62610 +__u32
62611 +gr_acl_handle_creat(const struct dentry * dentry,
62612 + const struct dentry * p_dentry,
62613 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
62614 + const int imode)
62615 +{
62616 + __u32 reqmode = GR_WRITE | GR_CREATE;
62617 + __u32 mode;
62618 +
62619 + if (acc_mode & MAY_APPEND)
62620 + reqmode |= GR_APPEND;
62621 + // if a directory was required or the directory already exists, then
62622 + // don't count this open as a read
62623 + if ((acc_mode & MAY_READ) &&
62624 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
62625 + reqmode |= GR_READ;
62626 + if ((open_flags & O_CREAT) &&
62627 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62628 + reqmode |= GR_SETID;
62629 +
62630 + mode =
62631 + gr_check_create(dentry, p_dentry, p_mnt,
62632 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62633 +
62634 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62635 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62636 + reqmode & GR_READ ? " reading" : "",
62637 + reqmode & GR_WRITE ? " writing" : reqmode &
62638 + GR_APPEND ? " appending" : "");
62639 + return reqmode;
62640 + } else
62641 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62642 + {
62643 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62644 + reqmode & GR_READ ? " reading" : "",
62645 + reqmode & GR_WRITE ? " writing" : reqmode &
62646 + GR_APPEND ? " appending" : "");
62647 + return 0;
62648 + } else if (unlikely((mode & reqmode) != reqmode))
62649 + return 0;
62650 +
62651 + return reqmode;
62652 +}
62653 +
62654 +__u32
62655 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
62656 + const int fmode)
62657 +{
62658 + __u32 mode, reqmode = GR_FIND;
62659 +
62660 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
62661 + reqmode |= GR_EXEC;
62662 + if (fmode & S_IWOTH)
62663 + reqmode |= GR_WRITE;
62664 + if (fmode & S_IROTH)
62665 + reqmode |= GR_READ;
62666 +
62667 + mode =
62668 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62669 + mnt);
62670 +
62671 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62672 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62673 + reqmode & GR_READ ? " reading" : "",
62674 + reqmode & GR_WRITE ? " writing" : "",
62675 + reqmode & GR_EXEC ? " executing" : "");
62676 + return reqmode;
62677 + } else
62678 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62679 + {
62680 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62681 + reqmode & GR_READ ? " reading" : "",
62682 + reqmode & GR_WRITE ? " writing" : "",
62683 + reqmode & GR_EXEC ? " executing" : "");
62684 + return 0;
62685 + } else if (unlikely((mode & reqmode) != reqmode))
62686 + return 0;
62687 +
62688 + return reqmode;
62689 +}
62690 +
62691 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
62692 +{
62693 + __u32 mode;
62694 +
62695 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
62696 +
62697 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62698 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
62699 + return mode;
62700 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62701 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
62702 + return 0;
62703 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62704 + return 0;
62705 +
62706 + return (reqmode);
62707 +}
62708 +
62709 +__u32
62710 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
62711 +{
62712 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
62713 +}
62714 +
62715 +__u32
62716 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
62717 +{
62718 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
62719 +}
62720 +
62721 +__u32
62722 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
62723 +{
62724 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
62725 +}
62726 +
62727 +__u32
62728 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
62729 +{
62730 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
62731 +}
62732 +
62733 +__u32
62734 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
62735 + umode_t *modeptr)
62736 +{
62737 + umode_t mode;
62738 +
62739 + *modeptr &= ~gr_acl_umask();
62740 + mode = *modeptr;
62741 +
62742 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
62743 + return 1;
62744 +
62745 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
62746 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
62747 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
62748 + GR_CHMOD_ACL_MSG);
62749 + } else {
62750 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
62751 + }
62752 +}
62753 +
62754 +__u32
62755 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
62756 +{
62757 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
62758 +}
62759 +
62760 +__u32
62761 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
62762 +{
62763 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
62764 +}
62765 +
62766 +__u32
62767 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
62768 +{
62769 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
62770 +}
62771 +
62772 +__u32
62773 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
62774 +{
62775 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
62776 + GR_UNIXCONNECT_ACL_MSG);
62777 +}
62778 +
62779 +/* hardlinks require at minimum create and link permission,
62780 + any additional privilege required is based on the
62781 + privilege of the file being linked to
62782 +*/
62783 +__u32
62784 +gr_acl_handle_link(const struct dentry * new_dentry,
62785 + const struct dentry * parent_dentry,
62786 + const struct vfsmount * parent_mnt,
62787 + const struct dentry * old_dentry,
62788 + const struct vfsmount * old_mnt, const struct filename *to)
62789 +{
62790 + __u32 mode;
62791 + __u32 needmode = GR_CREATE | GR_LINK;
62792 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
62793 +
62794 + mode =
62795 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
62796 + old_mnt);
62797 +
62798 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
62799 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62800 + return mode;
62801 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62802 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62803 + return 0;
62804 + } else if (unlikely((mode & needmode) != needmode))
62805 + return 0;
62806 +
62807 + return 1;
62808 +}
62809 +
62810 +__u32
62811 +gr_acl_handle_symlink(const struct dentry * new_dentry,
62812 + const struct dentry * parent_dentry,
62813 + const struct vfsmount * parent_mnt, const struct filename *from)
62814 +{
62815 + __u32 needmode = GR_WRITE | GR_CREATE;
62816 + __u32 mode;
62817 +
62818 + mode =
62819 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
62820 + GR_CREATE | GR_AUDIT_CREATE |
62821 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
62822 +
62823 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
62824 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62825 + return mode;
62826 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62827 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62828 + return 0;
62829 + } else if (unlikely((mode & needmode) != needmode))
62830 + return 0;
62831 +
62832 + return (GR_WRITE | GR_CREATE);
62833 +}
62834 +
62835 +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)
62836 +{
62837 + __u32 mode;
62838 +
62839 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62840 +
62841 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62842 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
62843 + return mode;
62844 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62845 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
62846 + return 0;
62847 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62848 + return 0;
62849 +
62850 + return (reqmode);
62851 +}
62852 +
62853 +__u32
62854 +gr_acl_handle_mknod(const struct dentry * new_dentry,
62855 + const struct dentry * parent_dentry,
62856 + const struct vfsmount * parent_mnt,
62857 + const int mode)
62858 +{
62859 + __u32 reqmode = GR_WRITE | GR_CREATE;
62860 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62861 + reqmode |= GR_SETID;
62862 +
62863 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62864 + reqmode, GR_MKNOD_ACL_MSG);
62865 +}
62866 +
62867 +__u32
62868 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
62869 + const struct dentry *parent_dentry,
62870 + const struct vfsmount *parent_mnt)
62871 +{
62872 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62873 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
62874 +}
62875 +
62876 +#define RENAME_CHECK_SUCCESS(old, new) \
62877 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
62878 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
62879 +
62880 +int
62881 +gr_acl_handle_rename(struct dentry *new_dentry,
62882 + struct dentry *parent_dentry,
62883 + const struct vfsmount *parent_mnt,
62884 + struct dentry *old_dentry,
62885 + struct inode *old_parent_inode,
62886 + struct vfsmount *old_mnt, const struct filename *newname)
62887 +{
62888 + __u32 comp1, comp2;
62889 + int error = 0;
62890 +
62891 + if (unlikely(!gr_acl_is_enabled()))
62892 + return 0;
62893 +
62894 + if (!new_dentry->d_inode) {
62895 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
62896 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
62897 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
62898 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
62899 + GR_DELETE | GR_AUDIT_DELETE |
62900 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62901 + GR_SUPPRESS, old_mnt);
62902 + } else {
62903 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
62904 + GR_CREATE | GR_DELETE |
62905 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
62906 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62907 + GR_SUPPRESS, parent_mnt);
62908 + comp2 =
62909 + gr_search_file(old_dentry,
62910 + GR_READ | GR_WRITE | GR_AUDIT_READ |
62911 + GR_DELETE | GR_AUDIT_DELETE |
62912 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
62913 + }
62914 +
62915 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
62916 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
62917 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62918 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
62919 + && !(comp2 & GR_SUPPRESS)) {
62920 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62921 + error = -EACCES;
62922 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
62923 + error = -EACCES;
62924 +
62925 + return error;
62926 +}
62927 +
62928 +void
62929 +gr_acl_handle_exit(void)
62930 +{
62931 + u16 id;
62932 + char *rolename;
62933 +
62934 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
62935 + !(current->role->roletype & GR_ROLE_PERSIST))) {
62936 + id = current->acl_role_id;
62937 + rolename = current->role->rolename;
62938 + gr_set_acls(1);
62939 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
62940 + }
62941 +
62942 + gr_put_exec_file(current);
62943 + return;
62944 +}
62945 +
62946 +int
62947 +gr_acl_handle_procpidmem(const struct task_struct *task)
62948 +{
62949 + if (unlikely(!gr_acl_is_enabled()))
62950 + return 0;
62951 +
62952 + if (task != current && task->acl->mode & GR_PROTPROCFD)
62953 + return -EACCES;
62954 +
62955 + return 0;
62956 +}
62957 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
62958 new file mode 100644
62959 index 0000000..8132048
62960 --- /dev/null
62961 +++ b/grsecurity/gracl_ip.c
62962 @@ -0,0 +1,387 @@
62963 +#include <linux/kernel.h>
62964 +#include <asm/uaccess.h>
62965 +#include <asm/errno.h>
62966 +#include <net/sock.h>
62967 +#include <linux/file.h>
62968 +#include <linux/fs.h>
62969 +#include <linux/net.h>
62970 +#include <linux/in.h>
62971 +#include <linux/skbuff.h>
62972 +#include <linux/ip.h>
62973 +#include <linux/udp.h>
62974 +#include <linux/types.h>
62975 +#include <linux/sched.h>
62976 +#include <linux/netdevice.h>
62977 +#include <linux/inetdevice.h>
62978 +#include <linux/gracl.h>
62979 +#include <linux/grsecurity.h>
62980 +#include <linux/grinternal.h>
62981 +
62982 +#define GR_BIND 0x01
62983 +#define GR_CONNECT 0x02
62984 +#define GR_INVERT 0x04
62985 +#define GR_BINDOVERRIDE 0x08
62986 +#define GR_CONNECTOVERRIDE 0x10
62987 +#define GR_SOCK_FAMILY 0x20
62988 +
62989 +static const char * gr_protocols[IPPROTO_MAX] = {
62990 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
62991 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
62992 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
62993 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
62994 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
62995 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
62996 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
62997 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
62998 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
62999 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
63000 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
63001 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
63002 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
63003 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
63004 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
63005 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
63006 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
63007 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
63008 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
63009 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
63010 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
63011 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
63012 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
63013 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
63014 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
63015 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
63016 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
63017 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
63018 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
63019 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
63020 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
63021 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
63022 + };
63023 +
63024 +static const char * gr_socktypes[SOCK_MAX] = {
63025 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
63026 + "unknown:7", "unknown:8", "unknown:9", "packet"
63027 + };
63028 +
63029 +static const char * gr_sockfamilies[AF_MAX+1] = {
63030 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
63031 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
63032 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
63033 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
63034 + };
63035 +
63036 +const char *
63037 +gr_proto_to_name(unsigned char proto)
63038 +{
63039 + return gr_protocols[proto];
63040 +}
63041 +
63042 +const char *
63043 +gr_socktype_to_name(unsigned char type)
63044 +{
63045 + return gr_socktypes[type];
63046 +}
63047 +
63048 +const char *
63049 +gr_sockfamily_to_name(unsigned char family)
63050 +{
63051 + return gr_sockfamilies[family];
63052 +}
63053 +
63054 +int
63055 +gr_search_socket(const int domain, const int type, const int protocol)
63056 +{
63057 + struct acl_subject_label *curr;
63058 + const struct cred *cred = current_cred();
63059 +
63060 + if (unlikely(!gr_acl_is_enabled()))
63061 + goto exit;
63062 +
63063 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
63064 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
63065 + goto exit; // let the kernel handle it
63066 +
63067 + curr = current->acl;
63068 +
63069 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
63070 + /* the family is allowed, if this is PF_INET allow it only if
63071 + the extra sock type/protocol checks pass */
63072 + if (domain == PF_INET)
63073 + goto inet_check;
63074 + goto exit;
63075 + } else {
63076 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63077 + __u32 fakeip = 0;
63078 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63079 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63080 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63081 + gr_to_filename(current->exec_file->f_path.dentry,
63082 + current->exec_file->f_path.mnt) :
63083 + curr->filename, curr->filename,
63084 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
63085 + &current->signal->saved_ip);
63086 + goto exit;
63087 + }
63088 + goto exit_fail;
63089 + }
63090 +
63091 +inet_check:
63092 + /* the rest of this checking is for IPv4 only */
63093 + if (!curr->ips)
63094 + goto exit;
63095 +
63096 + if ((curr->ip_type & (1U << type)) &&
63097 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
63098 + goto exit;
63099 +
63100 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63101 + /* we don't place acls on raw sockets , and sometimes
63102 + dgram/ip sockets are opened for ioctl and not
63103 + bind/connect, so we'll fake a bind learn log */
63104 + if (type == SOCK_RAW || type == SOCK_PACKET) {
63105 + __u32 fakeip = 0;
63106 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63107 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63108 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63109 + gr_to_filename(current->exec_file->f_path.dentry,
63110 + current->exec_file->f_path.mnt) :
63111 + curr->filename, curr->filename,
63112 + &fakeip, 0, type,
63113 + protocol, GR_CONNECT, &current->signal->saved_ip);
63114 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
63115 + __u32 fakeip = 0;
63116 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63117 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63118 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63119 + gr_to_filename(current->exec_file->f_path.dentry,
63120 + current->exec_file->f_path.mnt) :
63121 + curr->filename, curr->filename,
63122 + &fakeip, 0, type,
63123 + protocol, GR_BIND, &current->signal->saved_ip);
63124 + }
63125 + /* we'll log when they use connect or bind */
63126 + goto exit;
63127 + }
63128 +
63129 +exit_fail:
63130 + if (domain == PF_INET)
63131 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
63132 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
63133 + else
63134 +#ifndef CONFIG_IPV6
63135 + if (domain != PF_INET6)
63136 +#endif
63137 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
63138 + gr_socktype_to_name(type), protocol);
63139 +
63140 + return 0;
63141 +exit:
63142 + return 1;
63143 +}
63144 +
63145 +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)
63146 +{
63147 + if ((ip->mode & mode) &&
63148 + (ip_port >= ip->low) &&
63149 + (ip_port <= ip->high) &&
63150 + ((ntohl(ip_addr) & our_netmask) ==
63151 + (ntohl(our_addr) & our_netmask))
63152 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
63153 + && (ip->type & (1U << type))) {
63154 + if (ip->mode & GR_INVERT)
63155 + return 2; // specifically denied
63156 + else
63157 + return 1; // allowed
63158 + }
63159 +
63160 + return 0; // not specifically allowed, may continue parsing
63161 +}
63162 +
63163 +static int
63164 +gr_search_connectbind(const int full_mode, struct sock *sk,
63165 + struct sockaddr_in *addr, const int type)
63166 +{
63167 + char iface[IFNAMSIZ] = {0};
63168 + struct acl_subject_label *curr;
63169 + struct acl_ip_label *ip;
63170 + struct inet_sock *isk;
63171 + struct net_device *dev;
63172 + struct in_device *idev;
63173 + unsigned long i;
63174 + int ret;
63175 + int mode = full_mode & (GR_BIND | GR_CONNECT);
63176 + __u32 ip_addr = 0;
63177 + __u32 our_addr;
63178 + __u32 our_netmask;
63179 + char *p;
63180 + __u16 ip_port = 0;
63181 + const struct cred *cred = current_cred();
63182 +
63183 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
63184 + return 0;
63185 +
63186 + curr = current->acl;
63187 + isk = inet_sk(sk);
63188 +
63189 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
63190 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
63191 + addr->sin_addr.s_addr = curr->inaddr_any_override;
63192 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
63193 + struct sockaddr_in saddr;
63194 + int err;
63195 +
63196 + saddr.sin_family = AF_INET;
63197 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
63198 + saddr.sin_port = isk->inet_sport;
63199 +
63200 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63201 + if (err)
63202 + return err;
63203 +
63204 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63205 + if (err)
63206 + return err;
63207 + }
63208 +
63209 + if (!curr->ips)
63210 + return 0;
63211 +
63212 + ip_addr = addr->sin_addr.s_addr;
63213 + ip_port = ntohs(addr->sin_port);
63214 +
63215 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63216 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63217 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63218 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63219 + gr_to_filename(current->exec_file->f_path.dentry,
63220 + current->exec_file->f_path.mnt) :
63221 + curr->filename, curr->filename,
63222 + &ip_addr, ip_port, type,
63223 + sk->sk_protocol, mode, &current->signal->saved_ip);
63224 + return 0;
63225 + }
63226 +
63227 + for (i = 0; i < curr->ip_num; i++) {
63228 + ip = *(curr->ips + i);
63229 + if (ip->iface != NULL) {
63230 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
63231 + p = strchr(iface, ':');
63232 + if (p != NULL)
63233 + *p = '\0';
63234 + dev = dev_get_by_name(sock_net(sk), iface);
63235 + if (dev == NULL)
63236 + continue;
63237 + idev = in_dev_get(dev);
63238 + if (idev == NULL) {
63239 + dev_put(dev);
63240 + continue;
63241 + }
63242 + rcu_read_lock();
63243 + for_ifa(idev) {
63244 + if (!strcmp(ip->iface, ifa->ifa_label)) {
63245 + our_addr = ifa->ifa_address;
63246 + our_netmask = 0xffffffff;
63247 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63248 + if (ret == 1) {
63249 + rcu_read_unlock();
63250 + in_dev_put(idev);
63251 + dev_put(dev);
63252 + return 0;
63253 + } else if (ret == 2) {
63254 + rcu_read_unlock();
63255 + in_dev_put(idev);
63256 + dev_put(dev);
63257 + goto denied;
63258 + }
63259 + }
63260 + } endfor_ifa(idev);
63261 + rcu_read_unlock();
63262 + in_dev_put(idev);
63263 + dev_put(dev);
63264 + } else {
63265 + our_addr = ip->addr;
63266 + our_netmask = ip->netmask;
63267 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63268 + if (ret == 1)
63269 + return 0;
63270 + else if (ret == 2)
63271 + goto denied;
63272 + }
63273 + }
63274 +
63275 +denied:
63276 + if (mode == GR_BIND)
63277 + 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));
63278 + else if (mode == GR_CONNECT)
63279 + 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));
63280 +
63281 + return -EACCES;
63282 +}
63283 +
63284 +int
63285 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
63286 +{
63287 + /* always allow disconnection of dgram sockets with connect */
63288 + if (addr->sin_family == AF_UNSPEC)
63289 + return 0;
63290 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
63291 +}
63292 +
63293 +int
63294 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
63295 +{
63296 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
63297 +}
63298 +
63299 +int gr_search_listen(struct socket *sock)
63300 +{
63301 + struct sock *sk = sock->sk;
63302 + struct sockaddr_in addr;
63303 +
63304 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63305 + addr.sin_port = inet_sk(sk)->inet_sport;
63306 +
63307 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63308 +}
63309 +
63310 +int gr_search_accept(struct socket *sock)
63311 +{
63312 + struct sock *sk = sock->sk;
63313 + struct sockaddr_in addr;
63314 +
63315 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63316 + addr.sin_port = inet_sk(sk)->inet_sport;
63317 +
63318 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63319 +}
63320 +
63321 +int
63322 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
63323 +{
63324 + if (addr)
63325 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
63326 + else {
63327 + struct sockaddr_in sin;
63328 + const struct inet_sock *inet = inet_sk(sk);
63329 +
63330 + sin.sin_addr.s_addr = inet->inet_daddr;
63331 + sin.sin_port = inet->inet_dport;
63332 +
63333 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63334 + }
63335 +}
63336 +
63337 +int
63338 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
63339 +{
63340 + struct sockaddr_in sin;
63341 +
63342 + if (unlikely(skb->len < sizeof (struct udphdr)))
63343 + return 0; // skip this packet
63344 +
63345 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
63346 + sin.sin_port = udp_hdr(skb)->source;
63347 +
63348 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63349 +}
63350 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
63351 new file mode 100644
63352 index 0000000..25f54ef
63353 --- /dev/null
63354 +++ b/grsecurity/gracl_learn.c
63355 @@ -0,0 +1,207 @@
63356 +#include <linux/kernel.h>
63357 +#include <linux/mm.h>
63358 +#include <linux/sched.h>
63359 +#include <linux/poll.h>
63360 +#include <linux/string.h>
63361 +#include <linux/file.h>
63362 +#include <linux/types.h>
63363 +#include <linux/vmalloc.h>
63364 +#include <linux/grinternal.h>
63365 +
63366 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
63367 + size_t count, loff_t *ppos);
63368 +extern int gr_acl_is_enabled(void);
63369 +
63370 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
63371 +static int gr_learn_attached;
63372 +
63373 +/* use a 512k buffer */
63374 +#define LEARN_BUFFER_SIZE (512 * 1024)
63375 +
63376 +static DEFINE_SPINLOCK(gr_learn_lock);
63377 +static DEFINE_MUTEX(gr_learn_user_mutex);
63378 +
63379 +/* we need to maintain two buffers, so that the kernel context of grlearn
63380 + uses a semaphore around the userspace copying, and the other kernel contexts
63381 + use a spinlock when copying into the buffer, since they cannot sleep
63382 +*/
63383 +static char *learn_buffer;
63384 +static char *learn_buffer_user;
63385 +static int learn_buffer_len;
63386 +static int learn_buffer_user_len;
63387 +
63388 +static ssize_t
63389 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
63390 +{
63391 + DECLARE_WAITQUEUE(wait, current);
63392 + ssize_t retval = 0;
63393 +
63394 + add_wait_queue(&learn_wait, &wait);
63395 + set_current_state(TASK_INTERRUPTIBLE);
63396 + do {
63397 + mutex_lock(&gr_learn_user_mutex);
63398 + spin_lock(&gr_learn_lock);
63399 + if (learn_buffer_len)
63400 + break;
63401 + spin_unlock(&gr_learn_lock);
63402 + mutex_unlock(&gr_learn_user_mutex);
63403 + if (file->f_flags & O_NONBLOCK) {
63404 + retval = -EAGAIN;
63405 + goto out;
63406 + }
63407 + if (signal_pending(current)) {
63408 + retval = -ERESTARTSYS;
63409 + goto out;
63410 + }
63411 +
63412 + schedule();
63413 + } while (1);
63414 +
63415 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
63416 + learn_buffer_user_len = learn_buffer_len;
63417 + retval = learn_buffer_len;
63418 + learn_buffer_len = 0;
63419 +
63420 + spin_unlock(&gr_learn_lock);
63421 +
63422 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
63423 + retval = -EFAULT;
63424 +
63425 + mutex_unlock(&gr_learn_user_mutex);
63426 +out:
63427 + set_current_state(TASK_RUNNING);
63428 + remove_wait_queue(&learn_wait, &wait);
63429 + return retval;
63430 +}
63431 +
63432 +static unsigned int
63433 +poll_learn(struct file * file, poll_table * wait)
63434 +{
63435 + poll_wait(file, &learn_wait, wait);
63436 +
63437 + if (learn_buffer_len)
63438 + return (POLLIN | POLLRDNORM);
63439 +
63440 + return 0;
63441 +}
63442 +
63443 +void
63444 +gr_clear_learn_entries(void)
63445 +{
63446 + char *tmp;
63447 +
63448 + mutex_lock(&gr_learn_user_mutex);
63449 + spin_lock(&gr_learn_lock);
63450 + tmp = learn_buffer;
63451 + learn_buffer = NULL;
63452 + spin_unlock(&gr_learn_lock);
63453 + if (tmp)
63454 + vfree(tmp);
63455 + if (learn_buffer_user != NULL) {
63456 + vfree(learn_buffer_user);
63457 + learn_buffer_user = NULL;
63458 + }
63459 + learn_buffer_len = 0;
63460 + mutex_unlock(&gr_learn_user_mutex);
63461 +
63462 + return;
63463 +}
63464 +
63465 +void
63466 +gr_add_learn_entry(const char *fmt, ...)
63467 +{
63468 + va_list args;
63469 + unsigned int len;
63470 +
63471 + if (!gr_learn_attached)
63472 + return;
63473 +
63474 + spin_lock(&gr_learn_lock);
63475 +
63476 + /* leave a gap at the end so we know when it's "full" but don't have to
63477 + compute the exact length of the string we're trying to append
63478 + */
63479 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
63480 + spin_unlock(&gr_learn_lock);
63481 + wake_up_interruptible(&learn_wait);
63482 + return;
63483 + }
63484 + if (learn_buffer == NULL) {
63485 + spin_unlock(&gr_learn_lock);
63486 + return;
63487 + }
63488 +
63489 + va_start(args, fmt);
63490 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
63491 + va_end(args);
63492 +
63493 + learn_buffer_len += len + 1;
63494 +
63495 + spin_unlock(&gr_learn_lock);
63496 + wake_up_interruptible(&learn_wait);
63497 +
63498 + return;
63499 +}
63500 +
63501 +static int
63502 +open_learn(struct inode *inode, struct file *file)
63503 +{
63504 + if (file->f_mode & FMODE_READ && gr_learn_attached)
63505 + return -EBUSY;
63506 + if (file->f_mode & FMODE_READ) {
63507 + int retval = 0;
63508 + mutex_lock(&gr_learn_user_mutex);
63509 + if (learn_buffer == NULL)
63510 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
63511 + if (learn_buffer_user == NULL)
63512 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
63513 + if (learn_buffer == NULL) {
63514 + retval = -ENOMEM;
63515 + goto out_error;
63516 + }
63517 + if (learn_buffer_user == NULL) {
63518 + retval = -ENOMEM;
63519 + goto out_error;
63520 + }
63521 + learn_buffer_len = 0;
63522 + learn_buffer_user_len = 0;
63523 + gr_learn_attached = 1;
63524 +out_error:
63525 + mutex_unlock(&gr_learn_user_mutex);
63526 + return retval;
63527 + }
63528 + return 0;
63529 +}
63530 +
63531 +static int
63532 +close_learn(struct inode *inode, struct file *file)
63533 +{
63534 + if (file->f_mode & FMODE_READ) {
63535 + char *tmp = NULL;
63536 + mutex_lock(&gr_learn_user_mutex);
63537 + spin_lock(&gr_learn_lock);
63538 + tmp = learn_buffer;
63539 + learn_buffer = NULL;
63540 + spin_unlock(&gr_learn_lock);
63541 + if (tmp)
63542 + vfree(tmp);
63543 + if (learn_buffer_user != NULL) {
63544 + vfree(learn_buffer_user);
63545 + learn_buffer_user = NULL;
63546 + }
63547 + learn_buffer_len = 0;
63548 + learn_buffer_user_len = 0;
63549 + gr_learn_attached = 0;
63550 + mutex_unlock(&gr_learn_user_mutex);
63551 + }
63552 +
63553 + return 0;
63554 +}
63555 +
63556 +const struct file_operations grsec_fops = {
63557 + .read = read_learn,
63558 + .write = write_grsec_handler,
63559 + .open = open_learn,
63560 + .release = close_learn,
63561 + .poll = poll_learn,
63562 +};
63563 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
63564 new file mode 100644
63565 index 0000000..39645c9
63566 --- /dev/null
63567 +++ b/grsecurity/gracl_res.c
63568 @@ -0,0 +1,68 @@
63569 +#include <linux/kernel.h>
63570 +#include <linux/sched.h>
63571 +#include <linux/gracl.h>
63572 +#include <linux/grinternal.h>
63573 +
63574 +static const char *restab_log[] = {
63575 + [RLIMIT_CPU] = "RLIMIT_CPU",
63576 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
63577 + [RLIMIT_DATA] = "RLIMIT_DATA",
63578 + [RLIMIT_STACK] = "RLIMIT_STACK",
63579 + [RLIMIT_CORE] = "RLIMIT_CORE",
63580 + [RLIMIT_RSS] = "RLIMIT_RSS",
63581 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
63582 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
63583 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
63584 + [RLIMIT_AS] = "RLIMIT_AS",
63585 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
63586 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
63587 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
63588 + [RLIMIT_NICE] = "RLIMIT_NICE",
63589 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
63590 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
63591 + [GR_CRASH_RES] = "RLIMIT_CRASH"
63592 +};
63593 +
63594 +void
63595 +gr_log_resource(const struct task_struct *task,
63596 + const int res, const unsigned long wanted, const int gt)
63597 +{
63598 + const struct cred *cred;
63599 + unsigned long rlim;
63600 +
63601 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
63602 + return;
63603 +
63604 + // not yet supported resource
63605 + if (unlikely(!restab_log[res]))
63606 + return;
63607 +
63608 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
63609 + rlim = task_rlimit_max(task, res);
63610 + else
63611 + rlim = task_rlimit(task, res);
63612 +
63613 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
63614 + return;
63615 +
63616 + rcu_read_lock();
63617 + cred = __task_cred(task);
63618 +
63619 + if (res == RLIMIT_NPROC &&
63620 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
63621 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
63622 + goto out_rcu_unlock;
63623 + else if (res == RLIMIT_MEMLOCK &&
63624 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
63625 + goto out_rcu_unlock;
63626 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
63627 + goto out_rcu_unlock;
63628 + rcu_read_unlock();
63629 +
63630 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
63631 +
63632 + return;
63633 +out_rcu_unlock:
63634 + rcu_read_unlock();
63635 + return;
63636 +}
63637 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
63638 new file mode 100644
63639 index 0000000..cb1e5ab
63640 --- /dev/null
63641 +++ b/grsecurity/gracl_segv.c
63642 @@ -0,0 +1,303 @@
63643 +#include <linux/kernel.h>
63644 +#include <linux/mm.h>
63645 +#include <asm/uaccess.h>
63646 +#include <asm/errno.h>
63647 +#include <asm/mman.h>
63648 +#include <net/sock.h>
63649 +#include <linux/file.h>
63650 +#include <linux/fs.h>
63651 +#include <linux/net.h>
63652 +#include <linux/in.h>
63653 +#include <linux/slab.h>
63654 +#include <linux/types.h>
63655 +#include <linux/sched.h>
63656 +#include <linux/timer.h>
63657 +#include <linux/gracl.h>
63658 +#include <linux/grsecurity.h>
63659 +#include <linux/grinternal.h>
63660 +
63661 +static struct crash_uid *uid_set;
63662 +static unsigned short uid_used;
63663 +static DEFINE_SPINLOCK(gr_uid_lock);
63664 +extern rwlock_t gr_inode_lock;
63665 +extern struct acl_subject_label *
63666 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
63667 + struct acl_role_label *role);
63668 +
63669 +#ifdef CONFIG_BTRFS_FS
63670 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
63671 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
63672 +#endif
63673 +
63674 +static inline dev_t __get_dev(const struct dentry *dentry)
63675 +{
63676 +#ifdef CONFIG_BTRFS_FS
63677 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
63678 + return get_btrfs_dev_from_inode(dentry->d_inode);
63679 + else
63680 +#endif
63681 + return dentry->d_inode->i_sb->s_dev;
63682 +}
63683 +
63684 +int
63685 +gr_init_uidset(void)
63686 +{
63687 + uid_set =
63688 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
63689 + uid_used = 0;
63690 +
63691 + return uid_set ? 1 : 0;
63692 +}
63693 +
63694 +void
63695 +gr_free_uidset(void)
63696 +{
63697 + if (uid_set)
63698 + kfree(uid_set);
63699 +
63700 + return;
63701 +}
63702 +
63703 +int
63704 +gr_find_uid(const uid_t uid)
63705 +{
63706 + struct crash_uid *tmp = uid_set;
63707 + uid_t buid;
63708 + int low = 0, high = uid_used - 1, mid;
63709 +
63710 + while (high >= low) {
63711 + mid = (low + high) >> 1;
63712 + buid = tmp[mid].uid;
63713 + if (buid == uid)
63714 + return mid;
63715 + if (buid > uid)
63716 + high = mid - 1;
63717 + if (buid < uid)
63718 + low = mid + 1;
63719 + }
63720 +
63721 + return -1;
63722 +}
63723 +
63724 +static __inline__ void
63725 +gr_insertsort(void)
63726 +{
63727 + unsigned short i, j;
63728 + struct crash_uid index;
63729 +
63730 + for (i = 1; i < uid_used; i++) {
63731 + index = uid_set[i];
63732 + j = i;
63733 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
63734 + uid_set[j] = uid_set[j - 1];
63735 + j--;
63736 + }
63737 + uid_set[j] = index;
63738 + }
63739 +
63740 + return;
63741 +}
63742 +
63743 +static __inline__ void
63744 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
63745 +{
63746 + int loc;
63747 + uid_t uid = GR_GLOBAL_UID(kuid);
63748 +
63749 + if (uid_used == GR_UIDTABLE_MAX)
63750 + return;
63751 +
63752 + loc = gr_find_uid(uid);
63753 +
63754 + if (loc >= 0) {
63755 + uid_set[loc].expires = expires;
63756 + return;
63757 + }
63758 +
63759 + uid_set[uid_used].uid = uid;
63760 + uid_set[uid_used].expires = expires;
63761 + uid_used++;
63762 +
63763 + gr_insertsort();
63764 +
63765 + return;
63766 +}
63767 +
63768 +void
63769 +gr_remove_uid(const unsigned short loc)
63770 +{
63771 + unsigned short i;
63772 +
63773 + for (i = loc + 1; i < uid_used; i++)
63774 + uid_set[i - 1] = uid_set[i];
63775 +
63776 + uid_used--;
63777 +
63778 + return;
63779 +}
63780 +
63781 +int
63782 +gr_check_crash_uid(const kuid_t kuid)
63783 +{
63784 + int loc;
63785 + int ret = 0;
63786 + uid_t uid;
63787 +
63788 + if (unlikely(!gr_acl_is_enabled()))
63789 + return 0;
63790 +
63791 + uid = GR_GLOBAL_UID(kuid);
63792 +
63793 + spin_lock(&gr_uid_lock);
63794 + loc = gr_find_uid(uid);
63795 +
63796 + if (loc < 0)
63797 + goto out_unlock;
63798 +
63799 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
63800 + gr_remove_uid(loc);
63801 + else
63802 + ret = 1;
63803 +
63804 +out_unlock:
63805 + spin_unlock(&gr_uid_lock);
63806 + return ret;
63807 +}
63808 +
63809 +static __inline__ int
63810 +proc_is_setxid(const struct cred *cred)
63811 +{
63812 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
63813 + !uid_eq(cred->uid, cred->fsuid))
63814 + return 1;
63815 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
63816 + !gid_eq(cred->gid, cred->fsgid))
63817 + return 1;
63818 +
63819 + return 0;
63820 +}
63821 +
63822 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
63823 +
63824 +void
63825 +gr_handle_crash(struct task_struct *task, const int sig)
63826 +{
63827 + struct acl_subject_label *curr;
63828 + struct task_struct *tsk, *tsk2;
63829 + const struct cred *cred;
63830 + const struct cred *cred2;
63831 +
63832 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
63833 + return;
63834 +
63835 + if (unlikely(!gr_acl_is_enabled()))
63836 + return;
63837 +
63838 + curr = task->acl;
63839 +
63840 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
63841 + return;
63842 +
63843 + if (time_before_eq(curr->expires, get_seconds())) {
63844 + curr->expires = 0;
63845 + curr->crashes = 0;
63846 + }
63847 +
63848 + curr->crashes++;
63849 +
63850 + if (!curr->expires)
63851 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
63852 +
63853 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63854 + time_after(curr->expires, get_seconds())) {
63855 + rcu_read_lock();
63856 + cred = __task_cred(task);
63857 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
63858 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63859 + spin_lock(&gr_uid_lock);
63860 + gr_insert_uid(cred->uid, curr->expires);
63861 + spin_unlock(&gr_uid_lock);
63862 + curr->expires = 0;
63863 + curr->crashes = 0;
63864 + read_lock(&tasklist_lock);
63865 + do_each_thread(tsk2, tsk) {
63866 + cred2 = __task_cred(tsk);
63867 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
63868 + gr_fake_force_sig(SIGKILL, tsk);
63869 + } while_each_thread(tsk2, tsk);
63870 + read_unlock(&tasklist_lock);
63871 + } else {
63872 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63873 + read_lock(&tasklist_lock);
63874 + read_lock(&grsec_exec_file_lock);
63875 + do_each_thread(tsk2, tsk) {
63876 + if (likely(tsk != task)) {
63877 + // if this thread has the same subject as the one that triggered
63878 + // RES_CRASH and it's the same binary, kill it
63879 + if (tsk->acl == task->acl && tsk->exec_file == task->exec_file)
63880 + gr_fake_force_sig(SIGKILL, tsk);
63881 + }
63882 + } while_each_thread(tsk2, tsk);
63883 + read_unlock(&grsec_exec_file_lock);
63884 + read_unlock(&tasklist_lock);
63885 + }
63886 + rcu_read_unlock();
63887 + }
63888 +
63889 + return;
63890 +}
63891 +
63892 +int
63893 +gr_check_crash_exec(const struct file *filp)
63894 +{
63895 + struct acl_subject_label *curr;
63896 +
63897 + if (unlikely(!gr_acl_is_enabled()))
63898 + return 0;
63899 +
63900 + read_lock(&gr_inode_lock);
63901 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
63902 + __get_dev(filp->f_path.dentry),
63903 + current->role);
63904 + read_unlock(&gr_inode_lock);
63905 +
63906 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
63907 + (!curr->crashes && !curr->expires))
63908 + return 0;
63909 +
63910 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63911 + time_after(curr->expires, get_seconds()))
63912 + return 1;
63913 + else if (time_before_eq(curr->expires, get_seconds())) {
63914 + curr->crashes = 0;
63915 + curr->expires = 0;
63916 + }
63917 +
63918 + return 0;
63919 +}
63920 +
63921 +void
63922 +gr_handle_alertkill(struct task_struct *task)
63923 +{
63924 + struct acl_subject_label *curracl;
63925 + __u32 curr_ip;
63926 + struct task_struct *p, *p2;
63927 +
63928 + if (unlikely(!gr_acl_is_enabled()))
63929 + return;
63930 +
63931 + curracl = task->acl;
63932 + curr_ip = task->signal->curr_ip;
63933 +
63934 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
63935 + read_lock(&tasklist_lock);
63936 + do_each_thread(p2, p) {
63937 + if (p->signal->curr_ip == curr_ip)
63938 + gr_fake_force_sig(SIGKILL, p);
63939 + } while_each_thread(p2, p);
63940 + read_unlock(&tasklist_lock);
63941 + } else if (curracl->mode & GR_KILLPROC)
63942 + gr_fake_force_sig(SIGKILL, task);
63943 +
63944 + return;
63945 +}
63946 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
63947 new file mode 100644
63948 index 0000000..98011b0
63949 --- /dev/null
63950 +++ b/grsecurity/gracl_shm.c
63951 @@ -0,0 +1,40 @@
63952 +#include <linux/kernel.h>
63953 +#include <linux/mm.h>
63954 +#include <linux/sched.h>
63955 +#include <linux/file.h>
63956 +#include <linux/ipc.h>
63957 +#include <linux/gracl.h>
63958 +#include <linux/grsecurity.h>
63959 +#include <linux/grinternal.h>
63960 +
63961 +int
63962 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63963 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
63964 +{
63965 + struct task_struct *task;
63966 +
63967 + if (!gr_acl_is_enabled())
63968 + return 1;
63969 +
63970 + rcu_read_lock();
63971 + read_lock(&tasklist_lock);
63972 +
63973 + task = find_task_by_vpid(shm_cprid);
63974 +
63975 + if (unlikely(!task))
63976 + task = find_task_by_vpid(shm_lapid);
63977 +
63978 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
63979 + (task_pid_nr(task) == shm_lapid)) &&
63980 + (task->acl->mode & GR_PROTSHM) &&
63981 + (task->acl != current->acl))) {
63982 + read_unlock(&tasklist_lock);
63983 + rcu_read_unlock();
63984 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
63985 + return 0;
63986 + }
63987 + read_unlock(&tasklist_lock);
63988 + rcu_read_unlock();
63989 +
63990 + return 1;
63991 +}
63992 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
63993 new file mode 100644
63994 index 0000000..bc0be01
63995 --- /dev/null
63996 +++ b/grsecurity/grsec_chdir.c
63997 @@ -0,0 +1,19 @@
63998 +#include <linux/kernel.h>
63999 +#include <linux/sched.h>
64000 +#include <linux/fs.h>
64001 +#include <linux/file.h>
64002 +#include <linux/grsecurity.h>
64003 +#include <linux/grinternal.h>
64004 +
64005 +void
64006 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
64007 +{
64008 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
64009 + if ((grsec_enable_chdir && grsec_enable_group &&
64010 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
64011 + !grsec_enable_group)) {
64012 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
64013 + }
64014 +#endif
64015 + return;
64016 +}
64017 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
64018 new file mode 100644
64019 index 0000000..6d2de57
64020 --- /dev/null
64021 +++ b/grsecurity/grsec_chroot.c
64022 @@ -0,0 +1,357 @@
64023 +#include <linux/kernel.h>
64024 +#include <linux/module.h>
64025 +#include <linux/sched.h>
64026 +#include <linux/file.h>
64027 +#include <linux/fs.h>
64028 +#include <linux/mount.h>
64029 +#include <linux/types.h>
64030 +#include "../fs/mount.h"
64031 +#include <linux/grsecurity.h>
64032 +#include <linux/grinternal.h>
64033 +
64034 +void gr_set_chroot_entries(struct task_struct *task, struct path *path)
64035 +{
64036 +#ifdef CONFIG_GRKERNSEC
64037 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
64038 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root)
64039 + task->gr_is_chrooted = 1;
64040 + else
64041 + task->gr_is_chrooted = 0;
64042 +
64043 + task->gr_chroot_dentry = path->dentry;
64044 +#endif
64045 + return;
64046 +}
64047 +
64048 +void gr_clear_chroot_entries(struct task_struct *task)
64049 +{
64050 +#ifdef CONFIG_GRKERNSEC
64051 + task->gr_is_chrooted = 0;
64052 + task->gr_chroot_dentry = NULL;
64053 +#endif
64054 + return;
64055 +}
64056 +
64057 +int
64058 +gr_handle_chroot_unix(const pid_t pid)
64059 +{
64060 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
64061 + struct task_struct *p;
64062 +
64063 + if (unlikely(!grsec_enable_chroot_unix))
64064 + return 1;
64065 +
64066 + if (likely(!proc_is_chrooted(current)))
64067 + return 1;
64068 +
64069 + rcu_read_lock();
64070 + read_lock(&tasklist_lock);
64071 + p = find_task_by_vpid_unrestricted(pid);
64072 + if (unlikely(p && !have_same_root(current, p))) {
64073 + read_unlock(&tasklist_lock);
64074 + rcu_read_unlock();
64075 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
64076 + return 0;
64077 + }
64078 + read_unlock(&tasklist_lock);
64079 + rcu_read_unlock();
64080 +#endif
64081 + return 1;
64082 +}
64083 +
64084 +int
64085 +gr_handle_chroot_nice(void)
64086 +{
64087 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64088 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
64089 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
64090 + return -EPERM;
64091 + }
64092 +#endif
64093 + return 0;
64094 +}
64095 +
64096 +int
64097 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
64098 +{
64099 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64100 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
64101 + && proc_is_chrooted(current)) {
64102 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
64103 + return -EACCES;
64104 + }
64105 +#endif
64106 + return 0;
64107 +}
64108 +
64109 +int
64110 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
64111 +{
64112 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64113 + struct task_struct *p;
64114 + int ret = 0;
64115 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
64116 + return ret;
64117 +
64118 + read_lock(&tasklist_lock);
64119 + do_each_pid_task(pid, type, p) {
64120 + if (!have_same_root(current, p)) {
64121 + ret = 1;
64122 + goto out;
64123 + }
64124 + } while_each_pid_task(pid, type, p);
64125 +out:
64126 + read_unlock(&tasklist_lock);
64127 + return ret;
64128 +#endif
64129 + return 0;
64130 +}
64131 +
64132 +int
64133 +gr_pid_is_chrooted(struct task_struct *p)
64134 +{
64135 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64136 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
64137 + return 0;
64138 +
64139 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
64140 + !have_same_root(current, p)) {
64141 + return 1;
64142 + }
64143 +#endif
64144 + return 0;
64145 +}
64146 +
64147 +EXPORT_SYMBOL(gr_pid_is_chrooted);
64148 +
64149 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
64150 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
64151 +{
64152 + struct path path, currentroot;
64153 + int ret = 0;
64154 +
64155 + path.dentry = (struct dentry *)u_dentry;
64156 + path.mnt = (struct vfsmount *)u_mnt;
64157 + get_fs_root(current->fs, &currentroot);
64158 + if (path_is_under(&path, &currentroot))
64159 + ret = 1;
64160 + path_put(&currentroot);
64161 +
64162 + return ret;
64163 +}
64164 +#endif
64165 +
64166 +int
64167 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
64168 +{
64169 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64170 + if (!grsec_enable_chroot_fchdir)
64171 + return 1;
64172 +
64173 + if (!proc_is_chrooted(current))
64174 + return 1;
64175 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
64176 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
64177 + return 0;
64178 + }
64179 +#endif
64180 + return 1;
64181 +}
64182 +
64183 +int
64184 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64185 + const time_t shm_createtime)
64186 +{
64187 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64188 + struct task_struct *p;
64189 + time_t starttime;
64190 +
64191 + if (unlikely(!grsec_enable_chroot_shmat))
64192 + return 1;
64193 +
64194 + if (likely(!proc_is_chrooted(current)))
64195 + return 1;
64196 +
64197 + rcu_read_lock();
64198 + read_lock(&tasklist_lock);
64199 +
64200 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
64201 + starttime = p->start_time.tv_sec;
64202 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
64203 + if (have_same_root(current, p)) {
64204 + goto allow;
64205 + } else {
64206 + read_unlock(&tasklist_lock);
64207 + rcu_read_unlock();
64208 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64209 + return 0;
64210 + }
64211 + }
64212 + /* creator exited, pid reuse, fall through to next check */
64213 + }
64214 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
64215 + if (unlikely(!have_same_root(current, p))) {
64216 + read_unlock(&tasklist_lock);
64217 + rcu_read_unlock();
64218 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64219 + return 0;
64220 + }
64221 + }
64222 +
64223 +allow:
64224 + read_unlock(&tasklist_lock);
64225 + rcu_read_unlock();
64226 +#endif
64227 + return 1;
64228 +}
64229 +
64230 +void
64231 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
64232 +{
64233 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64234 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
64235 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
64236 +#endif
64237 + return;
64238 +}
64239 +
64240 +int
64241 +gr_handle_chroot_mknod(const struct dentry *dentry,
64242 + const struct vfsmount *mnt, const int mode)
64243 +{
64244 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64245 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
64246 + proc_is_chrooted(current)) {
64247 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
64248 + return -EPERM;
64249 + }
64250 +#endif
64251 + return 0;
64252 +}
64253 +
64254 +int
64255 +gr_handle_chroot_mount(const struct dentry *dentry,
64256 + const struct vfsmount *mnt, const char *dev_name)
64257 +{
64258 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64259 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
64260 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
64261 + return -EPERM;
64262 + }
64263 +#endif
64264 + return 0;
64265 +}
64266 +
64267 +int
64268 +gr_handle_chroot_pivot(void)
64269 +{
64270 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64271 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
64272 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
64273 + return -EPERM;
64274 + }
64275 +#endif
64276 + return 0;
64277 +}
64278 +
64279 +int
64280 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
64281 +{
64282 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64283 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
64284 + !gr_is_outside_chroot(dentry, mnt)) {
64285 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
64286 + return -EPERM;
64287 + }
64288 +#endif
64289 + return 0;
64290 +}
64291 +
64292 +extern const char *captab_log[];
64293 +extern int captab_log_entries;
64294 +
64295 +int
64296 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, 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 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
64303 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
64304 + }
64305 + return 0;
64306 + }
64307 + }
64308 +#endif
64309 + return 1;
64310 +}
64311 +
64312 +int
64313 +gr_chroot_is_capable(const int cap)
64314 +{
64315 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64316 + return gr_task_chroot_is_capable(current, current_cred(), cap);
64317 +#endif
64318 + return 1;
64319 +}
64320 +
64321 +int
64322 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
64323 +{
64324 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64325 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64326 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64327 + if (cap_raised(chroot_caps, cap)) {
64328 + return 0;
64329 + }
64330 + }
64331 +#endif
64332 + return 1;
64333 +}
64334 +
64335 +int
64336 +gr_chroot_is_capable_nolog(const int cap)
64337 +{
64338 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64339 + return gr_task_chroot_is_capable_nolog(current, cap);
64340 +#endif
64341 + return 1;
64342 +}
64343 +
64344 +int
64345 +gr_handle_chroot_sysctl(const int op)
64346 +{
64347 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64348 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
64349 + proc_is_chrooted(current))
64350 + return -EACCES;
64351 +#endif
64352 + return 0;
64353 +}
64354 +
64355 +void
64356 +gr_handle_chroot_chdir(struct path *path)
64357 +{
64358 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64359 + if (grsec_enable_chroot_chdir)
64360 + set_fs_pwd(current->fs, path);
64361 +#endif
64362 + return;
64363 +}
64364 +
64365 +int
64366 +gr_handle_chroot_chmod(const struct dentry *dentry,
64367 + const struct vfsmount *mnt, const int mode)
64368 +{
64369 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64370 + /* allow chmod +s on directories, but not files */
64371 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
64372 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
64373 + proc_is_chrooted(current)) {
64374 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
64375 + return -EPERM;
64376 + }
64377 +#endif
64378 + return 0;
64379 +}
64380 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
64381 new file mode 100644
64382 index 0000000..207d409
64383 --- /dev/null
64384 +++ b/grsecurity/grsec_disabled.c
64385 @@ -0,0 +1,434 @@
64386 +#include <linux/kernel.h>
64387 +#include <linux/module.h>
64388 +#include <linux/sched.h>
64389 +#include <linux/file.h>
64390 +#include <linux/fs.h>
64391 +#include <linux/kdev_t.h>
64392 +#include <linux/net.h>
64393 +#include <linux/in.h>
64394 +#include <linux/ip.h>
64395 +#include <linux/skbuff.h>
64396 +#include <linux/sysctl.h>
64397 +
64398 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
64399 +void
64400 +pax_set_initial_flags(struct linux_binprm *bprm)
64401 +{
64402 + return;
64403 +}
64404 +#endif
64405 +
64406 +#ifdef CONFIG_SYSCTL
64407 +__u32
64408 +gr_handle_sysctl(const struct ctl_table * table, const int op)
64409 +{
64410 + return 0;
64411 +}
64412 +#endif
64413 +
64414 +#ifdef CONFIG_TASKSTATS
64415 +int gr_is_taskstats_denied(int pid)
64416 +{
64417 + return 0;
64418 +}
64419 +#endif
64420 +
64421 +int
64422 +gr_acl_is_enabled(void)
64423 +{
64424 + return 0;
64425 +}
64426 +
64427 +void
64428 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
64429 +{
64430 + return;
64431 +}
64432 +
64433 +int
64434 +gr_handle_rawio(const struct inode *inode)
64435 +{
64436 + return 0;
64437 +}
64438 +
64439 +void
64440 +gr_acl_handle_psacct(struct task_struct *task, const long code)
64441 +{
64442 + return;
64443 +}
64444 +
64445 +int
64446 +gr_handle_ptrace(struct task_struct *task, const long request)
64447 +{
64448 + return 0;
64449 +}
64450 +
64451 +int
64452 +gr_handle_proc_ptrace(struct task_struct *task)
64453 +{
64454 + return 0;
64455 +}
64456 +
64457 +int
64458 +gr_set_acls(const int type)
64459 +{
64460 + return 0;
64461 +}
64462 +
64463 +int
64464 +gr_check_hidden_task(const struct task_struct *tsk)
64465 +{
64466 + return 0;
64467 +}
64468 +
64469 +int
64470 +gr_check_protected_task(const struct task_struct *task)
64471 +{
64472 + return 0;
64473 +}
64474 +
64475 +int
64476 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64477 +{
64478 + return 0;
64479 +}
64480 +
64481 +void
64482 +gr_copy_label(struct task_struct *tsk)
64483 +{
64484 + return;
64485 +}
64486 +
64487 +void
64488 +gr_set_pax_flags(struct task_struct *task)
64489 +{
64490 + return;
64491 +}
64492 +
64493 +int
64494 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64495 + const int unsafe_share)
64496 +{
64497 + return 0;
64498 +}
64499 +
64500 +void
64501 +gr_handle_delete(const ino_t ino, const dev_t dev)
64502 +{
64503 + return;
64504 +}
64505 +
64506 +void
64507 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
64508 +{
64509 + return;
64510 +}
64511 +
64512 +void
64513 +gr_handle_crash(struct task_struct *task, const int sig)
64514 +{
64515 + return;
64516 +}
64517 +
64518 +int
64519 +gr_check_crash_exec(const struct file *filp)
64520 +{
64521 + return 0;
64522 +}
64523 +
64524 +int
64525 +gr_check_crash_uid(const kuid_t uid)
64526 +{
64527 + return 0;
64528 +}
64529 +
64530 +void
64531 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
64532 + struct dentry *old_dentry,
64533 + struct dentry *new_dentry,
64534 + struct vfsmount *mnt, const __u8 replace)
64535 +{
64536 + return;
64537 +}
64538 +
64539 +int
64540 +gr_search_socket(const int family, const int type, const int protocol)
64541 +{
64542 + return 1;
64543 +}
64544 +
64545 +int
64546 +gr_search_connectbind(const int mode, const struct socket *sock,
64547 + const struct sockaddr_in *addr)
64548 +{
64549 + return 0;
64550 +}
64551 +
64552 +void
64553 +gr_handle_alertkill(struct task_struct *task)
64554 +{
64555 + return;
64556 +}
64557 +
64558 +__u32
64559 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
64560 +{
64561 + return 1;
64562 +}
64563 +
64564 +__u32
64565 +gr_acl_handle_hidden_file(const struct dentry * dentry,
64566 + const struct vfsmount * mnt)
64567 +{
64568 + return 1;
64569 +}
64570 +
64571 +__u32
64572 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
64573 + int acc_mode)
64574 +{
64575 + return 1;
64576 +}
64577 +
64578 +__u32
64579 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
64580 +{
64581 + return 1;
64582 +}
64583 +
64584 +__u32
64585 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
64586 +{
64587 + return 1;
64588 +}
64589 +
64590 +int
64591 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
64592 + unsigned int *vm_flags)
64593 +{
64594 + return 1;
64595 +}
64596 +
64597 +__u32
64598 +gr_acl_handle_truncate(const struct dentry * dentry,
64599 + const struct vfsmount * mnt)
64600 +{
64601 + return 1;
64602 +}
64603 +
64604 +__u32
64605 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
64606 +{
64607 + return 1;
64608 +}
64609 +
64610 +__u32
64611 +gr_acl_handle_access(const struct dentry * dentry,
64612 + const struct vfsmount * mnt, const int fmode)
64613 +{
64614 + return 1;
64615 +}
64616 +
64617 +__u32
64618 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
64619 + umode_t *mode)
64620 +{
64621 + return 1;
64622 +}
64623 +
64624 +__u32
64625 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
64626 +{
64627 + return 1;
64628 +}
64629 +
64630 +__u32
64631 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
64632 +{
64633 + return 1;
64634 +}
64635 +
64636 +void
64637 +grsecurity_init(void)
64638 +{
64639 + return;
64640 +}
64641 +
64642 +umode_t gr_acl_umask(void)
64643 +{
64644 + return 0;
64645 +}
64646 +
64647 +__u32
64648 +gr_acl_handle_mknod(const struct dentry * new_dentry,
64649 + const struct dentry * parent_dentry,
64650 + const struct vfsmount * parent_mnt,
64651 + const int mode)
64652 +{
64653 + return 1;
64654 +}
64655 +
64656 +__u32
64657 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
64658 + const struct dentry * parent_dentry,
64659 + const struct vfsmount * parent_mnt)
64660 +{
64661 + return 1;
64662 +}
64663 +
64664 +__u32
64665 +gr_acl_handle_symlink(const struct dentry * new_dentry,
64666 + const struct dentry * parent_dentry,
64667 + const struct vfsmount * parent_mnt, const struct filename *from)
64668 +{
64669 + return 1;
64670 +}
64671 +
64672 +__u32
64673 +gr_acl_handle_link(const struct dentry * new_dentry,
64674 + const struct dentry * parent_dentry,
64675 + const struct vfsmount * parent_mnt,
64676 + const struct dentry * old_dentry,
64677 + const struct vfsmount * old_mnt, const struct filename *to)
64678 +{
64679 + return 1;
64680 +}
64681 +
64682 +int
64683 +gr_acl_handle_rename(const struct dentry *new_dentry,
64684 + const struct dentry *parent_dentry,
64685 + const struct vfsmount *parent_mnt,
64686 + const struct dentry *old_dentry,
64687 + const struct inode *old_parent_inode,
64688 + const struct vfsmount *old_mnt, const struct filename *newname)
64689 +{
64690 + return 0;
64691 +}
64692 +
64693 +int
64694 +gr_acl_handle_filldir(const struct file *file, const char *name,
64695 + const int namelen, const ino_t ino)
64696 +{
64697 + return 1;
64698 +}
64699 +
64700 +int
64701 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64702 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
64703 +{
64704 + return 1;
64705 +}
64706 +
64707 +int
64708 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
64709 +{
64710 + return 0;
64711 +}
64712 +
64713 +int
64714 +gr_search_accept(const struct socket *sock)
64715 +{
64716 + return 0;
64717 +}
64718 +
64719 +int
64720 +gr_search_listen(const struct socket *sock)
64721 +{
64722 + return 0;
64723 +}
64724 +
64725 +int
64726 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
64727 +{
64728 + return 0;
64729 +}
64730 +
64731 +__u32
64732 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
64733 +{
64734 + return 1;
64735 +}
64736 +
64737 +__u32
64738 +gr_acl_handle_creat(const struct dentry * dentry,
64739 + const struct dentry * p_dentry,
64740 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
64741 + const int imode)
64742 +{
64743 + return 1;
64744 +}
64745 +
64746 +void
64747 +gr_acl_handle_exit(void)
64748 +{
64749 + return;
64750 +}
64751 +
64752 +int
64753 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
64754 +{
64755 + return 1;
64756 +}
64757 +
64758 +void
64759 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
64760 +{
64761 + return;
64762 +}
64763 +
64764 +int
64765 +gr_acl_handle_procpidmem(const struct task_struct *task)
64766 +{
64767 + return 0;
64768 +}
64769 +
64770 +int
64771 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
64772 +{
64773 + return 0;
64774 +}
64775 +
64776 +int
64777 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
64778 +{
64779 + return 0;
64780 +}
64781 +
64782 +void
64783 +gr_set_kernel_label(struct task_struct *task)
64784 +{
64785 + return;
64786 +}
64787 +
64788 +int
64789 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64790 +{
64791 + return 0;
64792 +}
64793 +
64794 +int
64795 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64796 +{
64797 + return 0;
64798 +}
64799 +
64800 +int gr_acl_enable_at_secure(void)
64801 +{
64802 + return 0;
64803 +}
64804 +
64805 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
64806 +{
64807 + return dentry->d_inode->i_sb->s_dev;
64808 +}
64809 +
64810 +void gr_put_exec_file(struct task_struct *task)
64811 +{
64812 + return;
64813 +}
64814 +
64815 +EXPORT_SYMBOL(gr_set_kernel_label);
64816 +#ifdef CONFIG_SECURITY
64817 +EXPORT_SYMBOL(gr_check_user_change);
64818 +EXPORT_SYMBOL(gr_check_group_change);
64819 +#endif
64820 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
64821 new file mode 100644
64822 index 0000000..387032b
64823 --- /dev/null
64824 +++ b/grsecurity/grsec_exec.c
64825 @@ -0,0 +1,187 @@
64826 +#include <linux/kernel.h>
64827 +#include <linux/sched.h>
64828 +#include <linux/file.h>
64829 +#include <linux/binfmts.h>
64830 +#include <linux/fs.h>
64831 +#include <linux/types.h>
64832 +#include <linux/grdefs.h>
64833 +#include <linux/grsecurity.h>
64834 +#include <linux/grinternal.h>
64835 +#include <linux/capability.h>
64836 +#include <linux/module.h>
64837 +#include <linux/compat.h>
64838 +
64839 +#include <asm/uaccess.h>
64840 +
64841 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64842 +static char gr_exec_arg_buf[132];
64843 +static DEFINE_MUTEX(gr_exec_arg_mutex);
64844 +#endif
64845 +
64846 +struct user_arg_ptr {
64847 +#ifdef CONFIG_COMPAT
64848 + bool is_compat;
64849 +#endif
64850 + union {
64851 + const char __user *const __user *native;
64852 +#ifdef CONFIG_COMPAT
64853 + const compat_uptr_t __user *compat;
64854 +#endif
64855 + } ptr;
64856 +};
64857 +
64858 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
64859 +
64860 +void
64861 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
64862 +{
64863 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64864 + char *grarg = gr_exec_arg_buf;
64865 + unsigned int i, x, execlen = 0;
64866 + char c;
64867 +
64868 + if (!((grsec_enable_execlog && grsec_enable_group &&
64869 + in_group_p(grsec_audit_gid))
64870 + || (grsec_enable_execlog && !grsec_enable_group)))
64871 + return;
64872 +
64873 + mutex_lock(&gr_exec_arg_mutex);
64874 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
64875 +
64876 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
64877 + const char __user *p;
64878 + unsigned int len;
64879 +
64880 + p = get_user_arg_ptr(argv, i);
64881 + if (IS_ERR(p))
64882 + goto log;
64883 +
64884 + len = strnlen_user(p, 128 - execlen);
64885 + if (len > 128 - execlen)
64886 + len = 128 - execlen;
64887 + else if (len > 0)
64888 + len--;
64889 + if (copy_from_user(grarg + execlen, p, len))
64890 + goto log;
64891 +
64892 + /* rewrite unprintable characters */
64893 + for (x = 0; x < len; x++) {
64894 + c = *(grarg + execlen + x);
64895 + if (c < 32 || c > 126)
64896 + *(grarg + execlen + x) = ' ';
64897 + }
64898 +
64899 + execlen += len;
64900 + *(grarg + execlen) = ' ';
64901 + *(grarg + execlen + 1) = '\0';
64902 + execlen++;
64903 + }
64904 +
64905 + log:
64906 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
64907 + bprm->file->f_path.mnt, grarg);
64908 + mutex_unlock(&gr_exec_arg_mutex);
64909 +#endif
64910 + return;
64911 +}
64912 +
64913 +#ifdef CONFIG_GRKERNSEC
64914 +extern int gr_acl_is_capable(const int cap);
64915 +extern int gr_acl_is_capable_nolog(const int cap);
64916 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64917 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
64918 +extern int gr_chroot_is_capable(const int cap);
64919 +extern int gr_chroot_is_capable_nolog(const int cap);
64920 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64921 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
64922 +#endif
64923 +
64924 +const char *captab_log[] = {
64925 + "CAP_CHOWN",
64926 + "CAP_DAC_OVERRIDE",
64927 + "CAP_DAC_READ_SEARCH",
64928 + "CAP_FOWNER",
64929 + "CAP_FSETID",
64930 + "CAP_KILL",
64931 + "CAP_SETGID",
64932 + "CAP_SETUID",
64933 + "CAP_SETPCAP",
64934 + "CAP_LINUX_IMMUTABLE",
64935 + "CAP_NET_BIND_SERVICE",
64936 + "CAP_NET_BROADCAST",
64937 + "CAP_NET_ADMIN",
64938 + "CAP_NET_RAW",
64939 + "CAP_IPC_LOCK",
64940 + "CAP_IPC_OWNER",
64941 + "CAP_SYS_MODULE",
64942 + "CAP_SYS_RAWIO",
64943 + "CAP_SYS_CHROOT",
64944 + "CAP_SYS_PTRACE",
64945 + "CAP_SYS_PACCT",
64946 + "CAP_SYS_ADMIN",
64947 + "CAP_SYS_BOOT",
64948 + "CAP_SYS_NICE",
64949 + "CAP_SYS_RESOURCE",
64950 + "CAP_SYS_TIME",
64951 + "CAP_SYS_TTY_CONFIG",
64952 + "CAP_MKNOD",
64953 + "CAP_LEASE",
64954 + "CAP_AUDIT_WRITE",
64955 + "CAP_AUDIT_CONTROL",
64956 + "CAP_SETFCAP",
64957 + "CAP_MAC_OVERRIDE",
64958 + "CAP_MAC_ADMIN",
64959 + "CAP_SYSLOG",
64960 + "CAP_WAKE_ALARM"
64961 +};
64962 +
64963 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
64964 +
64965 +int gr_is_capable(const int cap)
64966 +{
64967 +#ifdef CONFIG_GRKERNSEC
64968 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
64969 + return 1;
64970 + return 0;
64971 +#else
64972 + return 1;
64973 +#endif
64974 +}
64975 +
64976 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64977 +{
64978 +#ifdef CONFIG_GRKERNSEC
64979 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
64980 + return 1;
64981 + return 0;
64982 +#else
64983 + return 1;
64984 +#endif
64985 +}
64986 +
64987 +int gr_is_capable_nolog(const int cap)
64988 +{
64989 +#ifdef CONFIG_GRKERNSEC
64990 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
64991 + return 1;
64992 + return 0;
64993 +#else
64994 + return 1;
64995 +#endif
64996 +}
64997 +
64998 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
64999 +{
65000 +#ifdef CONFIG_GRKERNSEC
65001 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
65002 + return 1;
65003 + return 0;
65004 +#else
65005 + return 1;
65006 +#endif
65007 +}
65008 +
65009 +EXPORT_SYMBOL(gr_is_capable);
65010 +EXPORT_SYMBOL(gr_is_capable_nolog);
65011 +EXPORT_SYMBOL(gr_task_is_capable);
65012 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
65013 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
65014 new file mode 100644
65015 index 0000000..06cc6ea
65016 --- /dev/null
65017 +++ b/grsecurity/grsec_fifo.c
65018 @@ -0,0 +1,24 @@
65019 +#include <linux/kernel.h>
65020 +#include <linux/sched.h>
65021 +#include <linux/fs.h>
65022 +#include <linux/file.h>
65023 +#include <linux/grinternal.h>
65024 +
65025 +int
65026 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
65027 + const struct dentry *dir, const int flag, const int acc_mode)
65028 +{
65029 +#ifdef CONFIG_GRKERNSEC_FIFO
65030 + const struct cred *cred = current_cred();
65031 +
65032 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
65033 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
65034 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
65035 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
65036 + if (!inode_permission(dentry->d_inode, acc_mode))
65037 + 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));
65038 + return -EACCES;
65039 + }
65040 +#endif
65041 + return 0;
65042 +}
65043 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
65044 new file mode 100644
65045 index 0000000..8ca18bf
65046 --- /dev/null
65047 +++ b/grsecurity/grsec_fork.c
65048 @@ -0,0 +1,23 @@
65049 +#include <linux/kernel.h>
65050 +#include <linux/sched.h>
65051 +#include <linux/grsecurity.h>
65052 +#include <linux/grinternal.h>
65053 +#include <linux/errno.h>
65054 +
65055 +void
65056 +gr_log_forkfail(const int retval)
65057 +{
65058 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65059 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
65060 + switch (retval) {
65061 + case -EAGAIN:
65062 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
65063 + break;
65064 + case -ENOMEM:
65065 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
65066 + break;
65067 + }
65068 + }
65069 +#endif
65070 + return;
65071 +}
65072 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
65073 new file mode 100644
65074 index 0000000..a862e9f
65075 --- /dev/null
65076 +++ b/grsecurity/grsec_init.c
65077 @@ -0,0 +1,283 @@
65078 +#include <linux/kernel.h>
65079 +#include <linux/sched.h>
65080 +#include <linux/mm.h>
65081 +#include <linux/gracl.h>
65082 +#include <linux/slab.h>
65083 +#include <linux/vmalloc.h>
65084 +#include <linux/percpu.h>
65085 +#include <linux/module.h>
65086 +
65087 +int grsec_enable_ptrace_readexec;
65088 +int grsec_enable_setxid;
65089 +int grsec_enable_symlinkown;
65090 +kgid_t grsec_symlinkown_gid;
65091 +int grsec_enable_brute;
65092 +int grsec_enable_link;
65093 +int grsec_enable_dmesg;
65094 +int grsec_enable_harden_ptrace;
65095 +int grsec_enable_fifo;
65096 +int grsec_enable_execlog;
65097 +int grsec_enable_signal;
65098 +int grsec_enable_forkfail;
65099 +int grsec_enable_audit_ptrace;
65100 +int grsec_enable_time;
65101 +int grsec_enable_audit_textrel;
65102 +int grsec_enable_group;
65103 +kgid_t grsec_audit_gid;
65104 +int grsec_enable_chdir;
65105 +int grsec_enable_mount;
65106 +int grsec_enable_rofs;
65107 +int grsec_enable_chroot_findtask;
65108 +int grsec_enable_chroot_mount;
65109 +int grsec_enable_chroot_shmat;
65110 +int grsec_enable_chroot_fchdir;
65111 +int grsec_enable_chroot_double;
65112 +int grsec_enable_chroot_pivot;
65113 +int grsec_enable_chroot_chdir;
65114 +int grsec_enable_chroot_chmod;
65115 +int grsec_enable_chroot_mknod;
65116 +int grsec_enable_chroot_nice;
65117 +int grsec_enable_chroot_execlog;
65118 +int grsec_enable_chroot_caps;
65119 +int grsec_enable_chroot_sysctl;
65120 +int grsec_enable_chroot_unix;
65121 +int grsec_enable_tpe;
65122 +kgid_t grsec_tpe_gid;
65123 +int grsec_enable_blackhole;
65124 +#ifdef CONFIG_IPV6_MODULE
65125 +EXPORT_SYMBOL(grsec_enable_blackhole);
65126 +#endif
65127 +int grsec_lastack_retries;
65128 +int grsec_enable_tpe_all;
65129 +int grsec_enable_tpe_invert;
65130 +int grsec_enable_socket_all;
65131 +kgid_t grsec_socket_all_gid;
65132 +int grsec_enable_socket_client;
65133 +kgid_t grsec_socket_client_gid;
65134 +int grsec_enable_socket_server;
65135 +kgid_t grsec_socket_server_gid;
65136 +int grsec_resource_logging;
65137 +int grsec_disable_privio;
65138 +int grsec_enable_log_rwxmaps;
65139 +int grsec_lock;
65140 +
65141 +DEFINE_SPINLOCK(grsec_alert_lock);
65142 +unsigned long grsec_alert_wtime = 0;
65143 +unsigned long grsec_alert_fyet = 0;
65144 +
65145 +DEFINE_SPINLOCK(grsec_audit_lock);
65146 +
65147 +DEFINE_RWLOCK(grsec_exec_file_lock);
65148 +
65149 +char *gr_shared_page[4];
65150 +
65151 +char *gr_alert_log_fmt;
65152 +char *gr_audit_log_fmt;
65153 +char *gr_alert_log_buf;
65154 +char *gr_audit_log_buf;
65155 +
65156 +extern struct gr_arg *gr_usermode;
65157 +extern unsigned char *gr_system_salt;
65158 +extern unsigned char *gr_system_sum;
65159 +
65160 +void __init
65161 +grsecurity_init(void)
65162 +{
65163 + int j;
65164 + /* create the per-cpu shared pages */
65165 +
65166 +#ifdef CONFIG_X86
65167 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
65168 +#endif
65169 +
65170 + for (j = 0; j < 4; j++) {
65171 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
65172 + if (gr_shared_page[j] == NULL) {
65173 + panic("Unable to allocate grsecurity shared page");
65174 + return;
65175 + }
65176 + }
65177 +
65178 + /* allocate log buffers */
65179 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
65180 + if (!gr_alert_log_fmt) {
65181 + panic("Unable to allocate grsecurity alert log format buffer");
65182 + return;
65183 + }
65184 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
65185 + if (!gr_audit_log_fmt) {
65186 + panic("Unable to allocate grsecurity audit log format buffer");
65187 + return;
65188 + }
65189 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65190 + if (!gr_alert_log_buf) {
65191 + panic("Unable to allocate grsecurity alert log buffer");
65192 + return;
65193 + }
65194 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65195 + if (!gr_audit_log_buf) {
65196 + panic("Unable to allocate grsecurity audit log buffer");
65197 + return;
65198 + }
65199 +
65200 + /* allocate memory for authentication structure */
65201 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
65202 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
65203 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
65204 +
65205 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
65206 + panic("Unable to allocate grsecurity authentication structure");
65207 + return;
65208 + }
65209 +
65210 +
65211 +#ifdef CONFIG_GRKERNSEC_IO
65212 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
65213 + grsec_disable_privio = 1;
65214 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65215 + grsec_disable_privio = 1;
65216 +#else
65217 + grsec_disable_privio = 0;
65218 +#endif
65219 +#endif
65220 +
65221 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65222 + /* for backward compatibility, tpe_invert always defaults to on if
65223 + enabled in the kernel
65224 + */
65225 + grsec_enable_tpe_invert = 1;
65226 +#endif
65227 +
65228 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65229 +#ifndef CONFIG_GRKERNSEC_SYSCTL
65230 + grsec_lock = 1;
65231 +#endif
65232 +
65233 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65234 + grsec_enable_audit_textrel = 1;
65235 +#endif
65236 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65237 + grsec_enable_log_rwxmaps = 1;
65238 +#endif
65239 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
65240 + grsec_enable_group = 1;
65241 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
65242 +#endif
65243 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65244 + grsec_enable_ptrace_readexec = 1;
65245 +#endif
65246 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
65247 + grsec_enable_chdir = 1;
65248 +#endif
65249 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65250 + grsec_enable_harden_ptrace = 1;
65251 +#endif
65252 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65253 + grsec_enable_mount = 1;
65254 +#endif
65255 +#ifdef CONFIG_GRKERNSEC_LINK
65256 + grsec_enable_link = 1;
65257 +#endif
65258 +#ifdef CONFIG_GRKERNSEC_BRUTE
65259 + grsec_enable_brute = 1;
65260 +#endif
65261 +#ifdef CONFIG_GRKERNSEC_DMESG
65262 + grsec_enable_dmesg = 1;
65263 +#endif
65264 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65265 + grsec_enable_blackhole = 1;
65266 + grsec_lastack_retries = 4;
65267 +#endif
65268 +#ifdef CONFIG_GRKERNSEC_FIFO
65269 + grsec_enable_fifo = 1;
65270 +#endif
65271 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65272 + grsec_enable_execlog = 1;
65273 +#endif
65274 +#ifdef CONFIG_GRKERNSEC_SETXID
65275 + grsec_enable_setxid = 1;
65276 +#endif
65277 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65278 + grsec_enable_signal = 1;
65279 +#endif
65280 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65281 + grsec_enable_forkfail = 1;
65282 +#endif
65283 +#ifdef CONFIG_GRKERNSEC_TIME
65284 + grsec_enable_time = 1;
65285 +#endif
65286 +#ifdef CONFIG_GRKERNSEC_RESLOG
65287 + grsec_resource_logging = 1;
65288 +#endif
65289 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
65290 + grsec_enable_chroot_findtask = 1;
65291 +#endif
65292 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
65293 + grsec_enable_chroot_unix = 1;
65294 +#endif
65295 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
65296 + grsec_enable_chroot_mount = 1;
65297 +#endif
65298 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
65299 + grsec_enable_chroot_fchdir = 1;
65300 +#endif
65301 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
65302 + grsec_enable_chroot_shmat = 1;
65303 +#endif
65304 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65305 + grsec_enable_audit_ptrace = 1;
65306 +#endif
65307 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
65308 + grsec_enable_chroot_double = 1;
65309 +#endif
65310 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
65311 + grsec_enable_chroot_pivot = 1;
65312 +#endif
65313 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
65314 + grsec_enable_chroot_chdir = 1;
65315 +#endif
65316 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
65317 + grsec_enable_chroot_chmod = 1;
65318 +#endif
65319 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
65320 + grsec_enable_chroot_mknod = 1;
65321 +#endif
65322 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
65323 + grsec_enable_chroot_nice = 1;
65324 +#endif
65325 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
65326 + grsec_enable_chroot_execlog = 1;
65327 +#endif
65328 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
65329 + grsec_enable_chroot_caps = 1;
65330 +#endif
65331 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
65332 + grsec_enable_chroot_sysctl = 1;
65333 +#endif
65334 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65335 + grsec_enable_symlinkown = 1;
65336 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
65337 +#endif
65338 +#ifdef CONFIG_GRKERNSEC_TPE
65339 + grsec_enable_tpe = 1;
65340 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
65341 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
65342 + grsec_enable_tpe_all = 1;
65343 +#endif
65344 +#endif
65345 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65346 + grsec_enable_socket_all = 1;
65347 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
65348 +#endif
65349 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65350 + grsec_enable_socket_client = 1;
65351 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
65352 +#endif
65353 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65354 + grsec_enable_socket_server = 1;
65355 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
65356 +#endif
65357 +#endif
65358 +
65359 + return;
65360 +}
65361 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
65362 new file mode 100644
65363 index 0000000..5e05e20
65364 --- /dev/null
65365 +++ b/grsecurity/grsec_link.c
65366 @@ -0,0 +1,58 @@
65367 +#include <linux/kernel.h>
65368 +#include <linux/sched.h>
65369 +#include <linux/fs.h>
65370 +#include <linux/file.h>
65371 +#include <linux/grinternal.h>
65372 +
65373 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
65374 +{
65375 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65376 + const struct inode *link_inode = link->dentry->d_inode;
65377 +
65378 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
65379 + /* ignore root-owned links, e.g. /proc/self */
65380 + gr_is_global_nonroot(link_inode->i_uid) && target &&
65381 + !uid_eq(link_inode->i_uid, target->i_uid)) {
65382 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
65383 + return 1;
65384 + }
65385 +#endif
65386 + return 0;
65387 +}
65388 +
65389 +int
65390 +gr_handle_follow_link(const struct inode *parent,
65391 + const struct inode *inode,
65392 + const struct dentry *dentry, const struct vfsmount *mnt)
65393 +{
65394 +#ifdef CONFIG_GRKERNSEC_LINK
65395 + const struct cred *cred = current_cred();
65396 +
65397 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
65398 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
65399 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
65400 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
65401 + return -EACCES;
65402 + }
65403 +#endif
65404 + return 0;
65405 +}
65406 +
65407 +int
65408 +gr_handle_hardlink(const struct dentry *dentry,
65409 + const struct vfsmount *mnt,
65410 + struct inode *inode, const int mode, const struct filename *to)
65411 +{
65412 +#ifdef CONFIG_GRKERNSEC_LINK
65413 + const struct cred *cred = current_cred();
65414 +
65415 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
65416 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
65417 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
65418 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
65419 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
65420 + return -EPERM;
65421 + }
65422 +#endif
65423 + return 0;
65424 +}
65425 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
65426 new file mode 100644
65427 index 0000000..7c06085
65428 --- /dev/null
65429 +++ b/grsecurity/grsec_log.c
65430 @@ -0,0 +1,326 @@
65431 +#include <linux/kernel.h>
65432 +#include <linux/sched.h>
65433 +#include <linux/file.h>
65434 +#include <linux/tty.h>
65435 +#include <linux/fs.h>
65436 +#include <linux/grinternal.h>
65437 +
65438 +#ifdef CONFIG_TREE_PREEMPT_RCU
65439 +#define DISABLE_PREEMPT() preempt_disable()
65440 +#define ENABLE_PREEMPT() preempt_enable()
65441 +#else
65442 +#define DISABLE_PREEMPT()
65443 +#define ENABLE_PREEMPT()
65444 +#endif
65445 +
65446 +#define BEGIN_LOCKS(x) \
65447 + DISABLE_PREEMPT(); \
65448 + rcu_read_lock(); \
65449 + read_lock(&tasklist_lock); \
65450 + read_lock(&grsec_exec_file_lock); \
65451 + if (x != GR_DO_AUDIT) \
65452 + spin_lock(&grsec_alert_lock); \
65453 + else \
65454 + spin_lock(&grsec_audit_lock)
65455 +
65456 +#define END_LOCKS(x) \
65457 + if (x != GR_DO_AUDIT) \
65458 + spin_unlock(&grsec_alert_lock); \
65459 + else \
65460 + spin_unlock(&grsec_audit_lock); \
65461 + read_unlock(&grsec_exec_file_lock); \
65462 + read_unlock(&tasklist_lock); \
65463 + rcu_read_unlock(); \
65464 + ENABLE_PREEMPT(); \
65465 + if (x == GR_DONT_AUDIT) \
65466 + gr_handle_alertkill(current)
65467 +
65468 +enum {
65469 + FLOODING,
65470 + NO_FLOODING
65471 +};
65472 +
65473 +extern char *gr_alert_log_fmt;
65474 +extern char *gr_audit_log_fmt;
65475 +extern char *gr_alert_log_buf;
65476 +extern char *gr_audit_log_buf;
65477 +
65478 +static int gr_log_start(int audit)
65479 +{
65480 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
65481 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
65482 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65483 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
65484 + unsigned long curr_secs = get_seconds();
65485 +
65486 + if (audit == GR_DO_AUDIT)
65487 + goto set_fmt;
65488 +
65489 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
65490 + grsec_alert_wtime = curr_secs;
65491 + grsec_alert_fyet = 0;
65492 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
65493 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
65494 + grsec_alert_fyet++;
65495 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
65496 + grsec_alert_wtime = curr_secs;
65497 + grsec_alert_fyet++;
65498 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
65499 + return FLOODING;
65500 + }
65501 + else return FLOODING;
65502 +
65503 +set_fmt:
65504 +#endif
65505 + memset(buf, 0, PAGE_SIZE);
65506 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
65507 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
65508 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65509 + } else if (current->signal->curr_ip) {
65510 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
65511 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
65512 + } else if (gr_acl_is_enabled()) {
65513 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
65514 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65515 + } else {
65516 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
65517 + strcpy(buf, fmt);
65518 + }
65519 +
65520 + return NO_FLOODING;
65521 +}
65522 +
65523 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65524 + __attribute__ ((format (printf, 2, 0)));
65525 +
65526 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65527 +{
65528 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65529 + unsigned int len = strlen(buf);
65530 +
65531 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65532 +
65533 + return;
65534 +}
65535 +
65536 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65537 + __attribute__ ((format (printf, 2, 3)));
65538 +
65539 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65540 +{
65541 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65542 + unsigned int len = strlen(buf);
65543 + va_list ap;
65544 +
65545 + va_start(ap, msg);
65546 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65547 + va_end(ap);
65548 +
65549 + return;
65550 +}
65551 +
65552 +static void gr_log_end(int audit, int append_default)
65553 +{
65554 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65555 + if (append_default) {
65556 + struct task_struct *task = current;
65557 + struct task_struct *parent = task->real_parent;
65558 + const struct cred *cred = __task_cred(task);
65559 + const struct cred *pcred = __task_cred(parent);
65560 + unsigned int len = strlen(buf);
65561 +
65562 + 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));
65563 + }
65564 +
65565 + printk("%s\n", buf);
65566 +
65567 + return;
65568 +}
65569 +
65570 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
65571 +{
65572 + int logtype;
65573 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
65574 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
65575 + void *voidptr = NULL;
65576 + int num1 = 0, num2 = 0;
65577 + unsigned long ulong1 = 0, ulong2 = 0;
65578 + struct dentry *dentry = NULL;
65579 + struct vfsmount *mnt = NULL;
65580 + struct file *file = NULL;
65581 + struct task_struct *task = NULL;
65582 + const struct cred *cred, *pcred;
65583 + va_list ap;
65584 +
65585 + BEGIN_LOCKS(audit);
65586 + logtype = gr_log_start(audit);
65587 + if (logtype == FLOODING) {
65588 + END_LOCKS(audit);
65589 + return;
65590 + }
65591 + va_start(ap, argtypes);
65592 + switch (argtypes) {
65593 + case GR_TTYSNIFF:
65594 + task = va_arg(ap, struct task_struct *);
65595 + 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));
65596 + break;
65597 + case GR_SYSCTL_HIDDEN:
65598 + str1 = va_arg(ap, char *);
65599 + gr_log_middle_varargs(audit, msg, result, str1);
65600 + break;
65601 + case GR_RBAC:
65602 + dentry = va_arg(ap, struct dentry *);
65603 + mnt = va_arg(ap, struct vfsmount *);
65604 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
65605 + break;
65606 + case GR_RBAC_STR:
65607 + dentry = va_arg(ap, struct dentry *);
65608 + mnt = va_arg(ap, struct vfsmount *);
65609 + str1 = va_arg(ap, char *);
65610 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
65611 + break;
65612 + case GR_STR_RBAC:
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, result, str1, gr_to_filename(dentry, mnt));
65617 + break;
65618 + case GR_RBAC_MODE2:
65619 + dentry = va_arg(ap, struct dentry *);
65620 + mnt = va_arg(ap, struct vfsmount *);
65621 + str1 = va_arg(ap, char *);
65622 + str2 = va_arg(ap, char *);
65623 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
65624 + break;
65625 + case GR_RBAC_MODE3:
65626 + dentry = va_arg(ap, struct dentry *);
65627 + mnt = va_arg(ap, struct vfsmount *);
65628 + str1 = va_arg(ap, char *);
65629 + str2 = va_arg(ap, char *);
65630 + str3 = va_arg(ap, char *);
65631 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
65632 + break;
65633 + case GR_FILENAME:
65634 + dentry = va_arg(ap, struct dentry *);
65635 + mnt = va_arg(ap, struct vfsmount *);
65636 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
65637 + break;
65638 + case GR_STR_FILENAME:
65639 + str1 = va_arg(ap, char *);
65640 + dentry = va_arg(ap, struct dentry *);
65641 + mnt = va_arg(ap, struct vfsmount *);
65642 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
65643 + break;
65644 + case GR_FILENAME_STR:
65645 + dentry = va_arg(ap, struct dentry *);
65646 + mnt = va_arg(ap, struct vfsmount *);
65647 + str1 = va_arg(ap, char *);
65648 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
65649 + break;
65650 + case GR_FILENAME_TWO_INT:
65651 + dentry = va_arg(ap, struct dentry *);
65652 + mnt = va_arg(ap, struct vfsmount *);
65653 + num1 = va_arg(ap, int);
65654 + num2 = va_arg(ap, int);
65655 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
65656 + break;
65657 + case GR_FILENAME_TWO_INT_STR:
65658 + dentry = va_arg(ap, struct dentry *);
65659 + mnt = va_arg(ap, struct vfsmount *);
65660 + num1 = va_arg(ap, int);
65661 + num2 = va_arg(ap, int);
65662 + str1 = va_arg(ap, char *);
65663 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
65664 + break;
65665 + case GR_TEXTREL:
65666 + file = va_arg(ap, struct file *);
65667 + ulong1 = va_arg(ap, unsigned long);
65668 + ulong2 = va_arg(ap, unsigned long);
65669 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
65670 + break;
65671 + case GR_PTRACE:
65672 + task = va_arg(ap, struct task_struct *);
65673 + 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));
65674 + break;
65675 + case GR_RESOURCE:
65676 + task = va_arg(ap, struct task_struct *);
65677 + cred = __task_cred(task);
65678 + pcred = __task_cred(task->real_parent);
65679 + ulong1 = va_arg(ap, unsigned long);
65680 + str1 = va_arg(ap, char *);
65681 + ulong2 = va_arg(ap, unsigned long);
65682 + 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));
65683 + break;
65684 + case GR_CAP:
65685 + task = va_arg(ap, struct task_struct *);
65686 + cred = __task_cred(task);
65687 + pcred = __task_cred(task->real_parent);
65688 + str1 = va_arg(ap, char *);
65689 + 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));
65690 + break;
65691 + case GR_SIG:
65692 + str1 = va_arg(ap, char *);
65693 + voidptr = va_arg(ap, void *);
65694 + gr_log_middle_varargs(audit, msg, str1, voidptr);
65695 + break;
65696 + case GR_SIG2:
65697 + task = va_arg(ap, struct task_struct *);
65698 + cred = __task_cred(task);
65699 + pcred = __task_cred(task->real_parent);
65700 + num1 = va_arg(ap, int);
65701 + 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));
65702 + break;
65703 + case GR_CRASH1:
65704 + task = va_arg(ap, struct task_struct *);
65705 + cred = __task_cred(task);
65706 + pcred = __task_cred(task->real_parent);
65707 + ulong1 = va_arg(ap, unsigned long);
65708 + 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);
65709 + break;
65710 + case GR_CRASH2:
65711 + task = va_arg(ap, struct task_struct *);
65712 + cred = __task_cred(task);
65713 + pcred = __task_cred(task->real_parent);
65714 + ulong1 = va_arg(ap, unsigned long);
65715 + 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);
65716 + break;
65717 + case GR_RWXMAP:
65718 + file = va_arg(ap, struct file *);
65719 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
65720 + break;
65721 + case GR_PSACCT:
65722 + {
65723 + unsigned int wday, cday;
65724 + __u8 whr, chr;
65725 + __u8 wmin, cmin;
65726 + __u8 wsec, csec;
65727 + char cur_tty[64] = { 0 };
65728 + char parent_tty[64] = { 0 };
65729 +
65730 + task = va_arg(ap, struct task_struct *);
65731 + wday = va_arg(ap, unsigned int);
65732 + cday = va_arg(ap, unsigned int);
65733 + whr = va_arg(ap, int);
65734 + chr = va_arg(ap, int);
65735 + wmin = va_arg(ap, int);
65736 + cmin = va_arg(ap, int);
65737 + wsec = va_arg(ap, int);
65738 + csec = va_arg(ap, int);
65739 + ulong1 = va_arg(ap, unsigned long);
65740 + cred = __task_cred(task);
65741 + pcred = __task_cred(task->real_parent);
65742 +
65743 + 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));
65744 + }
65745 + break;
65746 + default:
65747 + gr_log_middle(audit, msg, ap);
65748 + }
65749 + va_end(ap);
65750 + // these don't need DEFAULTSECARGS printed on the end
65751 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
65752 + gr_log_end(audit, 0);
65753 + else
65754 + gr_log_end(audit, 1);
65755 + END_LOCKS(audit);
65756 +}
65757 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
65758 new file mode 100644
65759 index 0000000..f536303
65760 --- /dev/null
65761 +++ b/grsecurity/grsec_mem.c
65762 @@ -0,0 +1,40 @@
65763 +#include <linux/kernel.h>
65764 +#include <linux/sched.h>
65765 +#include <linux/mm.h>
65766 +#include <linux/mman.h>
65767 +#include <linux/grinternal.h>
65768 +
65769 +void
65770 +gr_handle_ioperm(void)
65771 +{
65772 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
65773 + return;
65774 +}
65775 +
65776 +void
65777 +gr_handle_iopl(void)
65778 +{
65779 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
65780 + return;
65781 +}
65782 +
65783 +void
65784 +gr_handle_mem_readwrite(u64 from, u64 to)
65785 +{
65786 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
65787 + return;
65788 +}
65789 +
65790 +void
65791 +gr_handle_vm86(void)
65792 +{
65793 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
65794 + return;
65795 +}
65796 +
65797 +void
65798 +gr_log_badprocpid(const char *entry)
65799 +{
65800 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
65801 + return;
65802 +}
65803 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
65804 new file mode 100644
65805 index 0000000..2131422
65806 --- /dev/null
65807 +++ b/grsecurity/grsec_mount.c
65808 @@ -0,0 +1,62 @@
65809 +#include <linux/kernel.h>
65810 +#include <linux/sched.h>
65811 +#include <linux/mount.h>
65812 +#include <linux/grsecurity.h>
65813 +#include <linux/grinternal.h>
65814 +
65815 +void
65816 +gr_log_remount(const char *devname, const int retval)
65817 +{
65818 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65819 + if (grsec_enable_mount && (retval >= 0))
65820 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
65821 +#endif
65822 + return;
65823 +}
65824 +
65825 +void
65826 +gr_log_unmount(const char *devname, const int retval)
65827 +{
65828 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65829 + if (grsec_enable_mount && (retval >= 0))
65830 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
65831 +#endif
65832 + return;
65833 +}
65834 +
65835 +void
65836 +gr_log_mount(const char *from, const char *to, const int retval)
65837 +{
65838 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65839 + if (grsec_enable_mount && (retval >= 0))
65840 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
65841 +#endif
65842 + return;
65843 +}
65844 +
65845 +int
65846 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
65847 +{
65848 +#ifdef CONFIG_GRKERNSEC_ROFS
65849 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
65850 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
65851 + return -EPERM;
65852 + } else
65853 + return 0;
65854 +#endif
65855 + return 0;
65856 +}
65857 +
65858 +int
65859 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
65860 +{
65861 +#ifdef CONFIG_GRKERNSEC_ROFS
65862 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
65863 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
65864 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
65865 + return -EPERM;
65866 + } else
65867 + return 0;
65868 +#endif
65869 + return 0;
65870 +}
65871 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
65872 new file mode 100644
65873 index 0000000..a3b12a0
65874 --- /dev/null
65875 +++ b/grsecurity/grsec_pax.c
65876 @@ -0,0 +1,36 @@
65877 +#include <linux/kernel.h>
65878 +#include <linux/sched.h>
65879 +#include <linux/mm.h>
65880 +#include <linux/file.h>
65881 +#include <linux/grinternal.h>
65882 +#include <linux/grsecurity.h>
65883 +
65884 +void
65885 +gr_log_textrel(struct vm_area_struct * vma)
65886 +{
65887 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65888 + if (grsec_enable_audit_textrel)
65889 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
65890 +#endif
65891 + return;
65892 +}
65893 +
65894 +void
65895 +gr_log_rwxmmap(struct file *file)
65896 +{
65897 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65898 + if (grsec_enable_log_rwxmaps)
65899 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
65900 +#endif
65901 + return;
65902 +}
65903 +
65904 +void
65905 +gr_log_rwxmprotect(struct file *file)
65906 +{
65907 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65908 + if (grsec_enable_log_rwxmaps)
65909 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
65910 +#endif
65911 + return;
65912 +}
65913 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
65914 new file mode 100644
65915 index 0000000..f7f29aa
65916 --- /dev/null
65917 +++ b/grsecurity/grsec_ptrace.c
65918 @@ -0,0 +1,30 @@
65919 +#include <linux/kernel.h>
65920 +#include <linux/sched.h>
65921 +#include <linux/grinternal.h>
65922 +#include <linux/security.h>
65923 +
65924 +void
65925 +gr_audit_ptrace(struct task_struct *task)
65926 +{
65927 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65928 + if (grsec_enable_audit_ptrace)
65929 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
65930 +#endif
65931 + return;
65932 +}
65933 +
65934 +int
65935 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
65936 +{
65937 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65938 + const struct dentry *dentry = file->f_path.dentry;
65939 + const struct vfsmount *mnt = file->f_path.mnt;
65940 +
65941 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
65942 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
65943 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
65944 + return -EACCES;
65945 + }
65946 +#endif
65947 + return 0;
65948 +}
65949 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
65950 new file mode 100644
65951 index 0000000..e09715a
65952 --- /dev/null
65953 +++ b/grsecurity/grsec_sig.c
65954 @@ -0,0 +1,222 @@
65955 +#include <linux/kernel.h>
65956 +#include <linux/sched.h>
65957 +#include <linux/delay.h>
65958 +#include <linux/grsecurity.h>
65959 +#include <linux/grinternal.h>
65960 +#include <linux/hardirq.h>
65961 +
65962 +char *signames[] = {
65963 + [SIGSEGV] = "Segmentation fault",
65964 + [SIGILL] = "Illegal instruction",
65965 + [SIGABRT] = "Abort",
65966 + [SIGBUS] = "Invalid alignment/Bus error"
65967 +};
65968 +
65969 +void
65970 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
65971 +{
65972 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65973 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
65974 + (sig == SIGABRT) || (sig == SIGBUS))) {
65975 + if (task_pid_nr(t) == task_pid_nr(current)) {
65976 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
65977 + } else {
65978 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
65979 + }
65980 + }
65981 +#endif
65982 + return;
65983 +}
65984 +
65985 +int
65986 +gr_handle_signal(const struct task_struct *p, const int sig)
65987 +{
65988 +#ifdef CONFIG_GRKERNSEC
65989 + /* ignore the 0 signal for protected task checks */
65990 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
65991 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
65992 + return -EPERM;
65993 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
65994 + return -EPERM;
65995 + }
65996 +#endif
65997 + return 0;
65998 +}
65999 +
66000 +#ifdef CONFIG_GRKERNSEC
66001 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
66002 +
66003 +int gr_fake_force_sig(int sig, struct task_struct *t)
66004 +{
66005 + unsigned long int flags;
66006 + int ret, blocked, ignored;
66007 + struct k_sigaction *action;
66008 +
66009 + spin_lock_irqsave(&t->sighand->siglock, flags);
66010 + action = &t->sighand->action[sig-1];
66011 + ignored = action->sa.sa_handler == SIG_IGN;
66012 + blocked = sigismember(&t->blocked, sig);
66013 + if (blocked || ignored) {
66014 + action->sa.sa_handler = SIG_DFL;
66015 + if (blocked) {
66016 + sigdelset(&t->blocked, sig);
66017 + recalc_sigpending_and_wake(t);
66018 + }
66019 + }
66020 + if (action->sa.sa_handler == SIG_DFL)
66021 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
66022 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
66023 +
66024 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
66025 +
66026 + return ret;
66027 +}
66028 +#endif
66029 +
66030 +#ifdef CONFIG_GRKERNSEC_BRUTE
66031 +#define GR_USER_BAN_TIME (15 * 60)
66032 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
66033 +
66034 +static int __get_dumpable(unsigned long mm_flags)
66035 +{
66036 + int ret;
66037 +
66038 + ret = mm_flags & MMF_DUMPABLE_MASK;
66039 + return (ret >= 2) ? 2 : ret;
66040 +}
66041 +#endif
66042 +
66043 +void gr_handle_brute_attach(unsigned long mm_flags)
66044 +{
66045 +#ifdef CONFIG_GRKERNSEC_BRUTE
66046 + struct task_struct *p = current;
66047 + kuid_t uid = GLOBAL_ROOT_UID;
66048 + int daemon = 0;
66049 +
66050 + if (!grsec_enable_brute)
66051 + return;
66052 +
66053 + rcu_read_lock();
66054 + read_lock(&tasklist_lock);
66055 + read_lock(&grsec_exec_file_lock);
66056 + if (p->real_parent && p->real_parent->exec_file == p->exec_file) {
66057 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
66058 + p->real_parent->brute = 1;
66059 + daemon = 1;
66060 + } else {
66061 + const struct cred *cred = __task_cred(p), *cred2;
66062 + struct task_struct *tsk, *tsk2;
66063 +
66064 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
66065 + struct user_struct *user;
66066 +
66067 + uid = cred->uid;
66068 +
66069 + /* this is put upon execution past expiration */
66070 + user = find_user(uid);
66071 + if (user == NULL)
66072 + goto unlock;
66073 + user->banned = 1;
66074 + user->ban_expires = get_seconds() + GR_USER_BAN_TIME;
66075 + if (user->ban_expires == ~0UL)
66076 + user->ban_expires--;
66077 +
66078 + do_each_thread(tsk2, tsk) {
66079 + cred2 = __task_cred(tsk);
66080 + if (tsk != p && uid_eq(cred2->uid, uid))
66081 + gr_fake_force_sig(SIGKILL, tsk);
66082 + } while_each_thread(tsk2, tsk);
66083 + }
66084 + }
66085 +unlock:
66086 + read_unlock(&grsec_exec_file_lock);
66087 + read_unlock(&tasklist_lock);
66088 + rcu_read_unlock();
66089 +
66090 + if (gr_is_global_nonroot(uid))
66091 + printk(KERN_ALERT "grsec: bruteforce prevention initiated against uid %u, banning for %d minutes\n",
66092 + GR_GLOBAL_UID(uid), GR_USER_BAN_TIME / 60);
66093 + else if (daemon)
66094 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
66095 +
66096 +#endif
66097 + return;
66098 +}
66099 +
66100 +void gr_handle_brute_check(void)
66101 +{
66102 +#ifdef CONFIG_GRKERNSEC_BRUTE
66103 + struct task_struct *p = current;
66104 +
66105 + if (unlikely(p->brute)) {
66106 + if (!grsec_enable_brute)
66107 + p->brute = 0;
66108 + else if (time_before(get_seconds(), p->brute_expires))
66109 + msleep(30 * 1000);
66110 + }
66111 +#endif
66112 + return;
66113 +}
66114 +
66115 +void gr_handle_kernel_exploit(void)
66116 +{
66117 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
66118 + const struct cred *cred;
66119 + struct task_struct *tsk, *tsk2;
66120 + struct user_struct *user;
66121 + kuid_t uid;
66122 +
66123 + if (in_irq() || in_serving_softirq() || in_nmi())
66124 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
66125 +
66126 + uid = current_uid();
66127 +
66128 + if (gr_is_global_root(uid))
66129 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
66130 + else {
66131 + /* kill all the processes of this user, hold a reference
66132 + to their creds struct, and prevent them from creating
66133 + another process until system reset
66134 + */
66135 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
66136 + GR_GLOBAL_UID(uid));
66137 + /* we intentionally leak this ref */
66138 + user = get_uid(current->cred->user);
66139 + if (user) {
66140 + user->banned = 1;
66141 + user->ban_expires = ~0UL;
66142 + }
66143 +
66144 + read_lock(&tasklist_lock);
66145 + do_each_thread(tsk2, tsk) {
66146 + cred = __task_cred(tsk);
66147 + if (uid_eq(cred->uid, uid))
66148 + gr_fake_force_sig(SIGKILL, tsk);
66149 + } while_each_thread(tsk2, tsk);
66150 + read_unlock(&tasklist_lock);
66151 + }
66152 +#endif
66153 +}
66154 +
66155 +int __gr_process_user_ban(struct user_struct *user)
66156 +{
66157 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
66158 + if (unlikely(user->banned)) {
66159 + if (user->ban_expires != ~0UL && time_after_eq(get_seconds(), user->ban_expires)) {
66160 + user->banned = 0;
66161 + user->ban_expires = 0;
66162 + free_uid(user);
66163 + } else
66164 + return -EPERM;
66165 + }
66166 +#endif
66167 + return 0;
66168 +}
66169 +
66170 +int gr_process_user_ban(void)
66171 +{
66172 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
66173 + return __gr_process_user_ban(current->cred->user);
66174 +#endif
66175 + return 0;
66176 +}
66177 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
66178 new file mode 100644
66179 index 0000000..4030d57
66180 --- /dev/null
66181 +++ b/grsecurity/grsec_sock.c
66182 @@ -0,0 +1,244 @@
66183 +#include <linux/kernel.h>
66184 +#include <linux/module.h>
66185 +#include <linux/sched.h>
66186 +#include <linux/file.h>
66187 +#include <linux/net.h>
66188 +#include <linux/in.h>
66189 +#include <linux/ip.h>
66190 +#include <net/sock.h>
66191 +#include <net/inet_sock.h>
66192 +#include <linux/grsecurity.h>
66193 +#include <linux/grinternal.h>
66194 +#include <linux/gracl.h>
66195 +
66196 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
66197 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
66198 +
66199 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
66200 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
66201 +
66202 +#ifdef CONFIG_UNIX_MODULE
66203 +EXPORT_SYMBOL(gr_acl_handle_unix);
66204 +EXPORT_SYMBOL(gr_acl_handle_mknod);
66205 +EXPORT_SYMBOL(gr_handle_chroot_unix);
66206 +EXPORT_SYMBOL(gr_handle_create);
66207 +#endif
66208 +
66209 +#ifdef CONFIG_GRKERNSEC
66210 +#define gr_conn_table_size 32749
66211 +struct conn_table_entry {
66212 + struct conn_table_entry *next;
66213 + struct signal_struct *sig;
66214 +};
66215 +
66216 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
66217 +DEFINE_SPINLOCK(gr_conn_table_lock);
66218 +
66219 +extern const char * gr_socktype_to_name(unsigned char type);
66220 +extern const char * gr_proto_to_name(unsigned char proto);
66221 +extern const char * gr_sockfamily_to_name(unsigned char family);
66222 +
66223 +static __inline__ int
66224 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
66225 +{
66226 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
66227 +}
66228 +
66229 +static __inline__ int
66230 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
66231 + __u16 sport, __u16 dport)
66232 +{
66233 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
66234 + sig->gr_sport == sport && sig->gr_dport == dport))
66235 + return 1;
66236 + else
66237 + return 0;
66238 +}
66239 +
66240 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
66241 +{
66242 + struct conn_table_entry **match;
66243 + unsigned int index;
66244 +
66245 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66246 + sig->gr_sport, sig->gr_dport,
66247 + gr_conn_table_size);
66248 +
66249 + newent->sig = sig;
66250 +
66251 + match = &gr_conn_table[index];
66252 + newent->next = *match;
66253 + *match = newent;
66254 +
66255 + return;
66256 +}
66257 +
66258 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
66259 +{
66260 + struct conn_table_entry *match, *last = NULL;
66261 + unsigned int index;
66262 +
66263 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66264 + sig->gr_sport, sig->gr_dport,
66265 + gr_conn_table_size);
66266 +
66267 + match = gr_conn_table[index];
66268 + while (match && !conn_match(match->sig,
66269 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
66270 + sig->gr_dport)) {
66271 + last = match;
66272 + match = match->next;
66273 + }
66274 +
66275 + if (match) {
66276 + if (last)
66277 + last->next = match->next;
66278 + else
66279 + gr_conn_table[index] = NULL;
66280 + kfree(match);
66281 + }
66282 +
66283 + return;
66284 +}
66285 +
66286 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
66287 + __u16 sport, __u16 dport)
66288 +{
66289 + struct conn_table_entry *match;
66290 + unsigned int index;
66291 +
66292 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
66293 +
66294 + match = gr_conn_table[index];
66295 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
66296 + match = match->next;
66297 +
66298 + if (match)
66299 + return match->sig;
66300 + else
66301 + return NULL;
66302 +}
66303 +
66304 +#endif
66305 +
66306 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
66307 +{
66308 +#ifdef CONFIG_GRKERNSEC
66309 + struct signal_struct *sig = task->signal;
66310 + struct conn_table_entry *newent;
66311 +
66312 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
66313 + if (newent == NULL)
66314 + return;
66315 + /* no bh lock needed since we are called with bh disabled */
66316 + spin_lock(&gr_conn_table_lock);
66317 + gr_del_task_from_ip_table_nolock(sig);
66318 + sig->gr_saddr = inet->inet_rcv_saddr;
66319 + sig->gr_daddr = inet->inet_daddr;
66320 + sig->gr_sport = inet->inet_sport;
66321 + sig->gr_dport = inet->inet_dport;
66322 + gr_add_to_task_ip_table_nolock(sig, newent);
66323 + spin_unlock(&gr_conn_table_lock);
66324 +#endif
66325 + return;
66326 +}
66327 +
66328 +void gr_del_task_from_ip_table(struct task_struct *task)
66329 +{
66330 +#ifdef CONFIG_GRKERNSEC
66331 + spin_lock_bh(&gr_conn_table_lock);
66332 + gr_del_task_from_ip_table_nolock(task->signal);
66333 + spin_unlock_bh(&gr_conn_table_lock);
66334 +#endif
66335 + return;
66336 +}
66337 +
66338 +void
66339 +gr_attach_curr_ip(const struct sock *sk)
66340 +{
66341 +#ifdef CONFIG_GRKERNSEC
66342 + struct signal_struct *p, *set;
66343 + const struct inet_sock *inet = inet_sk(sk);
66344 +
66345 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
66346 + return;
66347 +
66348 + set = current->signal;
66349 +
66350 + spin_lock_bh(&gr_conn_table_lock);
66351 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
66352 + inet->inet_dport, inet->inet_sport);
66353 + if (unlikely(p != NULL)) {
66354 + set->curr_ip = p->curr_ip;
66355 + set->used_accept = 1;
66356 + gr_del_task_from_ip_table_nolock(p);
66357 + spin_unlock_bh(&gr_conn_table_lock);
66358 + return;
66359 + }
66360 + spin_unlock_bh(&gr_conn_table_lock);
66361 +
66362 + set->curr_ip = inet->inet_daddr;
66363 + set->used_accept = 1;
66364 +#endif
66365 + return;
66366 +}
66367 +
66368 +int
66369 +gr_handle_sock_all(const int family, const int type, const int protocol)
66370 +{
66371 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66372 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
66373 + (family != AF_UNIX)) {
66374 + if (family == AF_INET)
66375 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
66376 + else
66377 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
66378 + return -EACCES;
66379 + }
66380 +#endif
66381 + return 0;
66382 +}
66383 +
66384 +int
66385 +gr_handle_sock_server(const struct sockaddr *sck)
66386 +{
66387 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66388 + if (grsec_enable_socket_server &&
66389 + in_group_p(grsec_socket_server_gid) &&
66390 + sck && (sck->sa_family != AF_UNIX) &&
66391 + (sck->sa_family != AF_LOCAL)) {
66392 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66393 + return -EACCES;
66394 + }
66395 +#endif
66396 + return 0;
66397 +}
66398 +
66399 +int
66400 +gr_handle_sock_server_other(const struct sock *sck)
66401 +{
66402 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66403 + if (grsec_enable_socket_server &&
66404 + in_group_p(grsec_socket_server_gid) &&
66405 + sck && (sck->sk_family != AF_UNIX) &&
66406 + (sck->sk_family != AF_LOCAL)) {
66407 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66408 + return -EACCES;
66409 + }
66410 +#endif
66411 + return 0;
66412 +}
66413 +
66414 +int
66415 +gr_handle_sock_client(const struct sockaddr *sck)
66416 +{
66417 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66418 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
66419 + sck && (sck->sa_family != AF_UNIX) &&
66420 + (sck->sa_family != AF_LOCAL)) {
66421 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
66422 + return -EACCES;
66423 + }
66424 +#endif
66425 + return 0;
66426 +}
66427 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
66428 new file mode 100644
66429 index 0000000..f55ef0f
66430 --- /dev/null
66431 +++ b/grsecurity/grsec_sysctl.c
66432 @@ -0,0 +1,469 @@
66433 +#include <linux/kernel.h>
66434 +#include <linux/sched.h>
66435 +#include <linux/sysctl.h>
66436 +#include <linux/grsecurity.h>
66437 +#include <linux/grinternal.h>
66438 +
66439 +int
66440 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
66441 +{
66442 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66443 + if (dirname == NULL || name == NULL)
66444 + return 0;
66445 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
66446 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
66447 + return -EACCES;
66448 + }
66449 +#endif
66450 + return 0;
66451 +}
66452 +
66453 +#ifdef CONFIG_GRKERNSEC_ROFS
66454 +static int __maybe_unused one = 1;
66455 +#endif
66456 +
66457 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
66458 +struct ctl_table grsecurity_table[] = {
66459 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66460 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
66461 +#ifdef CONFIG_GRKERNSEC_IO
66462 + {
66463 + .procname = "disable_priv_io",
66464 + .data = &grsec_disable_privio,
66465 + .maxlen = sizeof(int),
66466 + .mode = 0600,
66467 + .proc_handler = &proc_dointvec,
66468 + },
66469 +#endif
66470 +#endif
66471 +#ifdef CONFIG_GRKERNSEC_LINK
66472 + {
66473 + .procname = "linking_restrictions",
66474 + .data = &grsec_enable_link,
66475 + .maxlen = sizeof(int),
66476 + .mode = 0600,
66477 + .proc_handler = &proc_dointvec,
66478 + },
66479 +#endif
66480 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
66481 + {
66482 + .procname = "enforce_symlinksifowner",
66483 + .data = &grsec_enable_symlinkown,
66484 + .maxlen = sizeof(int),
66485 + .mode = 0600,
66486 + .proc_handler = &proc_dointvec,
66487 + },
66488 + {
66489 + .procname = "symlinkown_gid",
66490 + .data = &grsec_symlinkown_gid,
66491 + .maxlen = sizeof(int),
66492 + .mode = 0600,
66493 + .proc_handler = &proc_dointvec,
66494 + },
66495 +#endif
66496 +#ifdef CONFIG_GRKERNSEC_BRUTE
66497 + {
66498 + .procname = "deter_bruteforce",
66499 + .data = &grsec_enable_brute,
66500 + .maxlen = sizeof(int),
66501 + .mode = 0600,
66502 + .proc_handler = &proc_dointvec,
66503 + },
66504 +#endif
66505 +#ifdef CONFIG_GRKERNSEC_FIFO
66506 + {
66507 + .procname = "fifo_restrictions",
66508 + .data = &grsec_enable_fifo,
66509 + .maxlen = sizeof(int),
66510 + .mode = 0600,
66511 + .proc_handler = &proc_dointvec,
66512 + },
66513 +#endif
66514 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
66515 + {
66516 + .procname = "ptrace_readexec",
66517 + .data = &grsec_enable_ptrace_readexec,
66518 + .maxlen = sizeof(int),
66519 + .mode = 0600,
66520 + .proc_handler = &proc_dointvec,
66521 + },
66522 +#endif
66523 +#ifdef CONFIG_GRKERNSEC_SETXID
66524 + {
66525 + .procname = "consistent_setxid",
66526 + .data = &grsec_enable_setxid,
66527 + .maxlen = sizeof(int),
66528 + .mode = 0600,
66529 + .proc_handler = &proc_dointvec,
66530 + },
66531 +#endif
66532 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
66533 + {
66534 + .procname = "ip_blackhole",
66535 + .data = &grsec_enable_blackhole,
66536 + .maxlen = sizeof(int),
66537 + .mode = 0600,
66538 + .proc_handler = &proc_dointvec,
66539 + },
66540 + {
66541 + .procname = "lastack_retries",
66542 + .data = &grsec_lastack_retries,
66543 + .maxlen = sizeof(int),
66544 + .mode = 0600,
66545 + .proc_handler = &proc_dointvec,
66546 + },
66547 +#endif
66548 +#ifdef CONFIG_GRKERNSEC_EXECLOG
66549 + {
66550 + .procname = "exec_logging",
66551 + .data = &grsec_enable_execlog,
66552 + .maxlen = sizeof(int),
66553 + .mode = 0600,
66554 + .proc_handler = &proc_dointvec,
66555 + },
66556 +#endif
66557 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66558 + {
66559 + .procname = "rwxmap_logging",
66560 + .data = &grsec_enable_log_rwxmaps,
66561 + .maxlen = sizeof(int),
66562 + .mode = 0600,
66563 + .proc_handler = &proc_dointvec,
66564 + },
66565 +#endif
66566 +#ifdef CONFIG_GRKERNSEC_SIGNAL
66567 + {
66568 + .procname = "signal_logging",
66569 + .data = &grsec_enable_signal,
66570 + .maxlen = sizeof(int),
66571 + .mode = 0600,
66572 + .proc_handler = &proc_dointvec,
66573 + },
66574 +#endif
66575 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
66576 + {
66577 + .procname = "forkfail_logging",
66578 + .data = &grsec_enable_forkfail,
66579 + .maxlen = sizeof(int),
66580 + .mode = 0600,
66581 + .proc_handler = &proc_dointvec,
66582 + },
66583 +#endif
66584 +#ifdef CONFIG_GRKERNSEC_TIME
66585 + {
66586 + .procname = "timechange_logging",
66587 + .data = &grsec_enable_time,
66588 + .maxlen = sizeof(int),
66589 + .mode = 0600,
66590 + .proc_handler = &proc_dointvec,
66591 + },
66592 +#endif
66593 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
66594 + {
66595 + .procname = "chroot_deny_shmat",
66596 + .data = &grsec_enable_chroot_shmat,
66597 + .maxlen = sizeof(int),
66598 + .mode = 0600,
66599 + .proc_handler = &proc_dointvec,
66600 + },
66601 +#endif
66602 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
66603 + {
66604 + .procname = "chroot_deny_unix",
66605 + .data = &grsec_enable_chroot_unix,
66606 + .maxlen = sizeof(int),
66607 + .mode = 0600,
66608 + .proc_handler = &proc_dointvec,
66609 + },
66610 +#endif
66611 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
66612 + {
66613 + .procname = "chroot_deny_mount",
66614 + .data = &grsec_enable_chroot_mount,
66615 + .maxlen = sizeof(int),
66616 + .mode = 0600,
66617 + .proc_handler = &proc_dointvec,
66618 + },
66619 +#endif
66620 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
66621 + {
66622 + .procname = "chroot_deny_fchdir",
66623 + .data = &grsec_enable_chroot_fchdir,
66624 + .maxlen = sizeof(int),
66625 + .mode = 0600,
66626 + .proc_handler = &proc_dointvec,
66627 + },
66628 +#endif
66629 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
66630 + {
66631 + .procname = "chroot_deny_chroot",
66632 + .data = &grsec_enable_chroot_double,
66633 + .maxlen = sizeof(int),
66634 + .mode = 0600,
66635 + .proc_handler = &proc_dointvec,
66636 + },
66637 +#endif
66638 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
66639 + {
66640 + .procname = "chroot_deny_pivot",
66641 + .data = &grsec_enable_chroot_pivot,
66642 + .maxlen = sizeof(int),
66643 + .mode = 0600,
66644 + .proc_handler = &proc_dointvec,
66645 + },
66646 +#endif
66647 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
66648 + {
66649 + .procname = "chroot_enforce_chdir",
66650 + .data = &grsec_enable_chroot_chdir,
66651 + .maxlen = sizeof(int),
66652 + .mode = 0600,
66653 + .proc_handler = &proc_dointvec,
66654 + },
66655 +#endif
66656 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
66657 + {
66658 + .procname = "chroot_deny_chmod",
66659 + .data = &grsec_enable_chroot_chmod,
66660 + .maxlen = sizeof(int),
66661 + .mode = 0600,
66662 + .proc_handler = &proc_dointvec,
66663 + },
66664 +#endif
66665 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
66666 + {
66667 + .procname = "chroot_deny_mknod",
66668 + .data = &grsec_enable_chroot_mknod,
66669 + .maxlen = sizeof(int),
66670 + .mode = 0600,
66671 + .proc_handler = &proc_dointvec,
66672 + },
66673 +#endif
66674 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
66675 + {
66676 + .procname = "chroot_restrict_nice",
66677 + .data = &grsec_enable_chroot_nice,
66678 + .maxlen = sizeof(int),
66679 + .mode = 0600,
66680 + .proc_handler = &proc_dointvec,
66681 + },
66682 +#endif
66683 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
66684 + {
66685 + .procname = "chroot_execlog",
66686 + .data = &grsec_enable_chroot_execlog,
66687 + .maxlen = sizeof(int),
66688 + .mode = 0600,
66689 + .proc_handler = &proc_dointvec,
66690 + },
66691 +#endif
66692 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
66693 + {
66694 + .procname = "chroot_caps",
66695 + .data = &grsec_enable_chroot_caps,
66696 + .maxlen = sizeof(int),
66697 + .mode = 0600,
66698 + .proc_handler = &proc_dointvec,
66699 + },
66700 +#endif
66701 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
66702 + {
66703 + .procname = "chroot_deny_sysctl",
66704 + .data = &grsec_enable_chroot_sysctl,
66705 + .maxlen = sizeof(int),
66706 + .mode = 0600,
66707 + .proc_handler = &proc_dointvec,
66708 + },
66709 +#endif
66710 +#ifdef CONFIG_GRKERNSEC_TPE
66711 + {
66712 + .procname = "tpe",
66713 + .data = &grsec_enable_tpe,
66714 + .maxlen = sizeof(int),
66715 + .mode = 0600,
66716 + .proc_handler = &proc_dointvec,
66717 + },
66718 + {
66719 + .procname = "tpe_gid",
66720 + .data = &grsec_tpe_gid,
66721 + .maxlen = sizeof(int),
66722 + .mode = 0600,
66723 + .proc_handler = &proc_dointvec,
66724 + },
66725 +#endif
66726 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66727 + {
66728 + .procname = "tpe_invert",
66729 + .data = &grsec_enable_tpe_invert,
66730 + .maxlen = sizeof(int),
66731 + .mode = 0600,
66732 + .proc_handler = &proc_dointvec,
66733 + },
66734 +#endif
66735 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66736 + {
66737 + .procname = "tpe_restrict_all",
66738 + .data = &grsec_enable_tpe_all,
66739 + .maxlen = sizeof(int),
66740 + .mode = 0600,
66741 + .proc_handler = &proc_dointvec,
66742 + },
66743 +#endif
66744 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66745 + {
66746 + .procname = "socket_all",
66747 + .data = &grsec_enable_socket_all,
66748 + .maxlen = sizeof(int),
66749 + .mode = 0600,
66750 + .proc_handler = &proc_dointvec,
66751 + },
66752 + {
66753 + .procname = "socket_all_gid",
66754 + .data = &grsec_socket_all_gid,
66755 + .maxlen = sizeof(int),
66756 + .mode = 0600,
66757 + .proc_handler = &proc_dointvec,
66758 + },
66759 +#endif
66760 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66761 + {
66762 + .procname = "socket_client",
66763 + .data = &grsec_enable_socket_client,
66764 + .maxlen = sizeof(int),
66765 + .mode = 0600,
66766 + .proc_handler = &proc_dointvec,
66767 + },
66768 + {
66769 + .procname = "socket_client_gid",
66770 + .data = &grsec_socket_client_gid,
66771 + .maxlen = sizeof(int),
66772 + .mode = 0600,
66773 + .proc_handler = &proc_dointvec,
66774 + },
66775 +#endif
66776 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66777 + {
66778 + .procname = "socket_server",
66779 + .data = &grsec_enable_socket_server,
66780 + .maxlen = sizeof(int),
66781 + .mode = 0600,
66782 + .proc_handler = &proc_dointvec,
66783 + },
66784 + {
66785 + .procname = "socket_server_gid",
66786 + .data = &grsec_socket_server_gid,
66787 + .maxlen = sizeof(int),
66788 + .mode = 0600,
66789 + .proc_handler = &proc_dointvec,
66790 + },
66791 +#endif
66792 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
66793 + {
66794 + .procname = "audit_group",
66795 + .data = &grsec_enable_group,
66796 + .maxlen = sizeof(int),
66797 + .mode = 0600,
66798 + .proc_handler = &proc_dointvec,
66799 + },
66800 + {
66801 + .procname = "audit_gid",
66802 + .data = &grsec_audit_gid,
66803 + .maxlen = sizeof(int),
66804 + .mode = 0600,
66805 + .proc_handler = &proc_dointvec,
66806 + },
66807 +#endif
66808 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
66809 + {
66810 + .procname = "audit_chdir",
66811 + .data = &grsec_enable_chdir,
66812 + .maxlen = sizeof(int),
66813 + .mode = 0600,
66814 + .proc_handler = &proc_dointvec,
66815 + },
66816 +#endif
66817 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66818 + {
66819 + .procname = "audit_mount",
66820 + .data = &grsec_enable_mount,
66821 + .maxlen = sizeof(int),
66822 + .mode = 0600,
66823 + .proc_handler = &proc_dointvec,
66824 + },
66825 +#endif
66826 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
66827 + {
66828 + .procname = "audit_textrel",
66829 + .data = &grsec_enable_audit_textrel,
66830 + .maxlen = sizeof(int),
66831 + .mode = 0600,
66832 + .proc_handler = &proc_dointvec,
66833 + },
66834 +#endif
66835 +#ifdef CONFIG_GRKERNSEC_DMESG
66836 + {
66837 + .procname = "dmesg",
66838 + .data = &grsec_enable_dmesg,
66839 + .maxlen = sizeof(int),
66840 + .mode = 0600,
66841 + .proc_handler = &proc_dointvec,
66842 + },
66843 +#endif
66844 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
66845 + {
66846 + .procname = "chroot_findtask",
66847 + .data = &grsec_enable_chroot_findtask,
66848 + .maxlen = sizeof(int),
66849 + .mode = 0600,
66850 + .proc_handler = &proc_dointvec,
66851 + },
66852 +#endif
66853 +#ifdef CONFIG_GRKERNSEC_RESLOG
66854 + {
66855 + .procname = "resource_logging",
66856 + .data = &grsec_resource_logging,
66857 + .maxlen = sizeof(int),
66858 + .mode = 0600,
66859 + .proc_handler = &proc_dointvec,
66860 + },
66861 +#endif
66862 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
66863 + {
66864 + .procname = "audit_ptrace",
66865 + .data = &grsec_enable_audit_ptrace,
66866 + .maxlen = sizeof(int),
66867 + .mode = 0600,
66868 + .proc_handler = &proc_dointvec,
66869 + },
66870 +#endif
66871 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66872 + {
66873 + .procname = "harden_ptrace",
66874 + .data = &grsec_enable_harden_ptrace,
66875 + .maxlen = sizeof(int),
66876 + .mode = 0600,
66877 + .proc_handler = &proc_dointvec,
66878 + },
66879 +#endif
66880 + {
66881 + .procname = "grsec_lock",
66882 + .data = &grsec_lock,
66883 + .maxlen = sizeof(int),
66884 + .mode = 0600,
66885 + .proc_handler = &proc_dointvec,
66886 + },
66887 +#endif
66888 +#ifdef CONFIG_GRKERNSEC_ROFS
66889 + {
66890 + .procname = "romount_protect",
66891 + .data = &grsec_enable_rofs,
66892 + .maxlen = sizeof(int),
66893 + .mode = 0600,
66894 + .proc_handler = &proc_dointvec_minmax,
66895 + .extra1 = &one,
66896 + .extra2 = &one,
66897 + },
66898 +#endif
66899 + { }
66900 +};
66901 +#endif
66902 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
66903 new file mode 100644
66904 index 0000000..0dc13c3
66905 --- /dev/null
66906 +++ b/grsecurity/grsec_time.c
66907 @@ -0,0 +1,16 @@
66908 +#include <linux/kernel.h>
66909 +#include <linux/sched.h>
66910 +#include <linux/grinternal.h>
66911 +#include <linux/module.h>
66912 +
66913 +void
66914 +gr_log_timechange(void)
66915 +{
66916 +#ifdef CONFIG_GRKERNSEC_TIME
66917 + if (grsec_enable_time)
66918 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
66919 +#endif
66920 + return;
66921 +}
66922 +
66923 +EXPORT_SYMBOL(gr_log_timechange);
66924 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
66925 new file mode 100644
66926 index 0000000..ee57dcf
66927 --- /dev/null
66928 +++ b/grsecurity/grsec_tpe.c
66929 @@ -0,0 +1,73 @@
66930 +#include <linux/kernel.h>
66931 +#include <linux/sched.h>
66932 +#include <linux/file.h>
66933 +#include <linux/fs.h>
66934 +#include <linux/grinternal.h>
66935 +
66936 +extern int gr_acl_tpe_check(void);
66937 +
66938 +int
66939 +gr_tpe_allow(const struct file *file)
66940 +{
66941 +#ifdef CONFIG_GRKERNSEC
66942 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
66943 + const struct cred *cred = current_cred();
66944 + char *msg = NULL;
66945 + char *msg2 = NULL;
66946 +
66947 + // never restrict root
66948 + if (gr_is_global_root(cred->uid))
66949 + return 1;
66950 +
66951 + if (grsec_enable_tpe) {
66952 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66953 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
66954 + msg = "not being in trusted group";
66955 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
66956 + msg = "being in untrusted group";
66957 +#else
66958 + if (in_group_p(grsec_tpe_gid))
66959 + msg = "being in untrusted group";
66960 +#endif
66961 + }
66962 + if (!msg && gr_acl_tpe_check())
66963 + msg = "being in untrusted role";
66964 +
66965 + // not in any affected group/role
66966 + if (!msg)
66967 + goto next_check;
66968 +
66969 + if (gr_is_global_nonroot(inode->i_uid))
66970 + msg2 = "file in non-root-owned directory";
66971 + else if (inode->i_mode & S_IWOTH)
66972 + msg2 = "file in world-writable directory";
66973 + else if (inode->i_mode & S_IWGRP)
66974 + msg2 = "file in group-writable directory";
66975 +
66976 + if (msg && msg2) {
66977 + char fullmsg[70] = {0};
66978 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
66979 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
66980 + return 0;
66981 + }
66982 + msg = NULL;
66983 +next_check:
66984 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66985 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
66986 + return 1;
66987 +
66988 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
66989 + msg = "directory not owned by user";
66990 + else if (inode->i_mode & S_IWOTH)
66991 + msg = "file in world-writable directory";
66992 + else if (inode->i_mode & S_IWGRP)
66993 + msg = "file in group-writable directory";
66994 +
66995 + if (msg) {
66996 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
66997 + return 0;
66998 + }
66999 +#endif
67000 +#endif
67001 + return 1;
67002 +}
67003 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
67004 new file mode 100644
67005 index 0000000..9f7b1ac
67006 --- /dev/null
67007 +++ b/grsecurity/grsum.c
67008 @@ -0,0 +1,61 @@
67009 +#include <linux/err.h>
67010 +#include <linux/kernel.h>
67011 +#include <linux/sched.h>
67012 +#include <linux/mm.h>
67013 +#include <linux/scatterlist.h>
67014 +#include <linux/crypto.h>
67015 +#include <linux/gracl.h>
67016 +
67017 +
67018 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
67019 +#error "crypto and sha256 must be built into the kernel"
67020 +#endif
67021 +
67022 +int
67023 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
67024 +{
67025 + char *p;
67026 + struct crypto_hash *tfm;
67027 + struct hash_desc desc;
67028 + struct scatterlist sg;
67029 + unsigned char temp_sum[GR_SHA_LEN];
67030 + volatile int retval = 0;
67031 + volatile int dummy = 0;
67032 + unsigned int i;
67033 +
67034 + sg_init_table(&sg, 1);
67035 +
67036 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
67037 + if (IS_ERR(tfm)) {
67038 + /* should never happen, since sha256 should be built in */
67039 + return 1;
67040 + }
67041 +
67042 + desc.tfm = tfm;
67043 + desc.flags = 0;
67044 +
67045 + crypto_hash_init(&desc);
67046 +
67047 + p = salt;
67048 + sg_set_buf(&sg, p, GR_SALT_LEN);
67049 + crypto_hash_update(&desc, &sg, sg.length);
67050 +
67051 + p = entry->pw;
67052 + sg_set_buf(&sg, p, strlen(p));
67053 +
67054 + crypto_hash_update(&desc, &sg, sg.length);
67055 +
67056 + crypto_hash_final(&desc, temp_sum);
67057 +
67058 + memset(entry->pw, 0, GR_PW_LEN);
67059 +
67060 + for (i = 0; i < GR_SHA_LEN; i++)
67061 + if (sum[i] != temp_sum[i])
67062 + retval = 1;
67063 + else
67064 + dummy = 1; // waste a cycle
67065 +
67066 + crypto_free_hash(tfm);
67067 +
67068 + return retval;
67069 +}
67070 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
67071 index 77ff547..181834f 100644
67072 --- a/include/asm-generic/4level-fixup.h
67073 +++ b/include/asm-generic/4level-fixup.h
67074 @@ -13,8 +13,10 @@
67075 #define pmd_alloc(mm, pud, address) \
67076 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
67077 NULL: pmd_offset(pud, address))
67078 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
67079
67080 #define pud_alloc(mm, pgd, address) (pgd)
67081 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
67082 #define pud_offset(pgd, start) (pgd)
67083 #define pud_none(pud) 0
67084 #define pud_bad(pud) 0
67085 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
67086 index b7babf0..04ad282 100644
67087 --- a/include/asm-generic/atomic-long.h
67088 +++ b/include/asm-generic/atomic-long.h
67089 @@ -22,6 +22,12 @@
67090
67091 typedef atomic64_t atomic_long_t;
67092
67093 +#ifdef CONFIG_PAX_REFCOUNT
67094 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
67095 +#else
67096 +typedef atomic64_t atomic_long_unchecked_t;
67097 +#endif
67098 +
67099 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
67100
67101 static inline long atomic_long_read(atomic_long_t *l)
67102 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67103 return (long)atomic64_read(v);
67104 }
67105
67106 +#ifdef CONFIG_PAX_REFCOUNT
67107 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67108 +{
67109 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67110 +
67111 + return (long)atomic64_read_unchecked(v);
67112 +}
67113 +#endif
67114 +
67115 static inline void atomic_long_set(atomic_long_t *l, long i)
67116 {
67117 atomic64_t *v = (atomic64_t *)l;
67118 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67119 atomic64_set(v, i);
67120 }
67121
67122 +#ifdef CONFIG_PAX_REFCOUNT
67123 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67124 +{
67125 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67126 +
67127 + atomic64_set_unchecked(v, i);
67128 +}
67129 +#endif
67130 +
67131 static inline void atomic_long_inc(atomic_long_t *l)
67132 {
67133 atomic64_t *v = (atomic64_t *)l;
67134 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67135 atomic64_inc(v);
67136 }
67137
67138 +#ifdef CONFIG_PAX_REFCOUNT
67139 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67140 +{
67141 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67142 +
67143 + atomic64_inc_unchecked(v);
67144 +}
67145 +#endif
67146 +
67147 static inline void atomic_long_dec(atomic_long_t *l)
67148 {
67149 atomic64_t *v = (atomic64_t *)l;
67150 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67151 atomic64_dec(v);
67152 }
67153
67154 +#ifdef CONFIG_PAX_REFCOUNT
67155 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67156 +{
67157 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67158 +
67159 + atomic64_dec_unchecked(v);
67160 +}
67161 +#endif
67162 +
67163 static inline void atomic_long_add(long i, atomic_long_t *l)
67164 {
67165 atomic64_t *v = (atomic64_t *)l;
67166 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67167 atomic64_add(i, v);
67168 }
67169
67170 +#ifdef CONFIG_PAX_REFCOUNT
67171 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67172 +{
67173 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67174 +
67175 + atomic64_add_unchecked(i, v);
67176 +}
67177 +#endif
67178 +
67179 static inline void atomic_long_sub(long i, atomic_long_t *l)
67180 {
67181 atomic64_t *v = (atomic64_t *)l;
67182 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67183 atomic64_sub(i, v);
67184 }
67185
67186 +#ifdef CONFIG_PAX_REFCOUNT
67187 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67188 +{
67189 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67190 +
67191 + atomic64_sub_unchecked(i, v);
67192 +}
67193 +#endif
67194 +
67195 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67196 {
67197 atomic64_t *v = (atomic64_t *)l;
67198 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67199 return (long)atomic64_add_return(i, v);
67200 }
67201
67202 +#ifdef CONFIG_PAX_REFCOUNT
67203 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67204 +{
67205 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67206 +
67207 + return (long)atomic64_add_return_unchecked(i, v);
67208 +}
67209 +#endif
67210 +
67211 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67212 {
67213 atomic64_t *v = (atomic64_t *)l;
67214 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67215 return (long)atomic64_inc_return(v);
67216 }
67217
67218 +#ifdef CONFIG_PAX_REFCOUNT
67219 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67220 +{
67221 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67222 +
67223 + return (long)atomic64_inc_return_unchecked(v);
67224 +}
67225 +#endif
67226 +
67227 static inline long atomic_long_dec_return(atomic_long_t *l)
67228 {
67229 atomic64_t *v = (atomic64_t *)l;
67230 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67231
67232 typedef atomic_t atomic_long_t;
67233
67234 +#ifdef CONFIG_PAX_REFCOUNT
67235 +typedef atomic_unchecked_t atomic_long_unchecked_t;
67236 +#else
67237 +typedef atomic_t atomic_long_unchecked_t;
67238 +#endif
67239 +
67240 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
67241 static inline long atomic_long_read(atomic_long_t *l)
67242 {
67243 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67244 return (long)atomic_read(v);
67245 }
67246
67247 +#ifdef CONFIG_PAX_REFCOUNT
67248 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67249 +{
67250 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67251 +
67252 + return (long)atomic_read_unchecked(v);
67253 +}
67254 +#endif
67255 +
67256 static inline void atomic_long_set(atomic_long_t *l, long i)
67257 {
67258 atomic_t *v = (atomic_t *)l;
67259 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67260 atomic_set(v, i);
67261 }
67262
67263 +#ifdef CONFIG_PAX_REFCOUNT
67264 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67265 +{
67266 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67267 +
67268 + atomic_set_unchecked(v, i);
67269 +}
67270 +#endif
67271 +
67272 static inline void atomic_long_inc(atomic_long_t *l)
67273 {
67274 atomic_t *v = (atomic_t *)l;
67275 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67276 atomic_inc(v);
67277 }
67278
67279 +#ifdef CONFIG_PAX_REFCOUNT
67280 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67281 +{
67282 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67283 +
67284 + atomic_inc_unchecked(v);
67285 +}
67286 +#endif
67287 +
67288 static inline void atomic_long_dec(atomic_long_t *l)
67289 {
67290 atomic_t *v = (atomic_t *)l;
67291 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67292 atomic_dec(v);
67293 }
67294
67295 +#ifdef CONFIG_PAX_REFCOUNT
67296 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67297 +{
67298 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67299 +
67300 + atomic_dec_unchecked(v);
67301 +}
67302 +#endif
67303 +
67304 static inline void atomic_long_add(long i, atomic_long_t *l)
67305 {
67306 atomic_t *v = (atomic_t *)l;
67307 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67308 atomic_add(i, v);
67309 }
67310
67311 +#ifdef CONFIG_PAX_REFCOUNT
67312 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67313 +{
67314 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67315 +
67316 + atomic_add_unchecked(i, v);
67317 +}
67318 +#endif
67319 +
67320 static inline void atomic_long_sub(long i, atomic_long_t *l)
67321 {
67322 atomic_t *v = (atomic_t *)l;
67323 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67324 atomic_sub(i, v);
67325 }
67326
67327 +#ifdef CONFIG_PAX_REFCOUNT
67328 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67329 +{
67330 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67331 +
67332 + atomic_sub_unchecked(i, v);
67333 +}
67334 +#endif
67335 +
67336 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67337 {
67338 atomic_t *v = (atomic_t *)l;
67339 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67340 return (long)atomic_add_return(i, v);
67341 }
67342
67343 +#ifdef CONFIG_PAX_REFCOUNT
67344 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67345 +{
67346 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67347 +
67348 + return (long)atomic_add_return_unchecked(i, v);
67349 +}
67350 +
67351 +#endif
67352 +
67353 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67354 {
67355 atomic_t *v = (atomic_t *)l;
67356 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67357 return (long)atomic_inc_return(v);
67358 }
67359
67360 +#ifdef CONFIG_PAX_REFCOUNT
67361 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67362 +{
67363 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67364 +
67365 + return (long)atomic_inc_return_unchecked(v);
67366 +}
67367 +#endif
67368 +
67369 static inline long atomic_long_dec_return(atomic_long_t *l)
67370 {
67371 atomic_t *v = (atomic_t *)l;
67372 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67373
67374 #endif /* BITS_PER_LONG == 64 */
67375
67376 +#ifdef CONFIG_PAX_REFCOUNT
67377 +static inline void pax_refcount_needs_these_functions(void)
67378 +{
67379 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
67380 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
67381 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
67382 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
67383 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
67384 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
67385 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
67386 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
67387 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
67388 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
67389 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
67390 +#ifdef CONFIG_X86
67391 + atomic_clear_mask_unchecked(0, NULL);
67392 + atomic_set_mask_unchecked(0, NULL);
67393 +#endif
67394 +
67395 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
67396 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
67397 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
67398 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
67399 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
67400 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
67401 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
67402 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
67403 +}
67404 +#else
67405 +#define atomic_read_unchecked(v) atomic_read(v)
67406 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
67407 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
67408 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
67409 +#define atomic_inc_unchecked(v) atomic_inc(v)
67410 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
67411 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
67412 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
67413 +#define atomic_dec_unchecked(v) atomic_dec(v)
67414 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
67415 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
67416 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
67417 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
67418 +
67419 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
67420 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
67421 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
67422 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
67423 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
67424 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
67425 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
67426 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
67427 +#endif
67428 +
67429 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
67430 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
67431 index 1ced641..c896ee8 100644
67432 --- a/include/asm-generic/atomic.h
67433 +++ b/include/asm-generic/atomic.h
67434 @@ -159,7 +159,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
67435 * Atomically clears the bits set in @mask from @v
67436 */
67437 #ifndef atomic_clear_mask
67438 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
67439 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
67440 {
67441 unsigned long flags;
67442
67443 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
67444 index b18ce4f..2ee2843 100644
67445 --- a/include/asm-generic/atomic64.h
67446 +++ b/include/asm-generic/atomic64.h
67447 @@ -16,6 +16,8 @@ typedef struct {
67448 long long counter;
67449 } atomic64_t;
67450
67451 +typedef atomic64_t atomic64_unchecked_t;
67452 +
67453 #define ATOMIC64_INIT(i) { (i) }
67454
67455 extern long long atomic64_read(const atomic64_t *v);
67456 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
67457 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
67458 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
67459
67460 +#define atomic64_read_unchecked(v) atomic64_read(v)
67461 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
67462 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
67463 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
67464 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
67465 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
67466 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
67467 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
67468 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
67469 +
67470 #endif /* _ASM_GENERIC_ATOMIC64_H */
67471 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
67472 index 1bfcfe5..e04c5c9 100644
67473 --- a/include/asm-generic/cache.h
67474 +++ b/include/asm-generic/cache.h
67475 @@ -6,7 +6,7 @@
67476 * cache lines need to provide their own cache.h.
67477 */
67478
67479 -#define L1_CACHE_SHIFT 5
67480 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
67481 +#define L1_CACHE_SHIFT 5UL
67482 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
67483
67484 #endif /* __ASM_GENERIC_CACHE_H */
67485 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
67486 index 0d68a1e..b74a761 100644
67487 --- a/include/asm-generic/emergency-restart.h
67488 +++ b/include/asm-generic/emergency-restart.h
67489 @@ -1,7 +1,7 @@
67490 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
67491 #define _ASM_GENERIC_EMERGENCY_RESTART_H
67492
67493 -static inline void machine_emergency_restart(void)
67494 +static inline __noreturn void machine_emergency_restart(void)
67495 {
67496 machine_restart(NULL);
67497 }
67498 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
67499 index 90f99c7..00ce236 100644
67500 --- a/include/asm-generic/kmap_types.h
67501 +++ b/include/asm-generic/kmap_types.h
67502 @@ -2,9 +2,9 @@
67503 #define _ASM_GENERIC_KMAP_TYPES_H
67504
67505 #ifdef __WITH_KM_FENCE
67506 -# define KM_TYPE_NR 41
67507 +# define KM_TYPE_NR 42
67508 #else
67509 -# define KM_TYPE_NR 20
67510 +# define KM_TYPE_NR 21
67511 #endif
67512
67513 #endif
67514 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
67515 index 9ceb03b..62b0b8f 100644
67516 --- a/include/asm-generic/local.h
67517 +++ b/include/asm-generic/local.h
67518 @@ -23,24 +23,37 @@ typedef struct
67519 atomic_long_t a;
67520 } local_t;
67521
67522 +typedef struct {
67523 + atomic_long_unchecked_t a;
67524 +} local_unchecked_t;
67525 +
67526 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
67527
67528 #define local_read(l) atomic_long_read(&(l)->a)
67529 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
67530 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
67531 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
67532 #define local_inc(l) atomic_long_inc(&(l)->a)
67533 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
67534 #define local_dec(l) atomic_long_dec(&(l)->a)
67535 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
67536 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
67537 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
67538 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
67539 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
67540
67541 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
67542 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
67543 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
67544 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
67545 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
67546 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
67547 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
67548 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
67549 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
67550
67551 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67552 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67553 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
67554 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
67555 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
67556 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
67557 index 725612b..9cc513a 100644
67558 --- a/include/asm-generic/pgtable-nopmd.h
67559 +++ b/include/asm-generic/pgtable-nopmd.h
67560 @@ -1,14 +1,19 @@
67561 #ifndef _PGTABLE_NOPMD_H
67562 #define _PGTABLE_NOPMD_H
67563
67564 -#ifndef __ASSEMBLY__
67565 -
67566 #include <asm-generic/pgtable-nopud.h>
67567
67568 -struct mm_struct;
67569 -
67570 #define __PAGETABLE_PMD_FOLDED
67571
67572 +#define PMD_SHIFT PUD_SHIFT
67573 +#define PTRS_PER_PMD 1
67574 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
67575 +#define PMD_MASK (~(PMD_SIZE-1))
67576 +
67577 +#ifndef __ASSEMBLY__
67578 +
67579 +struct mm_struct;
67580 +
67581 /*
67582 * Having the pmd type consist of a pud gets the size right, and allows
67583 * us to conceptually access the pud entry that this pmd is folded into
67584 @@ -16,11 +21,6 @@ struct mm_struct;
67585 */
67586 typedef struct { pud_t pud; } pmd_t;
67587
67588 -#define PMD_SHIFT PUD_SHIFT
67589 -#define PTRS_PER_PMD 1
67590 -#define PMD_SIZE (1UL << PMD_SHIFT)
67591 -#define PMD_MASK (~(PMD_SIZE-1))
67592 -
67593 /*
67594 * The "pud_xxx()" functions here are trivial for a folded two-level
67595 * setup: the pmd is never bad, and a pmd always exists (as it's folded
67596 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
67597 index 810431d..0ec4804f 100644
67598 --- a/include/asm-generic/pgtable-nopud.h
67599 +++ b/include/asm-generic/pgtable-nopud.h
67600 @@ -1,10 +1,15 @@
67601 #ifndef _PGTABLE_NOPUD_H
67602 #define _PGTABLE_NOPUD_H
67603
67604 -#ifndef __ASSEMBLY__
67605 -
67606 #define __PAGETABLE_PUD_FOLDED
67607
67608 +#define PUD_SHIFT PGDIR_SHIFT
67609 +#define PTRS_PER_PUD 1
67610 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
67611 +#define PUD_MASK (~(PUD_SIZE-1))
67612 +
67613 +#ifndef __ASSEMBLY__
67614 +
67615 /*
67616 * Having the pud type consist of a pgd gets the size right, and allows
67617 * us to conceptually access the pgd entry that this pud is folded into
67618 @@ -12,11 +17,6 @@
67619 */
67620 typedef struct { pgd_t pgd; } pud_t;
67621
67622 -#define PUD_SHIFT PGDIR_SHIFT
67623 -#define PTRS_PER_PUD 1
67624 -#define PUD_SIZE (1UL << PUD_SHIFT)
67625 -#define PUD_MASK (~(PUD_SIZE-1))
67626 -
67627 /*
67628 * The "pgd_xxx()" functions here are trivial for a folded two-level
67629 * setup: the pud is never bad, and a pud always exists (as it's folded
67630 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
67631 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
67632
67633 #define pgd_populate(mm, pgd, pud) do { } while (0)
67634 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
67635 /*
67636 * (puds are folded into pgds so this doesn't get actually called,
67637 * but the define is needed for a generic inline function.)
67638 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
67639 index 5cf680a..4b74d62 100644
67640 --- a/include/asm-generic/pgtable.h
67641 +++ b/include/asm-generic/pgtable.h
67642 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
67643 }
67644 #endif /* CONFIG_NUMA_BALANCING */
67645
67646 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
67647 +static inline unsigned long pax_open_kernel(void) { return 0; }
67648 +#endif
67649 +
67650 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
67651 +static inline unsigned long pax_close_kernel(void) { return 0; }
67652 +#endif
67653 +
67654 #endif /* CONFIG_MMU */
67655
67656 #endif /* !__ASSEMBLY__ */
67657 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
67658 index d1ea7ce..b1ebf2a 100644
67659 --- a/include/asm-generic/vmlinux.lds.h
67660 +++ b/include/asm-generic/vmlinux.lds.h
67661 @@ -218,6 +218,7 @@
67662 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
67663 VMLINUX_SYMBOL(__start_rodata) = .; \
67664 *(.rodata) *(.rodata.*) \
67665 + *(.data..read_only) \
67666 *(__vermagic) /* Kernel version magic */ \
67667 . = ALIGN(8); \
67668 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
67669 @@ -725,17 +726,18 @@
67670 * section in the linker script will go there too. @phdr should have
67671 * a leading colon.
67672 *
67673 - * Note that this macros defines __per_cpu_load as an absolute symbol.
67674 + * Note that this macros defines per_cpu_load as an absolute symbol.
67675 * If there is no need to put the percpu section at a predetermined
67676 * address, use PERCPU_SECTION.
67677 */
67678 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
67679 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
67680 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
67681 + per_cpu_load = .; \
67682 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
67683 - LOAD_OFFSET) { \
67684 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
67685 PERCPU_INPUT(cacheline) \
67686 } phdr \
67687 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
67688 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
67689
67690 /**
67691 * PERCPU_SECTION - define output section for percpu area, simple version
67692 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
67693 index 418d270..bfd2794 100644
67694 --- a/include/crypto/algapi.h
67695 +++ b/include/crypto/algapi.h
67696 @@ -34,7 +34,7 @@ struct crypto_type {
67697 unsigned int maskclear;
67698 unsigned int maskset;
67699 unsigned int tfmsize;
67700 -};
67701 +} __do_const;
67702
67703 struct crypto_instance {
67704 struct crypto_alg alg;
67705 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
67706 index fad21c9..ab858bc 100644
67707 --- a/include/drm/drmP.h
67708 +++ b/include/drm/drmP.h
67709 @@ -72,6 +72,7 @@
67710 #include <linux/workqueue.h>
67711 #include <linux/poll.h>
67712 #include <asm/pgalloc.h>
67713 +#include <asm/local.h>
67714 #include <drm/drm.h>
67715 #include <drm/drm_sarea.h>
67716
67717 @@ -293,10 +294,12 @@ do { \
67718 * \param cmd command.
67719 * \param arg argument.
67720 */
67721 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
67722 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
67723 + struct drm_file *file_priv);
67724 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
67725 struct drm_file *file_priv);
67726
67727 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67728 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
67729 unsigned long arg);
67730
67731 #define DRM_IOCTL_NR(n) _IOC_NR(n)
67732 @@ -311,9 +314,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67733 struct drm_ioctl_desc {
67734 unsigned int cmd;
67735 int flags;
67736 - drm_ioctl_t *func;
67737 + drm_ioctl_t func;
67738 unsigned int cmd_drv;
67739 -};
67740 +} __do_const;
67741
67742 /**
67743 * Creates a driver or general drm_ioctl_desc array entry for the given
67744 @@ -995,7 +998,7 @@ struct drm_info_list {
67745 int (*show)(struct seq_file*, void*); /** show callback */
67746 u32 driver_features; /**< Required driver features for this entry */
67747 void *data;
67748 -};
67749 +} __do_const;
67750
67751 /**
67752 * debugfs node structure. This structure represents a debugfs file.
67753 @@ -1068,7 +1071,7 @@ struct drm_device {
67754
67755 /** \name Usage Counters */
67756 /*@{ */
67757 - int open_count; /**< Outstanding files open */
67758 + local_t open_count; /**< Outstanding files open */
67759 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
67760 atomic_t vma_count; /**< Outstanding vma areas open */
67761 int buf_use; /**< Buffers in use -- cannot alloc */
67762 @@ -1079,7 +1082,7 @@ struct drm_device {
67763 /*@{ */
67764 unsigned long counters;
67765 enum drm_stat_type types[15];
67766 - atomic_t counts[15];
67767 + atomic_unchecked_t counts[15];
67768 /*@} */
67769
67770 struct list_head filelist;
67771 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
67772 index f43d556..94d9343 100644
67773 --- a/include/drm/drm_crtc_helper.h
67774 +++ b/include/drm/drm_crtc_helper.h
67775 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
67776 struct drm_connector *connector);
67777 /* disable encoder when not in use - more explicit than dpms off */
67778 void (*disable)(struct drm_encoder *encoder);
67779 -};
67780 +} __no_const;
67781
67782 /**
67783 * drm_connector_helper_funcs - helper operations for connectors
67784 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
67785 index 72dcbe8..8db58d7 100644
67786 --- a/include/drm/ttm/ttm_memory.h
67787 +++ b/include/drm/ttm/ttm_memory.h
67788 @@ -48,7 +48,7 @@
67789
67790 struct ttm_mem_shrink {
67791 int (*do_shrink) (struct ttm_mem_shrink *);
67792 -};
67793 +} __no_const;
67794
67795 /**
67796 * struct ttm_mem_global - Global memory accounting structure.
67797 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
67798 index 4b840e8..155d235 100644
67799 --- a/include/keys/asymmetric-subtype.h
67800 +++ b/include/keys/asymmetric-subtype.h
67801 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
67802 /* Verify the signature on a key of this subtype (optional) */
67803 int (*verify_signature)(const struct key *key,
67804 const struct public_key_signature *sig);
67805 -};
67806 +} __do_const;
67807
67808 /**
67809 * asymmetric_key_subtype - Get the subtype from an asymmetric key
67810 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
67811 index c1da539..1dcec55 100644
67812 --- a/include/linux/atmdev.h
67813 +++ b/include/linux/atmdev.h
67814 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
67815 #endif
67816
67817 struct k_atm_aal_stats {
67818 -#define __HANDLE_ITEM(i) atomic_t i
67819 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
67820 __AAL_STAT_ITEMS
67821 #undef __HANDLE_ITEM
67822 };
67823 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
67824 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
67825 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
67826 struct module *owner;
67827 -};
67828 +} __do_const ;
67829
67830 struct atmphy_ops {
67831 int (*start)(struct atm_dev *dev);
67832 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
67833 index 0530b98..96a8ac0 100644
67834 --- a/include/linux/binfmts.h
67835 +++ b/include/linux/binfmts.h
67836 @@ -73,8 +73,9 @@ struct linux_binfmt {
67837 int (*load_binary)(struct linux_binprm *);
67838 int (*load_shlib)(struct file *);
67839 int (*core_dump)(struct coredump_params *cprm);
67840 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
67841 unsigned long min_coredump; /* minimal dump size */
67842 -};
67843 +} __do_const;
67844
67845 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
67846
67847 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
67848 index f94bc83..62b9cfe 100644
67849 --- a/include/linux/blkdev.h
67850 +++ b/include/linux/blkdev.h
67851 @@ -1498,7 +1498,7 @@ struct block_device_operations {
67852 /* this callback is with swap_lock and sometimes page table lock held */
67853 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
67854 struct module *owner;
67855 -};
67856 +} __do_const;
67857
67858 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
67859 unsigned long);
67860 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
67861 index 7c2e030..b72475d 100644
67862 --- a/include/linux/blktrace_api.h
67863 +++ b/include/linux/blktrace_api.h
67864 @@ -23,7 +23,7 @@ struct blk_trace {
67865 struct dentry *dir;
67866 struct dentry *dropped_file;
67867 struct dentry *msg_file;
67868 - atomic_t dropped;
67869 + atomic_unchecked_t dropped;
67870 };
67871
67872 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
67873 diff --git a/include/linux/cache.h b/include/linux/cache.h
67874 index 4c57065..4307975 100644
67875 --- a/include/linux/cache.h
67876 +++ b/include/linux/cache.h
67877 @@ -16,6 +16,10 @@
67878 #define __read_mostly
67879 #endif
67880
67881 +#ifndef __read_only
67882 +#define __read_only __read_mostly
67883 +#endif
67884 +
67885 #ifndef ____cacheline_aligned
67886 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
67887 #endif
67888 diff --git a/include/linux/capability.h b/include/linux/capability.h
67889 index 98503b7..cc36d18 100644
67890 --- a/include/linux/capability.h
67891 +++ b/include/linux/capability.h
67892 @@ -211,8 +211,13 @@ extern bool capable(int cap);
67893 extern bool ns_capable(struct user_namespace *ns, int cap);
67894 extern bool nsown_capable(int cap);
67895 extern bool inode_capable(const struct inode *inode, int cap);
67896 +extern bool capable_nolog(int cap);
67897 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
67898 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
67899
67900 /* audit system wants to get cap info from files as well */
67901 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
67902
67903 +extern int is_privileged_binary(const struct dentry *dentry);
67904 +
67905 #endif /* !_LINUX_CAPABILITY_H */
67906 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
67907 index 8609d57..86e4d79 100644
67908 --- a/include/linux/cdrom.h
67909 +++ b/include/linux/cdrom.h
67910 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
67911
67912 /* driver specifications */
67913 const int capability; /* capability flags */
67914 - int n_minors; /* number of active minor devices */
67915 /* handle uniform packets for scsi type devices (scsi,atapi) */
67916 int (*generic_packet) (struct cdrom_device_info *,
67917 struct packet_command *);
67918 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
67919 index 42e55de..1cd0e66 100644
67920 --- a/include/linux/cleancache.h
67921 +++ b/include/linux/cleancache.h
67922 @@ -31,7 +31,7 @@ struct cleancache_ops {
67923 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
67924 void (*invalidate_inode)(int, struct cleancache_filekey);
67925 void (*invalidate_fs)(int);
67926 -};
67927 +} __no_const;
67928
67929 extern struct cleancache_ops
67930 cleancache_register_ops(struct cleancache_ops *ops);
67931 diff --git a/include/linux/compat.h b/include/linux/compat.h
67932 index dec7e2d..45db13f 100644
67933 --- a/include/linux/compat.h
67934 +++ b/include/linux/compat.h
67935 @@ -311,14 +311,14 @@ long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
67936 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
67937 int version, void __user *uptr);
67938 long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
67939 - void __user *uptr);
67940 + void __user *uptr) __intentional_overflow(0);
67941 #else
67942 long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
67943 long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
67944 compat_ssize_t msgsz, int msgflg);
67945 long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
67946 compat_ssize_t msgsz, long msgtyp, int msgflg);
67947 -long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
67948 +long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
67949 #endif
67950 long compat_sys_msgctl(int first, int second, void __user *uptr);
67951 long compat_sys_shmctl(int first, int second, void __user *uptr);
67952 @@ -414,7 +414,7 @@ extern int compat_ptrace_request(struct task_struct *child,
67953 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
67954 compat_ulong_t addr, compat_ulong_t data);
67955 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
67956 - compat_long_t addr, compat_long_t data);
67957 + compat_ulong_t addr, compat_ulong_t data);
67958
67959 /*
67960 * epoll (fs/eventpoll.c) compat bits follow ...
67961 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
67962 index 662fd1b..e801992 100644
67963 --- a/include/linux/compiler-gcc4.h
67964 +++ b/include/linux/compiler-gcc4.h
67965 @@ -34,6 +34,21 @@
67966 #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
67967
67968 #if __GNUC_MINOR__ >= 5
67969 +
67970 +#ifdef CONSTIFY_PLUGIN
67971 +#define __no_const __attribute__((no_const))
67972 +#define __do_const __attribute__((do_const))
67973 +#endif
67974 +
67975 +#ifdef SIZE_OVERFLOW_PLUGIN
67976 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
67977 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
67978 +#endif
67979 +
67980 +#ifdef LATENT_ENTROPY_PLUGIN
67981 +#define __latent_entropy __attribute__((latent_entropy))
67982 +#endif
67983 +
67984 /*
67985 * Mark a position in code as unreachable. This can be used to
67986 * suppress control flow warnings after asm blocks that transfer
67987 @@ -49,6 +64,11 @@
67988 #define __noclone __attribute__((__noclone__))
67989
67990 #endif
67991 +
67992 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
67993 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
67994 +#define __bos0(ptr) __bos((ptr), 0)
67995 +#define __bos1(ptr) __bos((ptr), 1)
67996 #endif
67997
67998 #if __GNUC_MINOR__ >= 6
67999 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
68000 index dd852b7..1ad5fba 100644
68001 --- a/include/linux/compiler.h
68002 +++ b/include/linux/compiler.h
68003 @@ -5,11 +5,14 @@
68004
68005 #ifdef __CHECKER__
68006 # define __user __attribute__((noderef, address_space(1)))
68007 +# define __force_user __force __user
68008 # define __kernel __attribute__((address_space(0)))
68009 +# define __force_kernel __force __kernel
68010 # define __safe __attribute__((safe))
68011 # define __force __attribute__((force))
68012 # define __nocast __attribute__((nocast))
68013 # define __iomem __attribute__((noderef, address_space(2)))
68014 +# define __force_iomem __force __iomem
68015 # define __must_hold(x) __attribute__((context(x,1,1)))
68016 # define __acquires(x) __attribute__((context(x,0,1)))
68017 # define __releases(x) __attribute__((context(x,1,0)))
68018 @@ -17,20 +20,37 @@
68019 # define __release(x) __context__(x,-1)
68020 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
68021 # define __percpu __attribute__((noderef, address_space(3)))
68022 +# define __force_percpu __force __percpu
68023 #ifdef CONFIG_SPARSE_RCU_POINTER
68024 # define __rcu __attribute__((noderef, address_space(4)))
68025 +# define __force_rcu __force __rcu
68026 #else
68027 # define __rcu
68028 +# define __force_rcu
68029 #endif
68030 extern void __chk_user_ptr(const volatile void __user *);
68031 extern void __chk_io_ptr(const volatile void __iomem *);
68032 #else
68033 -# define __user
68034 -# define __kernel
68035 +# ifdef CHECKER_PLUGIN
68036 +//# define __user
68037 +//# define __force_user
68038 +//# define __kernel
68039 +//# define __force_kernel
68040 +# else
68041 +# ifdef STRUCTLEAK_PLUGIN
68042 +# define __user __attribute__((user))
68043 +# else
68044 +# define __user
68045 +# endif
68046 +# define __force_user
68047 +# define __kernel
68048 +# define __force_kernel
68049 +# endif
68050 # define __safe
68051 # define __force
68052 # define __nocast
68053 # define __iomem
68054 +# define __force_iomem
68055 # define __chk_user_ptr(x) (void)0
68056 # define __chk_io_ptr(x) (void)0
68057 # define __builtin_warning(x, y...) (1)
68058 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
68059 # define __release(x) (void)0
68060 # define __cond_lock(x,c) (c)
68061 # define __percpu
68062 +# define __force_percpu
68063 # define __rcu
68064 +# define __force_rcu
68065 #endif
68066
68067 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
68068 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68069 # define __attribute_const__ /* unimplemented */
68070 #endif
68071
68072 +#ifndef __no_const
68073 +# define __no_const
68074 +#endif
68075 +
68076 +#ifndef __do_const
68077 +# define __do_const
68078 +#endif
68079 +
68080 +#ifndef __size_overflow
68081 +# define __size_overflow(...)
68082 +#endif
68083 +
68084 +#ifndef __intentional_overflow
68085 +# define __intentional_overflow(...)
68086 +#endif
68087 +
68088 +#ifndef __latent_entropy
68089 +# define __latent_entropy
68090 +#endif
68091 +
68092 /*
68093 * Tell gcc if a function is cold. The compiler will assume any path
68094 * directly leading to the call is unlikely.
68095 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68096 #define __cold
68097 #endif
68098
68099 +#ifndef __alloc_size
68100 +#define __alloc_size(...)
68101 +#endif
68102 +
68103 +#ifndef __bos
68104 +#define __bos(ptr, arg)
68105 +#endif
68106 +
68107 +#ifndef __bos0
68108 +#define __bos0(ptr)
68109 +#endif
68110 +
68111 +#ifndef __bos1
68112 +#define __bos1(ptr)
68113 +#endif
68114 +
68115 /* Simple shorthand for a section definition */
68116 #ifndef __section
68117 # define __section(S) __attribute__ ((__section__(#S)))
68118 @@ -323,6 +381,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68119 * use is to mediate communication between process-level code and irq/NMI
68120 * handlers, all running on the same CPU.
68121 */
68122 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
68123 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
68124 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
68125
68126 #endif /* __LINUX_COMPILER_H */
68127 diff --git a/include/linux/completion.h b/include/linux/completion.h
68128 index 51494e6..0fd1b61 100644
68129 --- a/include/linux/completion.h
68130 +++ b/include/linux/completion.h
68131 @@ -78,13 +78,13 @@ static inline void init_completion(struct completion *x)
68132
68133 extern void wait_for_completion(struct completion *);
68134 extern int wait_for_completion_interruptible(struct completion *x);
68135 -extern int wait_for_completion_killable(struct completion *x);
68136 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
68137 extern unsigned long wait_for_completion_timeout(struct completion *x,
68138 unsigned long timeout);
68139 extern long wait_for_completion_interruptible_timeout(
68140 - struct completion *x, unsigned long timeout);
68141 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68142 extern long wait_for_completion_killable_timeout(
68143 - struct completion *x, unsigned long timeout);
68144 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68145 extern bool try_wait_for_completion(struct completion *x);
68146 extern bool completion_done(struct completion *x);
68147
68148 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
68149 index 34025df..d94bbbc 100644
68150 --- a/include/linux/configfs.h
68151 +++ b/include/linux/configfs.h
68152 @@ -125,7 +125,7 @@ struct configfs_attribute {
68153 const char *ca_name;
68154 struct module *ca_owner;
68155 umode_t ca_mode;
68156 -};
68157 +} __do_const;
68158
68159 /*
68160 * Users often need to create attribute structures for their configurable
68161 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
68162 index ce7a074..01ab8ac 100644
68163 --- a/include/linux/cpu.h
68164 +++ b/include/linux/cpu.h
68165 @@ -115,7 +115,7 @@ enum {
68166 /* Need to know about CPUs going up/down? */
68167 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
68168 #define cpu_notifier(fn, pri) { \
68169 - static struct notifier_block fn##_nb __cpuinitdata = \
68170 + static struct notifier_block fn##_nb = \
68171 { .notifier_call = fn, .priority = pri }; \
68172 register_cpu_notifier(&fn##_nb); \
68173 }
68174 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
68175 index a55b88e..fba90c5 100644
68176 --- a/include/linux/cpufreq.h
68177 +++ b/include/linux/cpufreq.h
68178 @@ -240,7 +240,7 @@ struct cpufreq_driver {
68179 int (*suspend) (struct cpufreq_policy *policy);
68180 int (*resume) (struct cpufreq_policy *policy);
68181 struct freq_attr **attr;
68182 -};
68183 +} __do_const;
68184
68185 /* flags */
68186
68187 @@ -299,6 +299,7 @@ struct global_attr {
68188 ssize_t (*store)(struct kobject *a, struct attribute *b,
68189 const char *c, size_t count);
68190 };
68191 +typedef struct global_attr __no_const global_attr_no_const;
68192
68193 #define define_one_global_ro(_name) \
68194 static struct global_attr _name = \
68195 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
68196 index 24cd1037..20a63aae 100644
68197 --- a/include/linux/cpuidle.h
68198 +++ b/include/linux/cpuidle.h
68199 @@ -54,7 +54,8 @@ struct cpuidle_state {
68200 int index);
68201
68202 int (*enter_dead) (struct cpuidle_device *dev, int index);
68203 -};
68204 +} __do_const;
68205 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
68206
68207 /* Idle State Flags */
68208 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
68209 @@ -216,7 +217,7 @@ struct cpuidle_governor {
68210 void (*reflect) (struct cpuidle_device *dev, int index);
68211
68212 struct module *owner;
68213 -};
68214 +} __do_const;
68215
68216 #ifdef CONFIG_CPU_IDLE
68217
68218 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
68219 index 0325602..5e9feff 100644
68220 --- a/include/linux/cpumask.h
68221 +++ b/include/linux/cpumask.h
68222 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68223 }
68224
68225 /* Valid inputs for n are -1 and 0. */
68226 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68227 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68228 {
68229 return n+1;
68230 }
68231
68232 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68233 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68234 {
68235 return n+1;
68236 }
68237
68238 -static inline unsigned int cpumask_next_and(int n,
68239 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
68240 const struct cpumask *srcp,
68241 const struct cpumask *andp)
68242 {
68243 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68244 *
68245 * Returns >= nr_cpu_ids if no further cpus set.
68246 */
68247 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68248 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68249 {
68250 /* -1 is a legal arg here. */
68251 if (n != -1)
68252 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68253 *
68254 * Returns >= nr_cpu_ids if no further cpus unset.
68255 */
68256 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68257 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68258 {
68259 /* -1 is a legal arg here. */
68260 if (n != -1)
68261 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68262 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
68263 }
68264
68265 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
68266 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
68267 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
68268
68269 /**
68270 diff --git a/include/linux/cred.h b/include/linux/cred.h
68271 index 04421e8..6bce4ef 100644
68272 --- a/include/linux/cred.h
68273 +++ b/include/linux/cred.h
68274 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
68275 static inline void validate_process_creds(void)
68276 {
68277 }
68278 +static inline void validate_task_creds(struct task_struct *task)
68279 +{
68280 +}
68281 #endif
68282
68283 /**
68284 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
68285 index b92eadf..b4ecdc1 100644
68286 --- a/include/linux/crypto.h
68287 +++ b/include/linux/crypto.h
68288 @@ -373,7 +373,7 @@ struct cipher_tfm {
68289 const u8 *key, unsigned int keylen);
68290 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68291 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68292 -};
68293 +} __no_const;
68294
68295 struct hash_tfm {
68296 int (*init)(struct hash_desc *desc);
68297 @@ -394,13 +394,13 @@ struct compress_tfm {
68298 int (*cot_decompress)(struct crypto_tfm *tfm,
68299 const u8 *src, unsigned int slen,
68300 u8 *dst, unsigned int *dlen);
68301 -};
68302 +} __no_const;
68303
68304 struct rng_tfm {
68305 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
68306 unsigned int dlen);
68307 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
68308 -};
68309 +} __no_const;
68310
68311 #define crt_ablkcipher crt_u.ablkcipher
68312 #define crt_aead crt_u.aead
68313 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
68314 index 8acfe31..6ffccd63 100644
68315 --- a/include/linux/ctype.h
68316 +++ b/include/linux/ctype.h
68317 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
68318 * Fast implementation of tolower() for internal usage. Do not use in your
68319 * code.
68320 */
68321 -static inline char _tolower(const char c)
68322 +static inline unsigned char _tolower(const unsigned char c)
68323 {
68324 return c | 0x20;
68325 }
68326 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
68327 index 7925bf0..d5143d2 100644
68328 --- a/include/linux/decompress/mm.h
68329 +++ b/include/linux/decompress/mm.h
68330 @@ -77,7 +77,7 @@ static void free(void *where)
68331 * warnings when not needed (indeed large_malloc / large_free are not
68332 * needed by inflate */
68333
68334 -#define malloc(a) kmalloc(a, GFP_KERNEL)
68335 +#define malloc(a) kmalloc((a), GFP_KERNEL)
68336 #define free(a) kfree(a)
68337
68338 #define large_malloc(a) vmalloc(a)
68339 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
68340 index e83ef39..33e0eb3 100644
68341 --- a/include/linux/devfreq.h
68342 +++ b/include/linux/devfreq.h
68343 @@ -114,7 +114,7 @@ struct devfreq_governor {
68344 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
68345 int (*event_handler)(struct devfreq *devfreq,
68346 unsigned int event, void *data);
68347 -};
68348 +} __do_const;
68349
68350 /**
68351 * struct devfreq - Device devfreq structure
68352 diff --git a/include/linux/device.h b/include/linux/device.h
68353 index 43dcda9..7a1fb65 100644
68354 --- a/include/linux/device.h
68355 +++ b/include/linux/device.h
68356 @@ -294,7 +294,7 @@ struct subsys_interface {
68357 struct list_head node;
68358 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
68359 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
68360 -};
68361 +} __do_const;
68362
68363 int subsys_interface_register(struct subsys_interface *sif);
68364 void subsys_interface_unregister(struct subsys_interface *sif);
68365 @@ -474,7 +474,7 @@ struct device_type {
68366 void (*release)(struct device *dev);
68367
68368 const struct dev_pm_ops *pm;
68369 -};
68370 +} __do_const;
68371
68372 /* interface for exporting device attributes */
68373 struct device_attribute {
68374 @@ -484,11 +484,12 @@ struct device_attribute {
68375 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
68376 const char *buf, size_t count);
68377 };
68378 +typedef struct device_attribute __no_const device_attribute_no_const;
68379
68380 struct dev_ext_attribute {
68381 struct device_attribute attr;
68382 void *var;
68383 -};
68384 +} __do_const;
68385
68386 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
68387 char *buf);
68388 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
68389 index 94af418..b1ca7a2 100644
68390 --- a/include/linux/dma-mapping.h
68391 +++ b/include/linux/dma-mapping.h
68392 @@ -54,7 +54,7 @@ struct dma_map_ops {
68393 u64 (*get_required_mask)(struct device *dev);
68394 #endif
68395 int is_phys;
68396 -};
68397 +} __do_const;
68398
68399 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
68400
68401 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
68402 index d3201e4..8281e63 100644
68403 --- a/include/linux/dmaengine.h
68404 +++ b/include/linux/dmaengine.h
68405 @@ -1018,9 +1018,9 @@ struct dma_pinned_list {
68406 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
68407 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
68408
68409 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68410 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68411 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
68412 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68413 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68414 struct dma_pinned_list *pinned_list, struct page *page,
68415 unsigned int offset, size_t len);
68416
68417 diff --git a/include/linux/efi.h b/include/linux/efi.h
68418 index 7a9498a..155713d 100644
68419 --- a/include/linux/efi.h
68420 +++ b/include/linux/efi.h
68421 @@ -733,6 +733,7 @@ struct efivar_operations {
68422 efi_set_variable_t *set_variable;
68423 efi_query_variable_info_t *query_variable_info;
68424 };
68425 +typedef struct efivar_operations __no_const efivar_operations_no_const;
68426
68427 struct efivars {
68428 /*
68429 diff --git a/include/linux/elf.h b/include/linux/elf.h
68430 index 8c9048e..16a4665 100644
68431 --- a/include/linux/elf.h
68432 +++ b/include/linux/elf.h
68433 @@ -20,6 +20,7 @@ extern Elf32_Dyn _DYNAMIC [];
68434 #define elf_note elf32_note
68435 #define elf_addr_t Elf32_Off
68436 #define Elf_Half Elf32_Half
68437 +#define elf_dyn Elf32_Dyn
68438
68439 #else
68440
68441 @@ -30,6 +31,7 @@ extern Elf64_Dyn _DYNAMIC [];
68442 #define elf_note elf64_note
68443 #define elf_addr_t Elf64_Off
68444 #define Elf_Half Elf64_Half
68445 +#define elf_dyn Elf64_Dyn
68446
68447 #endif
68448
68449 diff --git a/include/linux/err.h b/include/linux/err.h
68450 index f2edce2..cc2082c 100644
68451 --- a/include/linux/err.h
68452 +++ b/include/linux/err.h
68453 @@ -19,12 +19,12 @@
68454
68455 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
68456
68457 -static inline void * __must_check ERR_PTR(long error)
68458 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
68459 {
68460 return (void *) error;
68461 }
68462
68463 -static inline long __must_check PTR_ERR(const void *ptr)
68464 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
68465 {
68466 return (long) ptr;
68467 }
68468 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
68469 index fcb51c8..bdafcf6 100644
68470 --- a/include/linux/extcon.h
68471 +++ b/include/linux/extcon.h
68472 @@ -134,7 +134,7 @@ struct extcon_dev {
68473 /* /sys/class/extcon/.../mutually_exclusive/... */
68474 struct attribute_group attr_g_muex;
68475 struct attribute **attrs_muex;
68476 - struct device_attribute *d_attrs_muex;
68477 + device_attribute_no_const *d_attrs_muex;
68478 };
68479
68480 /**
68481 diff --git a/include/linux/fb.h b/include/linux/fb.h
68482 index c7a9571..02eeffe 100644
68483 --- a/include/linux/fb.h
68484 +++ b/include/linux/fb.h
68485 @@ -302,7 +302,7 @@ struct fb_ops {
68486 /* called at KDB enter and leave time to prepare the console */
68487 int (*fb_debug_enter)(struct fb_info *info);
68488 int (*fb_debug_leave)(struct fb_info *info);
68489 -};
68490 +} __do_const;
68491
68492 #ifdef CONFIG_FB_TILEBLITTING
68493 #define FB_TILE_CURSOR_NONE 0
68494 diff --git a/include/linux/filter.h b/include/linux/filter.h
68495 index c45eabc..baa0be5 100644
68496 --- a/include/linux/filter.h
68497 +++ b/include/linux/filter.h
68498 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
68499
68500 struct sk_buff;
68501 struct sock;
68502 +struct bpf_jit_work;
68503
68504 struct sk_filter
68505 {
68506 @@ -27,6 +28,9 @@ struct sk_filter
68507 unsigned int len; /* Number of filter blocks */
68508 unsigned int (*bpf_func)(const struct sk_buff *skb,
68509 const struct sock_filter *filter);
68510 +#ifdef CONFIG_BPF_JIT
68511 + struct bpf_jit_work *work;
68512 +#endif
68513 struct rcu_head rcu;
68514 struct sock_filter insns[0];
68515 };
68516 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
68517 index 3044254..9767f41 100644
68518 --- a/include/linux/frontswap.h
68519 +++ b/include/linux/frontswap.h
68520 @@ -11,7 +11,7 @@ struct frontswap_ops {
68521 int (*load)(unsigned, pgoff_t, struct page *);
68522 void (*invalidate_page)(unsigned, pgoff_t);
68523 void (*invalidate_area)(unsigned);
68524 -};
68525 +} __no_const;
68526
68527 extern bool frontswap_enabled;
68528 extern struct frontswap_ops
68529 diff --git a/include/linux/fs.h b/include/linux/fs.h
68530 index 7617ee0..b575199 100644
68531 --- a/include/linux/fs.h
68532 +++ b/include/linux/fs.h
68533 @@ -1541,7 +1541,8 @@ struct file_operations {
68534 long (*fallocate)(struct file *file, int mode, loff_t offset,
68535 loff_t len);
68536 int (*show_fdinfo)(struct seq_file *m, struct file *f);
68537 -};
68538 +} __do_const;
68539 +typedef struct file_operations __no_const file_operations_no_const;
68540
68541 struct inode_operations {
68542 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
68543 @@ -2665,4 +2666,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
68544 inode->i_flags |= S_NOSEC;
68545 }
68546
68547 +static inline bool is_sidechannel_device(const struct inode *inode)
68548 +{
68549 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
68550 + umode_t mode = inode->i_mode;
68551 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
68552 +#else
68553 + return false;
68554 +#endif
68555 +}
68556 +
68557 #endif /* _LINUX_FS_H */
68558 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
68559 index 324f931..f292b65 100644
68560 --- a/include/linux/fs_struct.h
68561 +++ b/include/linux/fs_struct.h
68562 @@ -6,7 +6,7 @@
68563 #include <linux/seqlock.h>
68564
68565 struct fs_struct {
68566 - int users;
68567 + atomic_t users;
68568 spinlock_t lock;
68569 seqcount_t seq;
68570 int umask;
68571 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
68572 index 5dfa0aa..6acf322 100644
68573 --- a/include/linux/fscache-cache.h
68574 +++ b/include/linux/fscache-cache.h
68575 @@ -112,7 +112,7 @@ struct fscache_operation {
68576 fscache_operation_release_t release;
68577 };
68578
68579 -extern atomic_t fscache_op_debug_id;
68580 +extern atomic_unchecked_t fscache_op_debug_id;
68581 extern void fscache_op_work_func(struct work_struct *work);
68582
68583 extern void fscache_enqueue_operation(struct fscache_operation *);
68584 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
68585 INIT_WORK(&op->work, fscache_op_work_func);
68586 atomic_set(&op->usage, 1);
68587 op->state = FSCACHE_OP_ST_INITIALISED;
68588 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
68589 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
68590 op->processor = processor;
68591 op->release = release;
68592 INIT_LIST_HEAD(&op->pend_link);
68593 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
68594 index 7a08623..4c07b0f 100644
68595 --- a/include/linux/fscache.h
68596 +++ b/include/linux/fscache.h
68597 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
68598 * - this is mandatory for any object that may have data
68599 */
68600 void (*now_uncached)(void *cookie_netfs_data);
68601 -};
68602 +} __do_const;
68603
68604 /*
68605 * fscache cached network filesystem type
68606 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
68607 index 0fbfb46..508eb0d 100644
68608 --- a/include/linux/fsnotify.h
68609 +++ b/include/linux/fsnotify.h
68610 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
68611 struct inode *inode = path->dentry->d_inode;
68612 __u32 mask = FS_ACCESS;
68613
68614 + if (is_sidechannel_device(inode))
68615 + return;
68616 +
68617 if (S_ISDIR(inode->i_mode))
68618 mask |= FS_ISDIR;
68619
68620 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
68621 struct inode *inode = path->dentry->d_inode;
68622 __u32 mask = FS_MODIFY;
68623
68624 + if (is_sidechannel_device(inode))
68625 + return;
68626 +
68627 if (S_ISDIR(inode->i_mode))
68628 mask |= FS_ISDIR;
68629
68630 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
68631 */
68632 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
68633 {
68634 - return kstrdup(name, GFP_KERNEL);
68635 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
68636 }
68637
68638 /*
68639 diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
68640 index a3d4895..ddd2a50 100644
68641 --- a/include/linux/ftrace_event.h
68642 +++ b/include/linux/ftrace_event.h
68643 @@ -272,7 +272,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
68644 extern int trace_add_event_call(struct ftrace_event_call *call);
68645 extern void trace_remove_event_call(struct ftrace_event_call *call);
68646
68647 -#define is_signed_type(type) (((type)(-1)) < 0)
68648 +#define is_signed_type(type) (((type)(-1)) < (type)1)
68649
68650 int trace_set_clr_event(const char *system, const char *event, int set);
68651
68652 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
68653 index 79b8bba..86b539e 100644
68654 --- a/include/linux/genhd.h
68655 +++ b/include/linux/genhd.h
68656 @@ -194,7 +194,7 @@ struct gendisk {
68657 struct kobject *slave_dir;
68658
68659 struct timer_rand_state *random;
68660 - atomic_t sync_io; /* RAID */
68661 + atomic_unchecked_t sync_io; /* RAID */
68662 struct disk_events *ev;
68663 #ifdef CONFIG_BLK_DEV_INTEGRITY
68664 struct blk_integrity *integrity;
68665 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
68666 index 023bc34..b02b46a 100644
68667 --- a/include/linux/genl_magic_func.h
68668 +++ b/include/linux/genl_magic_func.h
68669 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
68670 },
68671
68672 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
68673 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
68674 +static struct genl_ops ZZZ_genl_ops[] = {
68675 #include GENL_MAGIC_INCLUDE_FILE
68676 };
68677
68678 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
68679 index 0f615eb..5c3832f 100644
68680 --- a/include/linux/gfp.h
68681 +++ b/include/linux/gfp.h
68682 @@ -35,6 +35,13 @@ struct vm_area_struct;
68683 #define ___GFP_NO_KSWAPD 0x400000u
68684 #define ___GFP_OTHER_NODE 0x800000u
68685 #define ___GFP_WRITE 0x1000000u
68686 +
68687 +#ifdef CONFIG_PAX_USERCOPY_SLABS
68688 +#define ___GFP_USERCOPY 0x2000000u
68689 +#else
68690 +#define ___GFP_USERCOPY 0
68691 +#endif
68692 +
68693 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
68694
68695 /*
68696 @@ -92,6 +99,7 @@ struct vm_area_struct;
68697 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
68698 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
68699 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
68700 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
68701
68702 /*
68703 * This may seem redundant, but it's a way of annotating false positives vs.
68704 @@ -99,7 +107,7 @@ struct vm_area_struct;
68705 */
68706 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
68707
68708 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
68709 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
68710 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
68711
68712 /* This equals 0, but use constants in case they ever change */
68713 @@ -153,6 +161,8 @@ struct vm_area_struct;
68714 /* 4GB DMA on some platforms */
68715 #define GFP_DMA32 __GFP_DMA32
68716
68717 +#define GFP_USERCOPY __GFP_USERCOPY
68718 +
68719 /* Convert GFP flags to their corresponding migrate type */
68720 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
68721 {
68722 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
68723 new file mode 100644
68724 index 0000000..ebe6d72
68725 --- /dev/null
68726 +++ b/include/linux/gracl.h
68727 @@ -0,0 +1,319 @@
68728 +#ifndef GR_ACL_H
68729 +#define GR_ACL_H
68730 +
68731 +#include <linux/grdefs.h>
68732 +#include <linux/resource.h>
68733 +#include <linux/capability.h>
68734 +#include <linux/dcache.h>
68735 +#include <asm/resource.h>
68736 +
68737 +/* Major status information */
68738 +
68739 +#define GR_VERSION "grsecurity 2.9.1"
68740 +#define GRSECURITY_VERSION 0x2901
68741 +
68742 +enum {
68743 + GR_SHUTDOWN = 0,
68744 + GR_ENABLE = 1,
68745 + GR_SPROLE = 2,
68746 + GR_RELOAD = 3,
68747 + GR_SEGVMOD = 4,
68748 + GR_STATUS = 5,
68749 + GR_UNSPROLE = 6,
68750 + GR_PASSSET = 7,
68751 + GR_SPROLEPAM = 8,
68752 +};
68753 +
68754 +/* Password setup definitions
68755 + * kernel/grhash.c */
68756 +enum {
68757 + GR_PW_LEN = 128,
68758 + GR_SALT_LEN = 16,
68759 + GR_SHA_LEN = 32,
68760 +};
68761 +
68762 +enum {
68763 + GR_SPROLE_LEN = 64,
68764 +};
68765 +
68766 +enum {
68767 + GR_NO_GLOB = 0,
68768 + GR_REG_GLOB,
68769 + GR_CREATE_GLOB
68770 +};
68771 +
68772 +#define GR_NLIMITS 32
68773 +
68774 +/* Begin Data Structures */
68775 +
68776 +struct sprole_pw {
68777 + unsigned char *rolename;
68778 + unsigned char salt[GR_SALT_LEN];
68779 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
68780 +};
68781 +
68782 +struct name_entry {
68783 + __u32 key;
68784 + ino_t inode;
68785 + dev_t device;
68786 + char *name;
68787 + __u16 len;
68788 + __u8 deleted;
68789 + struct name_entry *prev;
68790 + struct name_entry *next;
68791 +};
68792 +
68793 +struct inodev_entry {
68794 + struct name_entry *nentry;
68795 + struct inodev_entry *prev;
68796 + struct inodev_entry *next;
68797 +};
68798 +
68799 +struct acl_role_db {
68800 + struct acl_role_label **r_hash;
68801 + __u32 r_size;
68802 +};
68803 +
68804 +struct inodev_db {
68805 + struct inodev_entry **i_hash;
68806 + __u32 i_size;
68807 +};
68808 +
68809 +struct name_db {
68810 + struct name_entry **n_hash;
68811 + __u32 n_size;
68812 +};
68813 +
68814 +struct crash_uid {
68815 + uid_t uid;
68816 + unsigned long expires;
68817 +};
68818 +
68819 +struct gr_hash_struct {
68820 + void **table;
68821 + void **nametable;
68822 + void *first;
68823 + __u32 table_size;
68824 + __u32 used_size;
68825 + int type;
68826 +};
68827 +
68828 +/* Userspace Grsecurity ACL data structures */
68829 +
68830 +struct acl_subject_label {
68831 + char *filename;
68832 + ino_t inode;
68833 + dev_t device;
68834 + __u32 mode;
68835 + kernel_cap_t cap_mask;
68836 + kernel_cap_t cap_lower;
68837 + kernel_cap_t cap_invert_audit;
68838 +
68839 + struct rlimit res[GR_NLIMITS];
68840 + __u32 resmask;
68841 +
68842 + __u8 user_trans_type;
68843 + __u8 group_trans_type;
68844 + uid_t *user_transitions;
68845 + gid_t *group_transitions;
68846 + __u16 user_trans_num;
68847 + __u16 group_trans_num;
68848 +
68849 + __u32 sock_families[2];
68850 + __u32 ip_proto[8];
68851 + __u32 ip_type;
68852 + struct acl_ip_label **ips;
68853 + __u32 ip_num;
68854 + __u32 inaddr_any_override;
68855 +
68856 + __u32 crashes;
68857 + unsigned long expires;
68858 +
68859 + struct acl_subject_label *parent_subject;
68860 + struct gr_hash_struct *hash;
68861 + struct acl_subject_label *prev;
68862 + struct acl_subject_label *next;
68863 +
68864 + struct acl_object_label **obj_hash;
68865 + __u32 obj_hash_size;
68866 + __u16 pax_flags;
68867 +};
68868 +
68869 +struct role_allowed_ip {
68870 + __u32 addr;
68871 + __u32 netmask;
68872 +
68873 + struct role_allowed_ip *prev;
68874 + struct role_allowed_ip *next;
68875 +};
68876 +
68877 +struct role_transition {
68878 + char *rolename;
68879 +
68880 + struct role_transition *prev;
68881 + struct role_transition *next;
68882 +};
68883 +
68884 +struct acl_role_label {
68885 + char *rolename;
68886 + uid_t uidgid;
68887 + __u16 roletype;
68888 +
68889 + __u16 auth_attempts;
68890 + unsigned long expires;
68891 +
68892 + struct acl_subject_label *root_label;
68893 + struct gr_hash_struct *hash;
68894 +
68895 + struct acl_role_label *prev;
68896 + struct acl_role_label *next;
68897 +
68898 + struct role_transition *transitions;
68899 + struct role_allowed_ip *allowed_ips;
68900 + uid_t *domain_children;
68901 + __u16 domain_child_num;
68902 +
68903 + umode_t umask;
68904 +
68905 + struct acl_subject_label **subj_hash;
68906 + __u32 subj_hash_size;
68907 +};
68908 +
68909 +struct user_acl_role_db {
68910 + struct acl_role_label **r_table;
68911 + __u32 num_pointers; /* Number of allocations to track */
68912 + __u32 num_roles; /* Number of roles */
68913 + __u32 num_domain_children; /* Number of domain children */
68914 + __u32 num_subjects; /* Number of subjects */
68915 + __u32 num_objects; /* Number of objects */
68916 +};
68917 +
68918 +struct acl_object_label {
68919 + char *filename;
68920 + ino_t inode;
68921 + dev_t device;
68922 + __u32 mode;
68923 +
68924 + struct acl_subject_label *nested;
68925 + struct acl_object_label *globbed;
68926 +
68927 + /* next two structures not used */
68928 +
68929 + struct acl_object_label *prev;
68930 + struct acl_object_label *next;
68931 +};
68932 +
68933 +struct acl_ip_label {
68934 + char *iface;
68935 + __u32 addr;
68936 + __u32 netmask;
68937 + __u16 low, high;
68938 + __u8 mode;
68939 + __u32 type;
68940 + __u32 proto[8];
68941 +
68942 + /* next two structures not used */
68943 +
68944 + struct acl_ip_label *prev;
68945 + struct acl_ip_label *next;
68946 +};
68947 +
68948 +struct gr_arg {
68949 + struct user_acl_role_db role_db;
68950 + unsigned char pw[GR_PW_LEN];
68951 + unsigned char salt[GR_SALT_LEN];
68952 + unsigned char sum[GR_SHA_LEN];
68953 + unsigned char sp_role[GR_SPROLE_LEN];
68954 + struct sprole_pw *sprole_pws;
68955 + dev_t segv_device;
68956 + ino_t segv_inode;
68957 + uid_t segv_uid;
68958 + __u16 num_sprole_pws;
68959 + __u16 mode;
68960 +};
68961 +
68962 +struct gr_arg_wrapper {
68963 + struct gr_arg *arg;
68964 + __u32 version;
68965 + __u32 size;
68966 +};
68967 +
68968 +struct subject_map {
68969 + struct acl_subject_label *user;
68970 + struct acl_subject_label *kernel;
68971 + struct subject_map *prev;
68972 + struct subject_map *next;
68973 +};
68974 +
68975 +struct acl_subj_map_db {
68976 + struct subject_map **s_hash;
68977 + __u32 s_size;
68978 +};
68979 +
68980 +/* End Data Structures Section */
68981 +
68982 +/* Hash functions generated by empirical testing by Brad Spengler
68983 + Makes good use of the low bits of the inode. Generally 0-1 times
68984 + in loop for successful match. 0-3 for unsuccessful match.
68985 + Shift/add algorithm with modulus of table size and an XOR*/
68986 +
68987 +static __inline__ unsigned int
68988 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
68989 +{
68990 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
68991 +}
68992 +
68993 + static __inline__ unsigned int
68994 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
68995 +{
68996 + return ((const unsigned long)userp % sz);
68997 +}
68998 +
68999 +static __inline__ unsigned int
69000 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
69001 +{
69002 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
69003 +}
69004 +
69005 +static __inline__ unsigned int
69006 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
69007 +{
69008 + return full_name_hash((const unsigned char *)name, len) % sz;
69009 +}
69010 +
69011 +#define FOR_EACH_ROLE_START(role) \
69012 + role = role_list; \
69013 + while (role) {
69014 +
69015 +#define FOR_EACH_ROLE_END(role) \
69016 + role = role->prev; \
69017 + }
69018 +
69019 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
69020 + subj = NULL; \
69021 + iter = 0; \
69022 + while (iter < role->subj_hash_size) { \
69023 + if (subj == NULL) \
69024 + subj = role->subj_hash[iter]; \
69025 + if (subj == NULL) { \
69026 + iter++; \
69027 + continue; \
69028 + }
69029 +
69030 +#define FOR_EACH_SUBJECT_END(subj,iter) \
69031 + subj = subj->next; \
69032 + if (subj == NULL) \
69033 + iter++; \
69034 + }
69035 +
69036 +
69037 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
69038 + subj = role->hash->first; \
69039 + while (subj != NULL) {
69040 +
69041 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
69042 + subj = subj->next; \
69043 + }
69044 +
69045 +#endif
69046 +
69047 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
69048 new file mode 100644
69049 index 0000000..323ecf2
69050 --- /dev/null
69051 +++ b/include/linux/gralloc.h
69052 @@ -0,0 +1,9 @@
69053 +#ifndef __GRALLOC_H
69054 +#define __GRALLOC_H
69055 +
69056 +void acl_free_all(void);
69057 +int acl_alloc_stack_init(unsigned long size);
69058 +void *acl_alloc(unsigned long len);
69059 +void *acl_alloc_num(unsigned long num, unsigned long len);
69060 +
69061 +#endif
69062 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
69063 new file mode 100644
69064 index 0000000..be66033
69065 --- /dev/null
69066 +++ b/include/linux/grdefs.h
69067 @@ -0,0 +1,140 @@
69068 +#ifndef GRDEFS_H
69069 +#define GRDEFS_H
69070 +
69071 +/* Begin grsecurity status declarations */
69072 +
69073 +enum {
69074 + GR_READY = 0x01,
69075 + GR_STATUS_INIT = 0x00 // disabled state
69076 +};
69077 +
69078 +/* Begin ACL declarations */
69079 +
69080 +/* Role flags */
69081 +
69082 +enum {
69083 + GR_ROLE_USER = 0x0001,
69084 + GR_ROLE_GROUP = 0x0002,
69085 + GR_ROLE_DEFAULT = 0x0004,
69086 + GR_ROLE_SPECIAL = 0x0008,
69087 + GR_ROLE_AUTH = 0x0010,
69088 + GR_ROLE_NOPW = 0x0020,
69089 + GR_ROLE_GOD = 0x0040,
69090 + GR_ROLE_LEARN = 0x0080,
69091 + GR_ROLE_TPE = 0x0100,
69092 + GR_ROLE_DOMAIN = 0x0200,
69093 + GR_ROLE_PAM = 0x0400,
69094 + GR_ROLE_PERSIST = 0x0800
69095 +};
69096 +
69097 +/* ACL Subject and Object mode flags */
69098 +enum {
69099 + GR_DELETED = 0x80000000
69100 +};
69101 +
69102 +/* ACL Object-only mode flags */
69103 +enum {
69104 + GR_READ = 0x00000001,
69105 + GR_APPEND = 0x00000002,
69106 + GR_WRITE = 0x00000004,
69107 + GR_EXEC = 0x00000008,
69108 + GR_FIND = 0x00000010,
69109 + GR_INHERIT = 0x00000020,
69110 + GR_SETID = 0x00000040,
69111 + GR_CREATE = 0x00000080,
69112 + GR_DELETE = 0x00000100,
69113 + GR_LINK = 0x00000200,
69114 + GR_AUDIT_READ = 0x00000400,
69115 + GR_AUDIT_APPEND = 0x00000800,
69116 + GR_AUDIT_WRITE = 0x00001000,
69117 + GR_AUDIT_EXEC = 0x00002000,
69118 + GR_AUDIT_FIND = 0x00004000,
69119 + GR_AUDIT_INHERIT= 0x00008000,
69120 + GR_AUDIT_SETID = 0x00010000,
69121 + GR_AUDIT_CREATE = 0x00020000,
69122 + GR_AUDIT_DELETE = 0x00040000,
69123 + GR_AUDIT_LINK = 0x00080000,
69124 + GR_PTRACERD = 0x00100000,
69125 + GR_NOPTRACE = 0x00200000,
69126 + GR_SUPPRESS = 0x00400000,
69127 + GR_NOLEARN = 0x00800000,
69128 + GR_INIT_TRANSFER= 0x01000000
69129 +};
69130 +
69131 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
69132 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
69133 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
69134 +
69135 +/* ACL subject-only mode flags */
69136 +enum {
69137 + GR_KILL = 0x00000001,
69138 + GR_VIEW = 0x00000002,
69139 + GR_PROTECTED = 0x00000004,
69140 + GR_LEARN = 0x00000008,
69141 + GR_OVERRIDE = 0x00000010,
69142 + /* just a placeholder, this mode is only used in userspace */
69143 + GR_DUMMY = 0x00000020,
69144 + GR_PROTSHM = 0x00000040,
69145 + GR_KILLPROC = 0x00000080,
69146 + GR_KILLIPPROC = 0x00000100,
69147 + /* just a placeholder, this mode is only used in userspace */
69148 + GR_NOTROJAN = 0x00000200,
69149 + GR_PROTPROCFD = 0x00000400,
69150 + GR_PROCACCT = 0x00000800,
69151 + GR_RELAXPTRACE = 0x00001000,
69152 + //GR_NESTED = 0x00002000,
69153 + GR_INHERITLEARN = 0x00004000,
69154 + GR_PROCFIND = 0x00008000,
69155 + GR_POVERRIDE = 0x00010000,
69156 + GR_KERNELAUTH = 0x00020000,
69157 + GR_ATSECURE = 0x00040000,
69158 + GR_SHMEXEC = 0x00080000
69159 +};
69160 +
69161 +enum {
69162 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
69163 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
69164 + GR_PAX_ENABLE_MPROTECT = 0x0004,
69165 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
69166 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
69167 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
69168 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
69169 + GR_PAX_DISABLE_MPROTECT = 0x0400,
69170 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
69171 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
69172 +};
69173 +
69174 +enum {
69175 + GR_ID_USER = 0x01,
69176 + GR_ID_GROUP = 0x02,
69177 +};
69178 +
69179 +enum {
69180 + GR_ID_ALLOW = 0x01,
69181 + GR_ID_DENY = 0x02,
69182 +};
69183 +
69184 +#define GR_CRASH_RES 31
69185 +#define GR_UIDTABLE_MAX 500
69186 +
69187 +/* begin resource learning section */
69188 +enum {
69189 + GR_RLIM_CPU_BUMP = 60,
69190 + GR_RLIM_FSIZE_BUMP = 50000,
69191 + GR_RLIM_DATA_BUMP = 10000,
69192 + GR_RLIM_STACK_BUMP = 1000,
69193 + GR_RLIM_CORE_BUMP = 10000,
69194 + GR_RLIM_RSS_BUMP = 500000,
69195 + GR_RLIM_NPROC_BUMP = 1,
69196 + GR_RLIM_NOFILE_BUMP = 5,
69197 + GR_RLIM_MEMLOCK_BUMP = 50000,
69198 + GR_RLIM_AS_BUMP = 500000,
69199 + GR_RLIM_LOCKS_BUMP = 2,
69200 + GR_RLIM_SIGPENDING_BUMP = 5,
69201 + GR_RLIM_MSGQUEUE_BUMP = 10000,
69202 + GR_RLIM_NICE_BUMP = 1,
69203 + GR_RLIM_RTPRIO_BUMP = 1,
69204 + GR_RLIM_RTTIME_BUMP = 1000000
69205 +};
69206 +
69207 +#endif
69208 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
69209 new file mode 100644
69210 index 0000000..9bb6662
69211 --- /dev/null
69212 +++ b/include/linux/grinternal.h
69213 @@ -0,0 +1,215 @@
69214 +#ifndef __GRINTERNAL_H
69215 +#define __GRINTERNAL_H
69216 +
69217 +#ifdef CONFIG_GRKERNSEC
69218 +
69219 +#include <linux/fs.h>
69220 +#include <linux/mnt_namespace.h>
69221 +#include <linux/nsproxy.h>
69222 +#include <linux/gracl.h>
69223 +#include <linux/grdefs.h>
69224 +#include <linux/grmsg.h>
69225 +
69226 +void gr_add_learn_entry(const char *fmt, ...)
69227 + __attribute__ ((format (printf, 1, 2)));
69228 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
69229 + const struct vfsmount *mnt);
69230 +__u32 gr_check_create(const struct dentry *new_dentry,
69231 + const struct dentry *parent,
69232 + const struct vfsmount *mnt, const __u32 mode);
69233 +int gr_check_protected_task(const struct task_struct *task);
69234 +__u32 to_gr_audit(const __u32 reqmode);
69235 +int gr_set_acls(const int type);
69236 +int gr_apply_subject_to_task(struct task_struct *task);
69237 +int gr_acl_is_enabled(void);
69238 +char gr_roletype_to_char(void);
69239 +
69240 +void gr_handle_alertkill(struct task_struct *task);
69241 +char *gr_to_filename(const struct dentry *dentry,
69242 + const struct vfsmount *mnt);
69243 +char *gr_to_filename1(const struct dentry *dentry,
69244 + const struct vfsmount *mnt);
69245 +char *gr_to_filename2(const struct dentry *dentry,
69246 + const struct vfsmount *mnt);
69247 +char *gr_to_filename3(const struct dentry *dentry,
69248 + const struct vfsmount *mnt);
69249 +
69250 +extern int grsec_enable_ptrace_readexec;
69251 +extern int grsec_enable_harden_ptrace;
69252 +extern int grsec_enable_link;
69253 +extern int grsec_enable_fifo;
69254 +extern int grsec_enable_execve;
69255 +extern int grsec_enable_shm;
69256 +extern int grsec_enable_execlog;
69257 +extern int grsec_enable_signal;
69258 +extern int grsec_enable_audit_ptrace;
69259 +extern int grsec_enable_forkfail;
69260 +extern int grsec_enable_time;
69261 +extern int grsec_enable_rofs;
69262 +extern int grsec_enable_chroot_shmat;
69263 +extern int grsec_enable_chroot_mount;
69264 +extern int grsec_enable_chroot_double;
69265 +extern int grsec_enable_chroot_pivot;
69266 +extern int grsec_enable_chroot_chdir;
69267 +extern int grsec_enable_chroot_chmod;
69268 +extern int grsec_enable_chroot_mknod;
69269 +extern int grsec_enable_chroot_fchdir;
69270 +extern int grsec_enable_chroot_nice;
69271 +extern int grsec_enable_chroot_execlog;
69272 +extern int grsec_enable_chroot_caps;
69273 +extern int grsec_enable_chroot_sysctl;
69274 +extern int grsec_enable_chroot_unix;
69275 +extern int grsec_enable_symlinkown;
69276 +extern kgid_t grsec_symlinkown_gid;
69277 +extern int grsec_enable_tpe;
69278 +extern kgid_t grsec_tpe_gid;
69279 +extern int grsec_enable_tpe_all;
69280 +extern int grsec_enable_tpe_invert;
69281 +extern int grsec_enable_socket_all;
69282 +extern kgid_t grsec_socket_all_gid;
69283 +extern int grsec_enable_socket_client;
69284 +extern kgid_t grsec_socket_client_gid;
69285 +extern int grsec_enable_socket_server;
69286 +extern kgid_t grsec_socket_server_gid;
69287 +extern kgid_t grsec_audit_gid;
69288 +extern int grsec_enable_group;
69289 +extern int grsec_enable_audit_textrel;
69290 +extern int grsec_enable_log_rwxmaps;
69291 +extern int grsec_enable_mount;
69292 +extern int grsec_enable_chdir;
69293 +extern int grsec_resource_logging;
69294 +extern int grsec_enable_blackhole;
69295 +extern int grsec_lastack_retries;
69296 +extern int grsec_enable_brute;
69297 +extern int grsec_lock;
69298 +
69299 +extern spinlock_t grsec_alert_lock;
69300 +extern unsigned long grsec_alert_wtime;
69301 +extern unsigned long grsec_alert_fyet;
69302 +
69303 +extern spinlock_t grsec_audit_lock;
69304 +
69305 +extern rwlock_t grsec_exec_file_lock;
69306 +
69307 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
69308 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
69309 + (tsk)->exec_file->f_vfsmnt) : "/")
69310 +
69311 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
69312 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
69313 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
69314 +
69315 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
69316 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
69317 + (tsk)->exec_file->f_vfsmnt) : "/")
69318 +
69319 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
69320 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
69321 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
69322 +
69323 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
69324 +
69325 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
69326 +
69327 +#define GR_CHROOT_CAPS {{ \
69328 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
69329 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
69330 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
69331 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
69332 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
69333 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
69334 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
69335 +
69336 +#define security_learn(normal_msg,args...) \
69337 +({ \
69338 + read_lock(&grsec_exec_file_lock); \
69339 + gr_add_learn_entry(normal_msg "\n", ## args); \
69340 + read_unlock(&grsec_exec_file_lock); \
69341 +})
69342 +
69343 +enum {
69344 + GR_DO_AUDIT,
69345 + GR_DONT_AUDIT,
69346 + /* used for non-audit messages that we shouldn't kill the task on */
69347 + GR_DONT_AUDIT_GOOD
69348 +};
69349 +
69350 +enum {
69351 + GR_TTYSNIFF,
69352 + GR_RBAC,
69353 + GR_RBAC_STR,
69354 + GR_STR_RBAC,
69355 + GR_RBAC_MODE2,
69356 + GR_RBAC_MODE3,
69357 + GR_FILENAME,
69358 + GR_SYSCTL_HIDDEN,
69359 + GR_NOARGS,
69360 + GR_ONE_INT,
69361 + GR_ONE_INT_TWO_STR,
69362 + GR_ONE_STR,
69363 + GR_STR_INT,
69364 + GR_TWO_STR_INT,
69365 + GR_TWO_INT,
69366 + GR_TWO_U64,
69367 + GR_THREE_INT,
69368 + GR_FIVE_INT_TWO_STR,
69369 + GR_TWO_STR,
69370 + GR_THREE_STR,
69371 + GR_FOUR_STR,
69372 + GR_STR_FILENAME,
69373 + GR_FILENAME_STR,
69374 + GR_FILENAME_TWO_INT,
69375 + GR_FILENAME_TWO_INT_STR,
69376 + GR_TEXTREL,
69377 + GR_PTRACE,
69378 + GR_RESOURCE,
69379 + GR_CAP,
69380 + GR_SIG,
69381 + GR_SIG2,
69382 + GR_CRASH1,
69383 + GR_CRASH2,
69384 + GR_PSACCT,
69385 + GR_RWXMAP
69386 +};
69387 +
69388 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
69389 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
69390 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
69391 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
69392 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
69393 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
69394 +#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)
69395 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
69396 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
69397 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
69398 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
69399 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
69400 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
69401 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
69402 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
69403 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
69404 +#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)
69405 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
69406 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
69407 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
69408 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
69409 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
69410 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
69411 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
69412 +#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)
69413 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
69414 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
69415 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
69416 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
69417 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
69418 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
69419 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
69420 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
69421 +#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)
69422 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
69423 +
69424 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
69425 +
69426 +#endif
69427 +
69428 +#endif
69429 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
69430 new file mode 100644
69431 index 0000000..2bd4c8d
69432 --- /dev/null
69433 +++ b/include/linux/grmsg.h
69434 @@ -0,0 +1,111 @@
69435 +#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"
69436 +#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"
69437 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
69438 +#define GR_STOPMOD_MSG "denied modification of module state by "
69439 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
69440 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
69441 +#define GR_IOPERM_MSG "denied use of ioperm() by "
69442 +#define GR_IOPL_MSG "denied use of iopl() by "
69443 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
69444 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
69445 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
69446 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
69447 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
69448 +#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"
69449 +#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"
69450 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
69451 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
69452 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
69453 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
69454 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
69455 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
69456 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
69457 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
69458 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
69459 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
69460 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
69461 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
69462 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
69463 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
69464 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
69465 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
69466 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
69467 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
69468 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
69469 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
69470 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
69471 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
69472 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
69473 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
69474 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
69475 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
69476 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
69477 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
69478 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
69479 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
69480 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
69481 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
69482 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
69483 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
69484 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
69485 +#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"
69486 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
69487 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
69488 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
69489 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
69490 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
69491 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
69492 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
69493 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
69494 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
69495 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
69496 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
69497 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
69498 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
69499 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
69500 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
69501 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
69502 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
69503 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
69504 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
69505 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
69506 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
69507 +#define GR_NICE_CHROOT_MSG "denied priority change by "
69508 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
69509 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
69510 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
69511 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
69512 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
69513 +#define GR_TIME_MSG "time set by "
69514 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
69515 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
69516 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
69517 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
69518 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
69519 +#define GR_BIND_MSG "denied bind() by "
69520 +#define GR_CONNECT_MSG "denied connect() by "
69521 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
69522 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
69523 +#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"
69524 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
69525 +#define GR_CAP_ACL_MSG "use of %s denied for "
69526 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
69527 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
69528 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
69529 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
69530 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
69531 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
69532 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
69533 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
69534 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
69535 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
69536 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
69537 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
69538 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
69539 +#define GR_VM86_MSG "denied use of vm86 by "
69540 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
69541 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
69542 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
69543 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
69544 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
69545 +#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 "
69546 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
69547 new file mode 100644
69548 index 0000000..8da63a4
69549 --- /dev/null
69550 +++ b/include/linux/grsecurity.h
69551 @@ -0,0 +1,242 @@
69552 +#ifndef GR_SECURITY_H
69553 +#define GR_SECURITY_H
69554 +#include <linux/fs.h>
69555 +#include <linux/fs_struct.h>
69556 +#include <linux/binfmts.h>
69557 +#include <linux/gracl.h>
69558 +
69559 +/* notify of brain-dead configs */
69560 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
69561 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
69562 +#endif
69563 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
69564 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
69565 +#endif
69566 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
69567 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
69568 +#endif
69569 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
69570 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
69571 +#endif
69572 +
69573 +void gr_handle_brute_attach(unsigned long mm_flags);
69574 +void gr_handle_brute_check(void);
69575 +void gr_handle_kernel_exploit(void);
69576 +int gr_process_user_ban(void);
69577 +
69578 +char gr_roletype_to_char(void);
69579 +
69580 +int gr_acl_enable_at_secure(void);
69581 +
69582 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
69583 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
69584 +
69585 +void gr_del_task_from_ip_table(struct task_struct *p);
69586 +
69587 +int gr_pid_is_chrooted(struct task_struct *p);
69588 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
69589 +int gr_handle_chroot_nice(void);
69590 +int gr_handle_chroot_sysctl(const int op);
69591 +int gr_handle_chroot_setpriority(struct task_struct *p,
69592 + const int niceval);
69593 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
69594 +int gr_handle_chroot_chroot(const struct dentry *dentry,
69595 + const struct vfsmount *mnt);
69596 +void gr_handle_chroot_chdir(struct path *path);
69597 +int gr_handle_chroot_chmod(const struct dentry *dentry,
69598 + const struct vfsmount *mnt, const int mode);
69599 +int gr_handle_chroot_mknod(const struct dentry *dentry,
69600 + const struct vfsmount *mnt, const int mode);
69601 +int gr_handle_chroot_mount(const struct dentry *dentry,
69602 + const struct vfsmount *mnt,
69603 + const char *dev_name);
69604 +int gr_handle_chroot_pivot(void);
69605 +int gr_handle_chroot_unix(const pid_t pid);
69606 +
69607 +int gr_handle_rawio(const struct inode *inode);
69608 +
69609 +void gr_handle_ioperm(void);
69610 +void gr_handle_iopl(void);
69611 +
69612 +umode_t gr_acl_umask(void);
69613 +
69614 +int gr_tpe_allow(const struct file *file);
69615 +
69616 +void gr_set_chroot_entries(struct task_struct *task, struct path *path);
69617 +void gr_clear_chroot_entries(struct task_struct *task);
69618 +
69619 +void gr_log_forkfail(const int retval);
69620 +void gr_log_timechange(void);
69621 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
69622 +void gr_log_chdir(const struct dentry *dentry,
69623 + const struct vfsmount *mnt);
69624 +void gr_log_chroot_exec(const struct dentry *dentry,
69625 + const struct vfsmount *mnt);
69626 +void gr_log_remount(const char *devname, const int retval);
69627 +void gr_log_unmount(const char *devname, const int retval);
69628 +void gr_log_mount(const char *from, const char *to, const int retval);
69629 +void gr_log_textrel(struct vm_area_struct *vma);
69630 +void gr_log_rwxmmap(struct file *file);
69631 +void gr_log_rwxmprotect(struct file *file);
69632 +
69633 +int gr_handle_follow_link(const struct inode *parent,
69634 + const struct inode *inode,
69635 + const struct dentry *dentry,
69636 + const struct vfsmount *mnt);
69637 +int gr_handle_fifo(const struct dentry *dentry,
69638 + const struct vfsmount *mnt,
69639 + const struct dentry *dir, const int flag,
69640 + const int acc_mode);
69641 +int gr_handle_hardlink(const struct dentry *dentry,
69642 + const struct vfsmount *mnt,
69643 + struct inode *inode,
69644 + const int mode, const struct filename *to);
69645 +
69646 +int gr_is_capable(const int cap);
69647 +int gr_is_capable_nolog(const int cap);
69648 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69649 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
69650 +
69651 +void gr_copy_label(struct task_struct *tsk);
69652 +void gr_handle_crash(struct task_struct *task, const int sig);
69653 +int gr_handle_signal(const struct task_struct *p, const int sig);
69654 +int gr_check_crash_uid(const kuid_t uid);
69655 +int gr_check_protected_task(const struct task_struct *task);
69656 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
69657 +int gr_acl_handle_mmap(const struct file *file,
69658 + const unsigned long prot);
69659 +int gr_acl_handle_mprotect(const struct file *file,
69660 + const unsigned long prot);
69661 +int gr_check_hidden_task(const struct task_struct *tsk);
69662 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
69663 + const struct vfsmount *mnt);
69664 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
69665 + const struct vfsmount *mnt);
69666 +__u32 gr_acl_handle_access(const struct dentry *dentry,
69667 + const struct vfsmount *mnt, const int fmode);
69668 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
69669 + const struct vfsmount *mnt, umode_t *mode);
69670 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
69671 + const struct vfsmount *mnt);
69672 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
69673 + const struct vfsmount *mnt);
69674 +int gr_handle_ptrace(struct task_struct *task, const long request);
69675 +int gr_handle_proc_ptrace(struct task_struct *task);
69676 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
69677 + const struct vfsmount *mnt);
69678 +int gr_check_crash_exec(const struct file *filp);
69679 +int gr_acl_is_enabled(void);
69680 +void gr_set_kernel_label(struct task_struct *task);
69681 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
69682 + const kgid_t gid);
69683 +int gr_set_proc_label(const struct dentry *dentry,
69684 + const struct vfsmount *mnt,
69685 + const int unsafe_flags);
69686 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
69687 + const struct vfsmount *mnt);
69688 +__u32 gr_acl_handle_open(const struct dentry *dentry,
69689 + const struct vfsmount *mnt, int acc_mode);
69690 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
69691 + const struct dentry *p_dentry,
69692 + const struct vfsmount *p_mnt,
69693 + int open_flags, int acc_mode, const int imode);
69694 +void gr_handle_create(const struct dentry *dentry,
69695 + const struct vfsmount *mnt);
69696 +void gr_handle_proc_create(const struct dentry *dentry,
69697 + const struct inode *inode);
69698 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
69699 + const struct dentry *parent_dentry,
69700 + const struct vfsmount *parent_mnt,
69701 + const int mode);
69702 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
69703 + const struct dentry *parent_dentry,
69704 + const struct vfsmount *parent_mnt);
69705 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
69706 + const struct vfsmount *mnt);
69707 +void gr_handle_delete(const ino_t ino, const dev_t dev);
69708 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
69709 + const struct vfsmount *mnt);
69710 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
69711 + const struct dentry *parent_dentry,
69712 + const struct vfsmount *parent_mnt,
69713 + const struct filename *from);
69714 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
69715 + const struct dentry *parent_dentry,
69716 + const struct vfsmount *parent_mnt,
69717 + const struct dentry *old_dentry,
69718 + const struct vfsmount *old_mnt, const struct filename *to);
69719 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
69720 +int gr_acl_handle_rename(struct dentry *new_dentry,
69721 + struct dentry *parent_dentry,
69722 + const struct vfsmount *parent_mnt,
69723 + struct dentry *old_dentry,
69724 + struct inode *old_parent_inode,
69725 + struct vfsmount *old_mnt, const struct filename *newname);
69726 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
69727 + struct dentry *old_dentry,
69728 + struct dentry *new_dentry,
69729 + struct vfsmount *mnt, const __u8 replace);
69730 +__u32 gr_check_link(const struct dentry *new_dentry,
69731 + const struct dentry *parent_dentry,
69732 + const struct vfsmount *parent_mnt,
69733 + const struct dentry *old_dentry,
69734 + const struct vfsmount *old_mnt);
69735 +int gr_acl_handle_filldir(const struct file *file, const char *name,
69736 + const unsigned int namelen, const ino_t ino);
69737 +
69738 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
69739 + const struct vfsmount *mnt);
69740 +void gr_acl_handle_exit(void);
69741 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
69742 +int gr_acl_handle_procpidmem(const struct task_struct *task);
69743 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
69744 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
69745 +void gr_audit_ptrace(struct task_struct *task);
69746 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
69747 +void gr_put_exec_file(struct task_struct *task);
69748 +
69749 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
69750 +
69751 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
69752 +extern void gr_learn_resource(const struct task_struct *task, const int res,
69753 + const unsigned long wanted, const int gt);
69754 +#else
69755 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
69756 + const unsigned long wanted, const int gt)
69757 +{
69758 +}
69759 +#endif
69760 +
69761 +#ifdef CONFIG_GRKERNSEC_RESLOG
69762 +extern void gr_log_resource(const struct task_struct *task, const int res,
69763 + const unsigned long wanted, const int gt);
69764 +#else
69765 +static inline void gr_log_resource(const struct task_struct *task, const int res,
69766 + const unsigned long wanted, const int gt)
69767 +{
69768 +}
69769 +#endif
69770 +
69771 +#ifdef CONFIG_GRKERNSEC
69772 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
69773 +void gr_handle_vm86(void);
69774 +void gr_handle_mem_readwrite(u64 from, u64 to);
69775 +
69776 +void gr_log_badprocpid(const char *entry);
69777 +
69778 +extern int grsec_enable_dmesg;
69779 +extern int grsec_disable_privio;
69780 +
69781 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
69782 +extern kgid_t grsec_proc_gid;
69783 +#endif
69784 +
69785 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69786 +extern int grsec_enable_chroot_findtask;
69787 +#endif
69788 +#ifdef CONFIG_GRKERNSEC_SETXID
69789 +extern int grsec_enable_setxid;
69790 +#endif
69791 +#endif
69792 +
69793 +#endif
69794 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
69795 new file mode 100644
69796 index 0000000..e7ffaaf
69797 --- /dev/null
69798 +++ b/include/linux/grsock.h
69799 @@ -0,0 +1,19 @@
69800 +#ifndef __GRSOCK_H
69801 +#define __GRSOCK_H
69802 +
69803 +extern void gr_attach_curr_ip(const struct sock *sk);
69804 +extern int gr_handle_sock_all(const int family, const int type,
69805 + const int protocol);
69806 +extern int gr_handle_sock_server(const struct sockaddr *sck);
69807 +extern int gr_handle_sock_server_other(const struct sock *sck);
69808 +extern int gr_handle_sock_client(const struct sockaddr *sck);
69809 +extern int gr_search_connect(struct socket * sock,
69810 + struct sockaddr_in * addr);
69811 +extern int gr_search_bind(struct socket * sock,
69812 + struct sockaddr_in * addr);
69813 +extern int gr_search_listen(struct socket * sock);
69814 +extern int gr_search_accept(struct socket * sock);
69815 +extern int gr_search_socket(const int domain, const int type,
69816 + const int protocol);
69817 +
69818 +#endif
69819 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
69820 index ef788b5..ac41b7b 100644
69821 --- a/include/linux/highmem.h
69822 +++ b/include/linux/highmem.h
69823 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
69824 kunmap_atomic(kaddr);
69825 }
69826
69827 +static inline void sanitize_highpage(struct page *page)
69828 +{
69829 + void *kaddr;
69830 + unsigned long flags;
69831 +
69832 + local_irq_save(flags);
69833 + kaddr = kmap_atomic(page);
69834 + clear_page(kaddr);
69835 + kunmap_atomic(kaddr);
69836 + local_irq_restore(flags);
69837 +}
69838 +
69839 static inline void zero_user_segments(struct page *page,
69840 unsigned start1, unsigned end1,
69841 unsigned start2, unsigned end2)
69842 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
69843 index 1c7b89a..7f52502 100644
69844 --- a/include/linux/hwmon-sysfs.h
69845 +++ b/include/linux/hwmon-sysfs.h
69846 @@ -25,7 +25,8 @@
69847 struct sensor_device_attribute{
69848 struct device_attribute dev_attr;
69849 int index;
69850 -};
69851 +} __do_const;
69852 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
69853 #define to_sensor_dev_attr(_dev_attr) \
69854 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
69855
69856 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
69857 struct device_attribute dev_attr;
69858 u8 index;
69859 u8 nr;
69860 -};
69861 +} __do_const;
69862 #define to_sensor_dev_attr_2(_dev_attr) \
69863 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
69864
69865 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
69866 index d0c4db7..61b3577 100644
69867 --- a/include/linux/i2c.h
69868 +++ b/include/linux/i2c.h
69869 @@ -369,6 +369,7 @@ struct i2c_algorithm {
69870 /* To determine what the adapter supports */
69871 u32 (*functionality) (struct i2c_adapter *);
69872 };
69873 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
69874
69875 /*
69876 * i2c_adapter is the structure used to identify a physical i2c bus along
69877 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
69878 index d23c3c2..eb63c81 100644
69879 --- a/include/linux/i2o.h
69880 +++ b/include/linux/i2o.h
69881 @@ -565,7 +565,7 @@ struct i2o_controller {
69882 struct i2o_device *exec; /* Executive */
69883 #if BITS_PER_LONG == 64
69884 spinlock_t context_list_lock; /* lock for context_list */
69885 - atomic_t context_list_counter; /* needed for unique contexts */
69886 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
69887 struct list_head context_list; /* list of context id's
69888 and pointers */
69889 #endif
69890 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
69891 index aff7ad8..3942bbd 100644
69892 --- a/include/linux/if_pppox.h
69893 +++ b/include/linux/if_pppox.h
69894 @@ -76,7 +76,7 @@ struct pppox_proto {
69895 int (*ioctl)(struct socket *sock, unsigned int cmd,
69896 unsigned long arg);
69897 struct module *owner;
69898 -};
69899 +} __do_const;
69900
69901 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
69902 extern void unregister_pppox_proto(int proto_num);
69903 diff --git a/include/linux/init.h b/include/linux/init.h
69904 index 10ed4f4..8e8490d 100644
69905 --- a/include/linux/init.h
69906 +++ b/include/linux/init.h
69907 @@ -39,9 +39,36 @@
69908 * Also note, that this data cannot be "const".
69909 */
69910
69911 +#ifdef MODULE
69912 +#define add_init_latent_entropy
69913 +#define add_devinit_latent_entropy
69914 +#define add_cpuinit_latent_entropy
69915 +#define add_meminit_latent_entropy
69916 +#else
69917 +#define add_init_latent_entropy __latent_entropy
69918 +
69919 +#ifdef CONFIG_HOTPLUG
69920 +#define add_devinit_latent_entropy
69921 +#else
69922 +#define add_devinit_latent_entropy __latent_entropy
69923 +#endif
69924 +
69925 +#ifdef CONFIG_HOTPLUG_CPU
69926 +#define add_cpuinit_latent_entropy
69927 +#else
69928 +#define add_cpuinit_latent_entropy __latent_entropy
69929 +#endif
69930 +
69931 +#ifdef CONFIG_MEMORY_HOTPLUG
69932 +#define add_meminit_latent_entropy
69933 +#else
69934 +#define add_meminit_latent_entropy __latent_entropy
69935 +#endif
69936 +#endif
69937 +
69938 /* These are for everybody (although not all archs will actually
69939 discard it in modules) */
69940 -#define __init __section(.init.text) __cold notrace
69941 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
69942 #define __initdata __section(.init.data)
69943 #define __initconst __constsection(.init.rodata)
69944 #define __exitdata __section(.exit.data)
69945 @@ -94,7 +121,7 @@
69946 #define __exit __section(.exit.text) __exitused __cold notrace
69947
69948 /* Used for HOTPLUG_CPU */
69949 -#define __cpuinit __section(.cpuinit.text) __cold notrace
69950 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
69951 #define __cpuinitdata __section(.cpuinit.data)
69952 #define __cpuinitconst __constsection(.cpuinit.rodata)
69953 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
69954 @@ -102,7 +129,7 @@
69955 #define __cpuexitconst __constsection(.cpuexit.rodata)
69956
69957 /* Used for MEMORY_HOTPLUG */
69958 -#define __meminit __section(.meminit.text) __cold notrace
69959 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
69960 #define __meminitdata __section(.meminit.data)
69961 #define __meminitconst __constsection(.meminit.rodata)
69962 #define __memexit __section(.memexit.text) __exitused __cold notrace
69963 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
69964 index 6d087c5..401cab8 100644
69965 --- a/include/linux/init_task.h
69966 +++ b/include/linux/init_task.h
69967 @@ -143,6 +143,12 @@ extern struct task_group root_task_group;
69968
69969 #define INIT_TASK_COMM "swapper"
69970
69971 +#ifdef CONFIG_X86
69972 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
69973 +#else
69974 +#define INIT_TASK_THREAD_INFO
69975 +#endif
69976 +
69977 /*
69978 * INIT_TASK is used to set up the first task table, touch at
69979 * your own risk!. Base=0, limit=0x1fffff (=2MB)
69980 @@ -182,6 +188,7 @@ extern struct task_group root_task_group;
69981 RCU_POINTER_INITIALIZER(cred, &init_cred), \
69982 .comm = INIT_TASK_COMM, \
69983 .thread = INIT_THREAD, \
69984 + INIT_TASK_THREAD_INFO \
69985 .fs = &init_fs, \
69986 .files = &init_files, \
69987 .signal = &init_signals, \
69988 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
69989 index 5fa5afe..ac55b25 100644
69990 --- a/include/linux/interrupt.h
69991 +++ b/include/linux/interrupt.h
69992 @@ -430,7 +430,7 @@ enum
69993 /* map softirq index to softirq name. update 'softirq_to_name' in
69994 * kernel/softirq.c when adding a new softirq.
69995 */
69996 -extern char *softirq_to_name[NR_SOFTIRQS];
69997 +extern const char * const softirq_to_name[NR_SOFTIRQS];
69998
69999 /* softirq mask and active fields moved to irq_cpustat_t in
70000 * asm/hardirq.h to get better cache usage. KAO
70001 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
70002
70003 struct softirq_action
70004 {
70005 - void (*action)(struct softirq_action *);
70006 -};
70007 + void (*action)(void);
70008 +} __no_const;
70009
70010 asmlinkage void do_softirq(void);
70011 asmlinkage void __do_softirq(void);
70012 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
70013 +extern void open_softirq(int nr, void (*action)(void));
70014 extern void softirq_init(void);
70015 extern void __raise_softirq_irqoff(unsigned int nr);
70016
70017 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
70018 index f3b99e1..9b73cee 100644
70019 --- a/include/linux/iommu.h
70020 +++ b/include/linux/iommu.h
70021 @@ -101,7 +101,7 @@ struct iommu_ops {
70022 int (*domain_set_attr)(struct iommu_domain *domain,
70023 enum iommu_attr attr, void *data);
70024 unsigned long pgsize_bitmap;
70025 -};
70026 +} __do_const;
70027
70028 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
70029 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
70030 diff --git a/include/linux/irq.h b/include/linux/irq.h
70031 index fdf2c4a..5332486 100644
70032 --- a/include/linux/irq.h
70033 +++ b/include/linux/irq.h
70034 @@ -328,7 +328,8 @@ struct irq_chip {
70035 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
70036
70037 unsigned long flags;
70038 -};
70039 +} __do_const;
70040 +typedef struct irq_chip __no_const irq_chip_no_const;
70041
70042 /*
70043 * irq_chip specific flags
70044 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
70045 index 6883e19..06992b1 100644
70046 --- a/include/linux/kallsyms.h
70047 +++ b/include/linux/kallsyms.h
70048 @@ -15,7 +15,8 @@
70049
70050 struct module;
70051
70052 -#ifdef CONFIG_KALLSYMS
70053 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
70054 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
70055 /* Lookup the address for a symbol. Returns 0 if not found. */
70056 unsigned long kallsyms_lookup_name(const char *name);
70057
70058 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
70059 /* Stupid that this does nothing, but I didn't create this mess. */
70060 #define __print_symbol(fmt, addr)
70061 #endif /*CONFIG_KALLSYMS*/
70062 +#else /* when included by kallsyms.c, vsnprintf.c, or
70063 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
70064 +extern void __print_symbol(const char *fmt, unsigned long address);
70065 +extern int sprint_backtrace(char *buffer, unsigned long address);
70066 +extern int sprint_symbol(char *buffer, unsigned long address);
70067 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
70068 +const char *kallsyms_lookup(unsigned long addr,
70069 + unsigned long *symbolsize,
70070 + unsigned long *offset,
70071 + char **modname, char *namebuf);
70072 +#endif
70073
70074 /* This macro allows us to keep printk typechecking */
70075 static __printf(1, 2)
70076 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
70077 index 518a53a..5e28358 100644
70078 --- a/include/linux/key-type.h
70079 +++ b/include/linux/key-type.h
70080 @@ -125,7 +125,7 @@ struct key_type {
70081 /* internal fields */
70082 struct list_head link; /* link in types list */
70083 struct lock_class_key lock_class; /* key->sem lock class */
70084 -};
70085 +} __do_const;
70086
70087 extern struct key_type key_type_keyring;
70088
70089 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
70090 index 4dff0c6..1ca9b72 100644
70091 --- a/include/linux/kgdb.h
70092 +++ b/include/linux/kgdb.h
70093 @@ -53,7 +53,7 @@ extern int kgdb_connected;
70094 extern int kgdb_io_module_registered;
70095
70096 extern atomic_t kgdb_setting_breakpoint;
70097 -extern atomic_t kgdb_cpu_doing_single_step;
70098 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
70099
70100 extern struct task_struct *kgdb_usethread;
70101 extern struct task_struct *kgdb_contthread;
70102 @@ -255,7 +255,7 @@ struct kgdb_arch {
70103 void (*correct_hw_break)(void);
70104
70105 void (*enable_nmi)(bool on);
70106 -};
70107 +} __do_const;
70108
70109 /**
70110 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
70111 @@ -280,7 +280,7 @@ struct kgdb_io {
70112 void (*pre_exception) (void);
70113 void (*post_exception) (void);
70114 int is_console;
70115 -};
70116 +} __do_const;
70117
70118 extern struct kgdb_arch arch_kgdb_ops;
70119
70120 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
70121 index 5398d58..5883a34 100644
70122 --- a/include/linux/kmod.h
70123 +++ b/include/linux/kmod.h
70124 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
70125 * usually useless though. */
70126 extern __printf(2, 3)
70127 int __request_module(bool wait, const char *name, ...);
70128 +extern __printf(3, 4)
70129 +int ___request_module(bool wait, char *param_name, const char *name, ...);
70130 #define request_module(mod...) __request_module(true, mod)
70131 #define request_module_nowait(mod...) __request_module(false, mod)
70132 #define try_then_request_module(x, mod...) \
70133 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
70134 index 939b112..ed6ed51 100644
70135 --- a/include/linux/kobject.h
70136 +++ b/include/linux/kobject.h
70137 @@ -111,7 +111,7 @@ struct kobj_type {
70138 struct attribute **default_attrs;
70139 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
70140 const void *(*namespace)(struct kobject *kobj);
70141 -};
70142 +} __do_const;
70143
70144 struct kobj_uevent_env {
70145 char *envp[UEVENT_NUM_ENVP];
70146 @@ -134,6 +134,7 @@ struct kobj_attribute {
70147 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
70148 const char *buf, size_t count);
70149 };
70150 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
70151
70152 extern const struct sysfs_ops kobj_sysfs_ops;
70153
70154 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
70155 index f66b065..c2c29b4 100644
70156 --- a/include/linux/kobject_ns.h
70157 +++ b/include/linux/kobject_ns.h
70158 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
70159 const void *(*netlink_ns)(struct sock *sk);
70160 const void *(*initial_ns)(void);
70161 void (*drop_ns)(void *);
70162 -};
70163 +} __do_const;
70164
70165 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
70166 int kobj_ns_type_registered(enum kobj_ns_type type);
70167 diff --git a/include/linux/kref.h b/include/linux/kref.h
70168 index 4972e6e..de4d19b 100644
70169 --- a/include/linux/kref.h
70170 +++ b/include/linux/kref.h
70171 @@ -64,7 +64,7 @@ static inline void kref_get(struct kref *kref)
70172 static inline int kref_sub(struct kref *kref, unsigned int count,
70173 void (*release)(struct kref *kref))
70174 {
70175 - WARN_ON(release == NULL);
70176 + BUG_ON(release == NULL);
70177
70178 if (atomic_sub_and_test((int) count, &kref->refcount)) {
70179 release(kref);
70180 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
70181 index 2c497ab..afe32f5 100644
70182 --- a/include/linux/kvm_host.h
70183 +++ b/include/linux/kvm_host.h
70184 @@ -418,7 +418,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
70185 int __must_check vcpu_load(struct kvm_vcpu *vcpu);
70186 void vcpu_put(struct kvm_vcpu *vcpu);
70187
70188 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70189 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70190 struct module *module);
70191 void kvm_exit(void);
70192
70193 @@ -574,7 +574,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
70194 struct kvm_guest_debug *dbg);
70195 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
70196
70197 -int kvm_arch_init(void *opaque);
70198 +int kvm_arch_init(const void *opaque);
70199 void kvm_arch_exit(void);
70200
70201 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
70202 diff --git a/include/linux/libata.h b/include/linux/libata.h
70203 index 649e5f8..ead5194 100644
70204 --- a/include/linux/libata.h
70205 +++ b/include/linux/libata.h
70206 @@ -915,7 +915,7 @@ struct ata_port_operations {
70207 * fields must be pointers.
70208 */
70209 const struct ata_port_operations *inherits;
70210 -};
70211 +} __do_const;
70212
70213 struct ata_port_info {
70214 unsigned long flags;
70215 diff --git a/include/linux/list.h b/include/linux/list.h
70216 index cc6d2aa..c10ee83 100644
70217 --- a/include/linux/list.h
70218 +++ b/include/linux/list.h
70219 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
70220 extern void list_del(struct list_head *entry);
70221 #endif
70222
70223 +extern void __pax_list_add(struct list_head *new,
70224 + struct list_head *prev,
70225 + struct list_head *next);
70226 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
70227 +{
70228 + __pax_list_add(new, head, head->next);
70229 +}
70230 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
70231 +{
70232 + __pax_list_add(new, head->prev, head);
70233 +}
70234 +extern void pax_list_del(struct list_head *entry);
70235 +
70236 /**
70237 * list_replace - replace old entry by new one
70238 * @old : the element to be replaced
70239 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
70240 INIT_LIST_HEAD(entry);
70241 }
70242
70243 +extern void pax_list_del_init(struct list_head *entry);
70244 +
70245 /**
70246 * list_move - delete from one list and add as another's head
70247 * @list: the entry to move
70248 diff --git a/include/linux/math64.h b/include/linux/math64.h
70249 index b8ba855..0148090 100644
70250 --- a/include/linux/math64.h
70251 +++ b/include/linux/math64.h
70252 @@ -14,7 +14,7 @@
70253 * This is commonly provided by 32bit archs to provide an optimized 64bit
70254 * divide.
70255 */
70256 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70257 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70258 {
70259 *remainder = dividend % divisor;
70260 return dividend / divisor;
70261 @@ -50,7 +50,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
70262 #define div64_long(x,y) div_s64((x),(y))
70263
70264 #ifndef div_u64_rem
70265 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70266 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70267 {
70268 *remainder = do_div(dividend, divisor);
70269 return dividend;
70270 @@ -79,7 +79,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
70271 * divide.
70272 */
70273 #ifndef div_u64
70274 -static inline u64 div_u64(u64 dividend, u32 divisor)
70275 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
70276 {
70277 u32 remainder;
70278 return div_u64_rem(dividend, divisor, &remainder);
70279 diff --git a/include/linux/mm.h b/include/linux/mm.h
70280 index 66e2f7c..b916b9a 100644
70281 --- a/include/linux/mm.h
70282 +++ b/include/linux/mm.h
70283 @@ -101,6 +101,11 @@ extern unsigned int kobjsize(const void *objp);
70284 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
70285 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
70286 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
70287 +
70288 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
70289 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
70290 +#endif
70291 +
70292 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
70293
70294 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
70295 @@ -200,8 +205,8 @@ struct vm_operations_struct {
70296 /* called by access_process_vm when get_user_pages() fails, typically
70297 * for use by special VMAs that can switch between memory and hardware
70298 */
70299 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
70300 - void *buf, int len, int write);
70301 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
70302 + void *buf, size_t len, int write);
70303 #ifdef CONFIG_NUMA
70304 /*
70305 * set_policy() op must add a reference to any non-NULL @new mempolicy
70306 @@ -231,6 +236,7 @@ struct vm_operations_struct {
70307 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
70308 unsigned long size, pgoff_t pgoff);
70309 };
70310 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
70311
70312 struct mmu_gather;
70313 struct inode;
70314 @@ -995,8 +1001,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
70315 unsigned long *pfn);
70316 int follow_phys(struct vm_area_struct *vma, unsigned long address,
70317 unsigned int flags, unsigned long *prot, resource_size_t *phys);
70318 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70319 - void *buf, int len, int write);
70320 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70321 + void *buf, size_t len, int write);
70322
70323 static inline void unmap_shared_mapping_range(struct address_space *mapping,
70324 loff_t const holebegin, loff_t const holelen)
70325 @@ -1035,10 +1041,10 @@ static inline int fixup_user_fault(struct task_struct *tsk,
70326 }
70327 #endif
70328
70329 -extern int make_pages_present(unsigned long addr, unsigned long end);
70330 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
70331 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
70332 - void *buf, int len, int write);
70333 +extern ssize_t make_pages_present(unsigned long addr, unsigned long end);
70334 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
70335 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
70336 + void *buf, size_t len, int write);
70337
70338 int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
70339 unsigned long start, int len, unsigned int foll_flags,
70340 @@ -1068,34 +1074,6 @@ int set_page_dirty(struct page *page);
70341 int set_page_dirty_lock(struct page *page);
70342 int clear_page_dirty_for_io(struct page *page);
70343
70344 -/* Is the vma a continuation of the stack vma above it? */
70345 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
70346 -{
70347 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
70348 -}
70349 -
70350 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
70351 - unsigned long addr)
70352 -{
70353 - return (vma->vm_flags & VM_GROWSDOWN) &&
70354 - (vma->vm_start == addr) &&
70355 - !vma_growsdown(vma->vm_prev, addr);
70356 -}
70357 -
70358 -/* Is the vma a continuation of the stack vma below it? */
70359 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
70360 -{
70361 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
70362 -}
70363 -
70364 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
70365 - unsigned long addr)
70366 -{
70367 - return (vma->vm_flags & VM_GROWSUP) &&
70368 - (vma->vm_end == addr) &&
70369 - !vma_growsup(vma->vm_next, addr);
70370 -}
70371 -
70372 extern pid_t
70373 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
70374
70375 @@ -1198,6 +1176,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
70376 }
70377 #endif
70378
70379 +#ifdef CONFIG_MMU
70380 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
70381 +#else
70382 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
70383 +{
70384 + return __pgprot(0);
70385 +}
70386 +#endif
70387 +
70388 int vma_wants_writenotify(struct vm_area_struct *vma);
70389
70390 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
70391 @@ -1216,8 +1203,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
70392 {
70393 return 0;
70394 }
70395 +
70396 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
70397 + unsigned long address)
70398 +{
70399 + return 0;
70400 +}
70401 #else
70402 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70403 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70404 #endif
70405
70406 #ifdef __PAGETABLE_PMD_FOLDED
70407 @@ -1226,8 +1220,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
70408 {
70409 return 0;
70410 }
70411 +
70412 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
70413 + unsigned long address)
70414 +{
70415 + return 0;
70416 +}
70417 #else
70418 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
70419 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
70420 #endif
70421
70422 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
70423 @@ -1245,11 +1246,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
70424 NULL: pud_offset(pgd, address);
70425 }
70426
70427 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
70428 +{
70429 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
70430 + NULL: pud_offset(pgd, address);
70431 +}
70432 +
70433 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
70434 {
70435 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
70436 NULL: pmd_offset(pud, address);
70437 }
70438 +
70439 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
70440 +{
70441 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
70442 + NULL: pmd_offset(pud, address);
70443 +}
70444 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
70445
70446 #if USE_SPLIT_PTLOCKS
70447 @@ -1479,6 +1492,7 @@ extern unsigned long do_mmap_pgoff(struct file *, unsigned long,
70448 unsigned long, unsigned long,
70449 unsigned long, unsigned long);
70450 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
70451 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
70452
70453 /* These take the mm semaphore themselves */
70454 extern unsigned long vm_brk(unsigned long, unsigned long);
70455 @@ -1573,6 +1587,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
70456 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
70457 struct vm_area_struct **pprev);
70458
70459 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
70460 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
70461 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
70462 +
70463 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
70464 NULL if none. Assume start_addr < end_addr. */
70465 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
70466 @@ -1601,15 +1619,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
70467 return vma;
70468 }
70469
70470 -#ifdef CONFIG_MMU
70471 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
70472 -#else
70473 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
70474 -{
70475 - return __pgprot(0);
70476 -}
70477 -#endif
70478 -
70479 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
70480 unsigned long change_prot_numa(struct vm_area_struct *vma,
70481 unsigned long start, unsigned long end);
70482 @@ -1649,6 +1658,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
70483 static inline void vm_stat_account(struct mm_struct *mm,
70484 unsigned long flags, struct file *file, long pages)
70485 {
70486 +
70487 +#ifdef CONFIG_PAX_RANDMMAP
70488 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
70489 +#endif
70490 +
70491 mm->total_vm += pages;
70492 }
70493 #endif /* CONFIG_PROC_FS */
70494 @@ -1721,7 +1735,7 @@ extern int unpoison_memory(unsigned long pfn);
70495 extern int sysctl_memory_failure_early_kill;
70496 extern int sysctl_memory_failure_recovery;
70497 extern void shake_page(struct page *p, int access);
70498 -extern atomic_long_t mce_bad_pages;
70499 +extern atomic_long_unchecked_t mce_bad_pages;
70500 extern int soft_offline_page(struct page *page, int flags);
70501
70502 extern void dump_page(struct page *page);
70503 @@ -1752,5 +1766,11 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
70504 static inline bool page_is_guard(struct page *page) { return false; }
70505 #endif /* CONFIG_DEBUG_PAGEALLOC */
70506
70507 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
70508 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
70509 +#else
70510 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
70511 +#endif
70512 +
70513 #endif /* __KERNEL__ */
70514 #endif /* _LINUX_MM_H */
70515 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
70516 index f8f5162..3aaf20f 100644
70517 --- a/include/linux/mm_types.h
70518 +++ b/include/linux/mm_types.h
70519 @@ -288,6 +288,8 @@ struct vm_area_struct {
70520 #ifdef CONFIG_NUMA
70521 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
70522 #endif
70523 +
70524 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
70525 };
70526
70527 struct core_thread {
70528 @@ -436,6 +438,24 @@ struct mm_struct {
70529 int first_nid;
70530 #endif
70531 struct uprobes_state uprobes_state;
70532 +
70533 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
70534 + unsigned long pax_flags;
70535 +#endif
70536 +
70537 +#ifdef CONFIG_PAX_DLRESOLVE
70538 + unsigned long call_dl_resolve;
70539 +#endif
70540 +
70541 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
70542 + unsigned long call_syscall;
70543 +#endif
70544 +
70545 +#ifdef CONFIG_PAX_ASLR
70546 + unsigned long delta_mmap; /* randomized offset */
70547 + unsigned long delta_stack; /* randomized offset */
70548 +#endif
70549 +
70550 };
70551
70552 /* first nid will either be a valid NID or one of these values */
70553 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
70554 index c5d5278..f0b68c8 100644
70555 --- a/include/linux/mmiotrace.h
70556 +++ b/include/linux/mmiotrace.h
70557 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
70558 /* Called from ioremap.c */
70559 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
70560 void __iomem *addr);
70561 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
70562 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
70563
70564 /* For anyone to insert markers. Remember trailing newline. */
70565 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
70566 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
70567 {
70568 }
70569
70570 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
70571 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
70572 {
70573 }
70574
70575 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
70576 index 73b64a3..6562925 100644
70577 --- a/include/linux/mmzone.h
70578 +++ b/include/linux/mmzone.h
70579 @@ -412,7 +412,7 @@ struct zone {
70580 unsigned long flags; /* zone flags, see below */
70581
70582 /* Zone statistics */
70583 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70584 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70585
70586 /*
70587 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
70588 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
70589 index fed3def..c933f99 100644
70590 --- a/include/linux/mod_devicetable.h
70591 +++ b/include/linux/mod_devicetable.h
70592 @@ -12,7 +12,7 @@
70593 typedef unsigned long kernel_ulong_t;
70594 #endif
70595
70596 -#define PCI_ANY_ID (~0)
70597 +#define PCI_ANY_ID ((__u16)~0)
70598
70599 struct pci_device_id {
70600 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
70601 @@ -139,7 +139,7 @@ struct usb_device_id {
70602 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
70603 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
70604
70605 -#define HID_ANY_ID (~0)
70606 +#define HID_ANY_ID (~0U)
70607 #define HID_BUS_ANY 0xffff
70608 #define HID_GROUP_ANY 0x0000
70609
70610 @@ -498,7 +498,7 @@ struct dmi_system_id {
70611 const char *ident;
70612 struct dmi_strmatch matches[4];
70613 void *driver_data;
70614 -};
70615 +} __do_const;
70616 /*
70617 * struct dmi_device_id appears during expansion of
70618 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
70619 diff --git a/include/linux/module.h b/include/linux/module.h
70620 index 1375ee3..ced8177 100644
70621 --- a/include/linux/module.h
70622 +++ b/include/linux/module.h
70623 @@ -17,9 +17,11 @@
70624 #include <linux/moduleparam.h>
70625 #include <linux/tracepoint.h>
70626 #include <linux/export.h>
70627 +#include <linux/fs.h>
70628
70629 #include <linux/percpu.h>
70630 #include <asm/module.h>
70631 +#include <asm/pgtable.h>
70632
70633 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
70634 #define MODULE_SIG_STRING "~Module signature appended~\n"
70635 @@ -54,12 +56,13 @@ struct module_attribute {
70636 int (*test)(struct module *);
70637 void (*free)(struct module *);
70638 };
70639 +typedef struct module_attribute __no_const module_attribute_no_const;
70640
70641 struct module_version_attribute {
70642 struct module_attribute mattr;
70643 const char *module_name;
70644 const char *version;
70645 -} __attribute__ ((__aligned__(sizeof(void *))));
70646 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
70647
70648 extern ssize_t __modver_version_show(struct module_attribute *,
70649 struct module_kobject *, char *);
70650 @@ -232,7 +235,7 @@ struct module
70651
70652 /* Sysfs stuff. */
70653 struct module_kobject mkobj;
70654 - struct module_attribute *modinfo_attrs;
70655 + module_attribute_no_const *modinfo_attrs;
70656 const char *version;
70657 const char *srcversion;
70658 struct kobject *holders_dir;
70659 @@ -281,19 +284,16 @@ struct module
70660 int (*init)(void);
70661
70662 /* If this is non-NULL, vfree after init() returns */
70663 - void *module_init;
70664 + void *module_init_rx, *module_init_rw;
70665
70666 /* Here is the actual code + data, vfree'd on unload. */
70667 - void *module_core;
70668 + void *module_core_rx, *module_core_rw;
70669
70670 /* Here are the sizes of the init and core sections */
70671 - unsigned int init_size, core_size;
70672 + unsigned int init_size_rw, core_size_rw;
70673
70674 /* The size of the executable code in each section. */
70675 - unsigned int init_text_size, core_text_size;
70676 -
70677 - /* Size of RO sections of the module (text+rodata) */
70678 - unsigned int init_ro_size, core_ro_size;
70679 + unsigned int init_size_rx, core_size_rx;
70680
70681 /* Arch-specific module values */
70682 struct mod_arch_specific arch;
70683 @@ -349,6 +349,10 @@ struct module
70684 #ifdef CONFIG_EVENT_TRACING
70685 struct ftrace_event_call **trace_events;
70686 unsigned int num_trace_events;
70687 + struct file_operations trace_id;
70688 + struct file_operations trace_enable;
70689 + struct file_operations trace_format;
70690 + struct file_operations trace_filter;
70691 #endif
70692 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
70693 unsigned int num_ftrace_callsites;
70694 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
70695 bool is_module_percpu_address(unsigned long addr);
70696 bool is_module_text_address(unsigned long addr);
70697
70698 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
70699 +{
70700 +
70701 +#ifdef CONFIG_PAX_KERNEXEC
70702 + if (ktla_ktva(addr) >= (unsigned long)start &&
70703 + ktla_ktva(addr) < (unsigned long)start + size)
70704 + return 1;
70705 +#endif
70706 +
70707 + return ((void *)addr >= start && (void *)addr < start + size);
70708 +}
70709 +
70710 +static inline int within_module_core_rx(unsigned long addr, struct module *mod)
70711 +{
70712 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
70713 +}
70714 +
70715 +static inline int within_module_core_rw(unsigned long addr, struct module *mod)
70716 +{
70717 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
70718 +}
70719 +
70720 +static inline int within_module_init_rx(unsigned long addr, struct module *mod)
70721 +{
70722 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
70723 +}
70724 +
70725 +static inline int within_module_init_rw(unsigned long addr, struct module *mod)
70726 +{
70727 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
70728 +}
70729 +
70730 static inline int within_module_core(unsigned long addr, struct module *mod)
70731 {
70732 - return (unsigned long)mod->module_core <= addr &&
70733 - addr < (unsigned long)mod->module_core + mod->core_size;
70734 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
70735 }
70736
70737 static inline int within_module_init(unsigned long addr, struct module *mod)
70738 {
70739 - return (unsigned long)mod->module_init <= addr &&
70740 - addr < (unsigned long)mod->module_init + mod->init_size;
70741 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
70742 }
70743
70744 /* Search for module by name: must hold module_mutex. */
70745 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
70746 index 560ca53..ef621ef 100644
70747 --- a/include/linux/moduleloader.h
70748 +++ b/include/linux/moduleloader.h
70749 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
70750 sections. Returns NULL on failure. */
70751 void *module_alloc(unsigned long size);
70752
70753 +#ifdef CONFIG_PAX_KERNEXEC
70754 +void *module_alloc_exec(unsigned long size);
70755 +#else
70756 +#define module_alloc_exec(x) module_alloc(x)
70757 +#endif
70758 +
70759 /* Free memory returned from module_alloc. */
70760 void module_free(struct module *mod, void *module_region);
70761
70762 +#ifdef CONFIG_PAX_KERNEXEC
70763 +void module_free_exec(struct module *mod, void *module_region);
70764 +#else
70765 +#define module_free_exec(x, y) module_free((x), (y))
70766 +#endif
70767 +
70768 /*
70769 * Apply the given relocation to the (simplified) ELF. Return -error
70770 * or 0.
70771 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
70772 unsigned int relsec,
70773 struct module *me)
70774 {
70775 +#ifdef CONFIG_MODULES
70776 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70777 +#endif
70778 return -ENOEXEC;
70779 }
70780 #endif
70781 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
70782 unsigned int relsec,
70783 struct module *me)
70784 {
70785 +#ifdef CONFIG_MODULES
70786 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70787 +#endif
70788 return -ENOEXEC;
70789 }
70790 #endif
70791 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
70792 index 137b419..fe663ec 100644
70793 --- a/include/linux/moduleparam.h
70794 +++ b/include/linux/moduleparam.h
70795 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
70796 * @len is usually just sizeof(string).
70797 */
70798 #define module_param_string(name, string, len, perm) \
70799 - static const struct kparam_string __param_string_##name \
70800 + static const struct kparam_string __param_string_##name __used \
70801 = { len, string }; \
70802 __module_param_call(MODULE_PARAM_PREFIX, name, \
70803 &param_ops_string, \
70804 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
70805 */
70806 #define module_param_array_named(name, array, type, nump, perm) \
70807 param_check_##type(name, &(array)[0]); \
70808 - static const struct kparam_array __param_arr_##name \
70809 + static const struct kparam_array __param_arr_##name __used \
70810 = { .max = ARRAY_SIZE(array), .num = nump, \
70811 .ops = &param_ops_##type, \
70812 .elemsize = sizeof(array[0]), .elem = array }; \
70813 diff --git a/include/linux/namei.h b/include/linux/namei.h
70814 index 5a5ff57..5ae5070 100644
70815 --- a/include/linux/namei.h
70816 +++ b/include/linux/namei.h
70817 @@ -19,7 +19,7 @@ struct nameidata {
70818 unsigned seq;
70819 int last_type;
70820 unsigned depth;
70821 - char *saved_names[MAX_NESTED_LINKS + 1];
70822 + const char *saved_names[MAX_NESTED_LINKS + 1];
70823 };
70824
70825 /*
70826 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
70827
70828 extern void nd_jump_link(struct nameidata *nd, struct path *path);
70829
70830 -static inline void nd_set_link(struct nameidata *nd, char *path)
70831 +static inline void nd_set_link(struct nameidata *nd, const char *path)
70832 {
70833 nd->saved_names[nd->depth] = path;
70834 }
70835
70836 -static inline char *nd_get_link(struct nameidata *nd)
70837 +static inline const char *nd_get_link(const struct nameidata *nd)
70838 {
70839 return nd->saved_names[nd->depth];
70840 }
70841 diff --git a/include/linux/net.h b/include/linux/net.h
70842 index aa16731..514b875 100644
70843 --- a/include/linux/net.h
70844 +++ b/include/linux/net.h
70845 @@ -183,7 +183,7 @@ struct net_proto_family {
70846 int (*create)(struct net *net, struct socket *sock,
70847 int protocol, int kern);
70848 struct module *owner;
70849 -};
70850 +} __do_const;
70851
70852 struct iovec;
70853 struct kvec;
70854 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
70855 index 9ef07d0..130a5d9 100644
70856 --- a/include/linux/netdevice.h
70857 +++ b/include/linux/netdevice.h
70858 @@ -1012,6 +1012,7 @@ struct net_device_ops {
70859 u32 pid, u32 seq,
70860 struct net_device *dev);
70861 };
70862 +typedef struct net_device_ops __no_const net_device_ops_no_const;
70863
70864 /*
70865 * The DEVICE structure.
70866 @@ -1078,7 +1079,7 @@ struct net_device {
70867 int iflink;
70868
70869 struct net_device_stats stats;
70870 - atomic_long_t rx_dropped; /* dropped packets by core network
70871 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
70872 * Do not use this in drivers.
70873 */
70874
70875 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
70876 index ee14284..bc65d63 100644
70877 --- a/include/linux/netfilter.h
70878 +++ b/include/linux/netfilter.h
70879 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
70880 #endif
70881 /* Use the module struct to lock set/get code in place */
70882 struct module *owner;
70883 -};
70884 +} __do_const;
70885
70886 /* Function to register/unregister hook points. */
70887 int nf_register_hook(struct nf_hook_ops *reg);
70888 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
70889 index 7958e84..ed74d7a 100644
70890 --- a/include/linux/netfilter/ipset/ip_set.h
70891 +++ b/include/linux/netfilter/ipset/ip_set.h
70892 @@ -98,7 +98,7 @@ struct ip_set_type_variant {
70893 /* Return true if "b" set is the same as "a"
70894 * according to the create set parameters */
70895 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
70896 -};
70897 +} __do_const;
70898
70899 /* The core set type structure */
70900 struct ip_set_type {
70901 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
70902 index 4966dde..7d8ce06 100644
70903 --- a/include/linux/netfilter/nfnetlink.h
70904 +++ b/include/linux/netfilter/nfnetlink.h
70905 @@ -16,7 +16,7 @@ struct nfnl_callback {
70906 const struct nlattr * const cda[]);
70907 const struct nla_policy *policy; /* netlink attribute policy */
70908 const u_int16_t attr_count; /* number of nlattr's */
70909 -};
70910 +} __do_const;
70911
70912 struct nfnetlink_subsystem {
70913 const char *name;
70914 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
70915 new file mode 100644
70916 index 0000000..33f4af8
70917 --- /dev/null
70918 +++ b/include/linux/netfilter/xt_gradm.h
70919 @@ -0,0 +1,9 @@
70920 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
70921 +#define _LINUX_NETFILTER_XT_GRADM_H 1
70922 +
70923 +struct xt_gradm_mtinfo {
70924 + __u16 flags;
70925 + __u16 invflags;
70926 +};
70927 +
70928 +#endif
70929 diff --git a/include/linux/nls.h b/include/linux/nls.h
70930 index 5dc635f..35f5e11 100644
70931 --- a/include/linux/nls.h
70932 +++ b/include/linux/nls.h
70933 @@ -31,7 +31,7 @@ struct nls_table {
70934 const unsigned char *charset2upper;
70935 struct module *owner;
70936 struct nls_table *next;
70937 -};
70938 +} __do_const;
70939
70940 /* this value hold the maximum octet of charset */
70941 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
70942 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
70943 index d65746e..62e72c2 100644
70944 --- a/include/linux/notifier.h
70945 +++ b/include/linux/notifier.h
70946 @@ -51,7 +51,8 @@ struct notifier_block {
70947 int (*notifier_call)(struct notifier_block *, unsigned long, void *);
70948 struct notifier_block __rcu *next;
70949 int priority;
70950 -};
70951 +} __do_const;
70952 +typedef struct notifier_block __no_const notifier_block_no_const;
70953
70954 struct atomic_notifier_head {
70955 spinlock_t lock;
70956 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
70957 index a4c5624..79d6d88 100644
70958 --- a/include/linux/oprofile.h
70959 +++ b/include/linux/oprofile.h
70960 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
70961 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
70962 char const * name, ulong * val);
70963
70964 -/** Create a file for read-only access to an atomic_t. */
70965 +/** Create a file for read-only access to an atomic_unchecked_t. */
70966 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
70967 - char const * name, atomic_t * val);
70968 + char const * name, atomic_unchecked_t * val);
70969
70970 /** create a directory */
70971 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
70972 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
70973 index 45fc162..01a4068 100644
70974 --- a/include/linux/pci_hotplug.h
70975 +++ b/include/linux/pci_hotplug.h
70976 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
70977 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
70978 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
70979 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
70980 -};
70981 +} __do_const;
70982 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
70983
70984 /**
70985 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
70986 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
70987 index a280650..2b67b91 100644
70988 --- a/include/linux/perf_event.h
70989 +++ b/include/linux/perf_event.h
70990 @@ -328,8 +328,8 @@ struct perf_event {
70991
70992 enum perf_event_active_state state;
70993 unsigned int attach_state;
70994 - local64_t count;
70995 - atomic64_t child_count;
70996 + local64_t count; /* PaX: fix it one day */
70997 + atomic64_unchecked_t child_count;
70998
70999 /*
71000 * These are the total time in nanoseconds that the event
71001 @@ -380,8 +380,8 @@ struct perf_event {
71002 * These accumulate total time (in nanoseconds) that children
71003 * events have been enabled and running, respectively.
71004 */
71005 - atomic64_t child_total_time_enabled;
71006 - atomic64_t child_total_time_running;
71007 + atomic64_unchecked_t child_total_time_enabled;
71008 + atomic64_unchecked_t child_total_time_running;
71009
71010 /*
71011 * Protect attach/detach and child_list:
71012 @@ -807,7 +807,7 @@ static inline void perf_restore_debug_store(void) { }
71013 */
71014 #define perf_cpu_notifier(fn) \
71015 do { \
71016 - static struct notifier_block fn##_nb __cpuinitdata = \
71017 + static struct notifier_block fn##_nb = \
71018 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
71019 unsigned long cpu = smp_processor_id(); \
71020 unsigned long flags; \
71021 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
71022 index ad1a427..6419649 100644
71023 --- a/include/linux/pipe_fs_i.h
71024 +++ b/include/linux/pipe_fs_i.h
71025 @@ -45,9 +45,9 @@ struct pipe_buffer {
71026 struct pipe_inode_info {
71027 wait_queue_head_t wait;
71028 unsigned int nrbufs, curbuf, buffers;
71029 - unsigned int readers;
71030 - unsigned int writers;
71031 - unsigned int waiting_writers;
71032 + atomic_t readers;
71033 + atomic_t writers;
71034 + atomic_t waiting_writers;
71035 unsigned int r_counter;
71036 unsigned int w_counter;
71037 struct page *tmp_page;
71038 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
71039 index 5f28cae..3d23723 100644
71040 --- a/include/linux/platform_data/usb-ehci-s5p.h
71041 +++ b/include/linux/platform_data/usb-ehci-s5p.h
71042 @@ -14,7 +14,7 @@
71043 struct s5p_ehci_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 s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
71050
71051 diff --git a/include/linux/platform_data/usb-exynos.h b/include/linux/platform_data/usb-exynos.h
71052 index c256c59..8ea94c7 100644
71053 --- a/include/linux/platform_data/usb-exynos.h
71054 +++ b/include/linux/platform_data/usb-exynos.h
71055 @@ -14,7 +14,7 @@
71056 struct exynos4_ohci_platdata {
71057 int (*phy_init)(struct platform_device *pdev, int type);
71058 int (*phy_exit)(struct platform_device *pdev, int type);
71059 -};
71060 +} __no_const;
71061
71062 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
71063
71064 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
71065 index 7c1d252..c5c773e 100644
71066 --- a/include/linux/pm_domain.h
71067 +++ b/include/linux/pm_domain.h
71068 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
71069
71070 struct gpd_cpu_data {
71071 unsigned int saved_exit_latency;
71072 - struct cpuidle_state *idle_state;
71073 + cpuidle_state_no_const *idle_state;
71074 };
71075
71076 struct generic_pm_domain {
71077 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
71078 index f271860..6b3bec5 100644
71079 --- a/include/linux/pm_runtime.h
71080 +++ b/include/linux/pm_runtime.h
71081 @@ -97,7 +97,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
71082
71083 static inline void pm_runtime_mark_last_busy(struct device *dev)
71084 {
71085 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
71086 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
71087 }
71088
71089 #else /* !CONFIG_PM_RUNTIME */
71090 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
71091 index 195aafc..49a7bc2 100644
71092 --- a/include/linux/pnp.h
71093 +++ b/include/linux/pnp.h
71094 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
71095 struct pnp_fixup {
71096 char id[7];
71097 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
71098 -};
71099 +} __do_const;
71100
71101 /* config parameters */
71102 #define PNP_CONFIG_NORMAL 0x0001
71103 diff --git a/include/linux/poison.h b/include/linux/poison.h
71104 index 2110a81..13a11bb 100644
71105 --- a/include/linux/poison.h
71106 +++ b/include/linux/poison.h
71107 @@ -19,8 +19,8 @@
71108 * under normal circumstances, used to verify that nobody uses
71109 * non-initialized list entries.
71110 */
71111 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
71112 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
71113 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
71114 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
71115
71116 /********** include/linux/timer.h **********/
71117 /*
71118 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
71119 index c0f44c2..1572583 100644
71120 --- a/include/linux/power/smartreflex.h
71121 +++ b/include/linux/power/smartreflex.h
71122 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
71123 int (*notify)(struct omap_sr *sr, u32 status);
71124 u8 notify_flags;
71125 u8 class_type;
71126 -};
71127 +} __do_const;
71128
71129 /**
71130 * struct omap_sr_nvalue_table - Smartreflex n-target value info
71131 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
71132 index 4ea1d37..80f4b33 100644
71133 --- a/include/linux/ppp-comp.h
71134 +++ b/include/linux/ppp-comp.h
71135 @@ -84,7 +84,7 @@ struct compressor {
71136 struct module *owner;
71137 /* Extra skb space needed by the compressor algorithm */
71138 unsigned int comp_extra;
71139 -};
71140 +} __do_const;
71141
71142 /*
71143 * The return value from decompress routine is the length of the
71144 diff --git a/include/linux/printk.h b/include/linux/printk.h
71145 index 9afc01e..92c32e8 100644
71146 --- a/include/linux/printk.h
71147 +++ b/include/linux/printk.h
71148 @@ -101,6 +101,8 @@ void early_printk(const char *fmt, ...);
71149 extern int printk_needs_cpu(int cpu);
71150 extern void printk_tick(void);
71151
71152 +extern int kptr_restrict;
71153 +
71154 #ifdef CONFIG_PRINTK
71155 asmlinkage __printf(5, 0)
71156 int vprintk_emit(int facility, int level,
71157 @@ -135,7 +137,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
71158
71159 extern int printk_delay_msec;
71160 extern int dmesg_restrict;
71161 -extern int kptr_restrict;
71162
71163 void log_buf_kexec_setup(void);
71164 void __init setup_log_buf(int early);
71165 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
71166 index 32676b3..e46f2c0 100644
71167 --- a/include/linux/proc_fs.h
71168 +++ b/include/linux/proc_fs.h
71169 @@ -159,6 +159,18 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
71170 return proc_create_data(name, mode, parent, proc_fops, NULL);
71171 }
71172
71173 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
71174 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
71175 +{
71176 +#ifdef CONFIG_GRKERNSEC_PROC_USER
71177 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
71178 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
71179 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
71180 +#else
71181 + return proc_create_data(name, mode, parent, proc_fops, NULL);
71182 +#endif
71183 +}
71184 +
71185 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
71186 umode_t mode, struct proc_dir_entry *base,
71187 read_proc_t *read_proc, void * data)
71188 @@ -268,7 +280,7 @@ struct proc_ns_operations {
71189 void (*put)(void *ns);
71190 int (*install)(struct nsproxy *nsproxy, void *ns);
71191 unsigned int (*inum)(void *ns);
71192 -};
71193 +} __do_const;
71194 extern const struct proc_ns_operations netns_operations;
71195 extern const struct proc_ns_operations utsns_operations;
71196 extern const struct proc_ns_operations ipcns_operations;
71197 diff --git a/include/linux/random.h b/include/linux/random.h
71198 index d984608..d6f0042 100644
71199 --- a/include/linux/random.h
71200 +++ b/include/linux/random.h
71201 @@ -39,6 +39,11 @@ void prandom_seed(u32 seed);
71202 u32 prandom_u32_state(struct rnd_state *);
71203 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
71204
71205 +static inline unsigned long pax_get_random_long(void)
71206 +{
71207 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
71208 +}
71209 +
71210 /*
71211 * Handle minimum values for seeds
71212 */
71213 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
71214 index c92dd28..08f4eab 100644
71215 --- a/include/linux/rculist.h
71216 +++ b/include/linux/rculist.h
71217 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
71218 struct list_head *prev, struct list_head *next);
71219 #endif
71220
71221 +extern void __pax_list_add_rcu(struct list_head *new,
71222 + struct list_head *prev, struct list_head *next);
71223 +
71224 /**
71225 * list_add_rcu - add a new entry to rcu-protected list
71226 * @new: new entry to be added
71227 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
71228 __list_add_rcu(new, head, head->next);
71229 }
71230
71231 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
71232 +{
71233 + __pax_list_add_rcu(new, head, head->next);
71234 +}
71235 +
71236 /**
71237 * list_add_tail_rcu - add a new entry to rcu-protected list
71238 * @new: new entry to be added
71239 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
71240 __list_add_rcu(new, head->prev, head);
71241 }
71242
71243 +static inline void pax_list_add_tail_rcu(struct list_head *new,
71244 + struct list_head *head)
71245 +{
71246 + __pax_list_add_rcu(new, head->prev, head);
71247 +}
71248 +
71249 /**
71250 * list_del_rcu - deletes entry from list without re-initialization
71251 * @entry: the element to delete from the list.
71252 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
71253 entry->prev = LIST_POISON2;
71254 }
71255
71256 +extern void pax_list_del_rcu(struct list_head *entry);
71257 +
71258 /**
71259 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
71260 * @n: the element to delete from the hash list.
71261 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
71262 index 23b3630..e1bc12b 100644
71263 --- a/include/linux/reboot.h
71264 +++ b/include/linux/reboot.h
71265 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
71266 * Architecture-specific implementations of sys_reboot commands.
71267 */
71268
71269 -extern void machine_restart(char *cmd);
71270 -extern void machine_halt(void);
71271 -extern void machine_power_off(void);
71272 +extern void machine_restart(char *cmd) __noreturn;
71273 +extern void machine_halt(void) __noreturn;
71274 +extern void machine_power_off(void) __noreturn;
71275
71276 extern void machine_shutdown(void);
71277 struct pt_regs;
71278 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
71279 */
71280
71281 extern void kernel_restart_prepare(char *cmd);
71282 -extern void kernel_restart(char *cmd);
71283 -extern void kernel_halt(void);
71284 -extern void kernel_power_off(void);
71285 +extern void kernel_restart(char *cmd) __noreturn;
71286 +extern void kernel_halt(void) __noreturn;
71287 +extern void kernel_power_off(void) __noreturn;
71288
71289 extern int C_A_D; /* for sysctl */
71290 void ctrl_alt_del(void);
71291 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
71292 * Emergency restart, callable from an interrupt handler.
71293 */
71294
71295 -extern void emergency_restart(void);
71296 +extern void emergency_restart(void) __noreturn;
71297 #include <asm/emergency-restart.h>
71298
71299 #endif /* _LINUX_REBOOT_H */
71300 diff --git a/include/linux/regset.h b/include/linux/regset.h
71301 index 8e0c9fe..ac4d221 100644
71302 --- a/include/linux/regset.h
71303 +++ b/include/linux/regset.h
71304 @@ -161,7 +161,8 @@ struct user_regset {
71305 unsigned int align;
71306 unsigned int bias;
71307 unsigned int core_note_type;
71308 -};
71309 +} __do_const;
71310 +typedef struct user_regset __no_const user_regset_no_const;
71311
71312 /**
71313 * struct user_regset_view - available regsets
71314 diff --git a/include/linux/relay.h b/include/linux/relay.h
71315 index 91cacc3..b55ff74 100644
71316 --- a/include/linux/relay.h
71317 +++ b/include/linux/relay.h
71318 @@ -160,7 +160,7 @@ struct rchan_callbacks
71319 * The callback should return 0 if successful, negative if not.
71320 */
71321 int (*remove_buf_file)(struct dentry *dentry);
71322 -};
71323 +} __no_const;
71324
71325 /*
71326 * CONFIG_RELAY kernel API, kernel/relay.c
71327 diff --git a/include/linux/rio.h b/include/linux/rio.h
71328 index a3e7842..d973ca6 100644
71329 --- a/include/linux/rio.h
71330 +++ b/include/linux/rio.h
71331 @@ -339,7 +339,7 @@ struct rio_ops {
71332 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
71333 u64 rstart, u32 size, u32 flags);
71334 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
71335 -};
71336 +} __no_const;
71337
71338 #define RIO_RESOURCE_MEM 0x00000100
71339 #define RIO_RESOURCE_DOORBELL 0x00000200
71340 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
71341 index c20635c..2f5def4 100644
71342 --- a/include/linux/rmap.h
71343 +++ b/include/linux/rmap.h
71344 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
71345 void anon_vma_init(void); /* create anon_vma_cachep */
71346 int anon_vma_prepare(struct vm_area_struct *);
71347 void unlink_anon_vmas(struct vm_area_struct *);
71348 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
71349 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
71350 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
71351 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
71352
71353 static inline void anon_vma_merge(struct vm_area_struct *vma,
71354 struct vm_area_struct *next)
71355 diff --git a/include/linux/sched.h b/include/linux/sched.h
71356 index d211247..eac6c2c 100644
71357 --- a/include/linux/sched.h
71358 +++ b/include/linux/sched.h
71359 @@ -61,6 +61,7 @@ struct bio_list;
71360 struct fs_struct;
71361 struct perf_event_context;
71362 struct blk_plug;
71363 +struct linux_binprm;
71364
71365 /*
71366 * List of flags we want to share for kernel threads,
71367 @@ -327,7 +328,7 @@ extern char __sched_text_start[], __sched_text_end[];
71368 extern int in_sched_functions(unsigned long addr);
71369
71370 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
71371 -extern signed long schedule_timeout(signed long timeout);
71372 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
71373 extern signed long schedule_timeout_interruptible(signed long timeout);
71374 extern signed long schedule_timeout_killable(signed long timeout);
71375 extern signed long schedule_timeout_uninterruptible(signed long timeout);
71376 @@ -354,10 +355,23 @@ struct user_namespace;
71377 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
71378
71379 extern int sysctl_max_map_count;
71380 +extern unsigned long sysctl_heap_stack_gap;
71381
71382 #include <linux/aio.h>
71383
71384 #ifdef CONFIG_MMU
71385 +
71386 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
71387 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
71388 +#else
71389 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
71390 +{
71391 + return 0;
71392 +}
71393 +#endif
71394 +
71395 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
71396 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
71397 extern void arch_pick_mmap_layout(struct mm_struct *mm);
71398 extern unsigned long
71399 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
71400 @@ -639,6 +653,17 @@ struct signal_struct {
71401 #ifdef CONFIG_TASKSTATS
71402 struct taskstats *stats;
71403 #endif
71404 +
71405 +#ifdef CONFIG_GRKERNSEC
71406 + u32 curr_ip;
71407 + u32 saved_ip;
71408 + u32 gr_saddr;
71409 + u32 gr_daddr;
71410 + u16 gr_sport;
71411 + u16 gr_dport;
71412 + u8 used_accept:1;
71413 +#endif
71414 +
71415 #ifdef CONFIG_AUDIT
71416 unsigned audit_tty;
71417 struct tty_audit_buf *tty_audit_buf;
71418 @@ -717,6 +742,11 @@ struct user_struct {
71419 struct key *session_keyring; /* UID's default session keyring */
71420 #endif
71421
71422 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
71423 + unsigned int banned;
71424 + unsigned long ban_expires;
71425 +#endif
71426 +
71427 /* Hash table maintenance information */
71428 struct hlist_node uidhash_node;
71429 kuid_t uid;
71430 @@ -1116,7 +1146,7 @@ struct sched_class {
71431 #ifdef CONFIG_FAIR_GROUP_SCHED
71432 void (*task_move_group) (struct task_struct *p, int on_rq);
71433 #endif
71434 -};
71435 +} __do_const;
71436
71437 struct load_weight {
71438 unsigned long weight, inv_weight;
71439 @@ -1360,8 +1390,8 @@ struct task_struct {
71440 struct list_head thread_group;
71441
71442 struct completion *vfork_done; /* for vfork() */
71443 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
71444 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71445 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
71446 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71447
71448 cputime_t utime, stime, utimescaled, stimescaled;
71449 cputime_t gtime;
71450 @@ -1377,11 +1407,6 @@ struct task_struct {
71451 struct task_cputime cputime_expires;
71452 struct list_head cpu_timers[3];
71453
71454 -/* process credentials */
71455 - const struct cred __rcu *real_cred; /* objective and real subjective task
71456 - * credentials (COW) */
71457 - const struct cred __rcu *cred; /* effective (overridable) subjective task
71458 - * credentials (COW) */
71459 char comm[TASK_COMM_LEN]; /* executable name excluding path
71460 - access with [gs]et_task_comm (which lock
71461 it with task_lock())
71462 @@ -1398,6 +1423,10 @@ struct task_struct {
71463 #endif
71464 /* CPU-specific state of this task */
71465 struct thread_struct thread;
71466 +/* thread_info moved to task_struct */
71467 +#ifdef CONFIG_X86
71468 + struct thread_info tinfo;
71469 +#endif
71470 /* filesystem information */
71471 struct fs_struct *fs;
71472 /* open file information */
71473 @@ -1471,6 +1500,10 @@ struct task_struct {
71474 gfp_t lockdep_reclaim_gfp;
71475 #endif
71476
71477 +/* process credentials */
71478 + const struct cred __rcu *real_cred; /* objective and real subjective task
71479 + * credentials (COW) */
71480 +
71481 /* journalling filesystem info */
71482 void *journal_info;
71483
71484 @@ -1509,6 +1542,10 @@ struct task_struct {
71485 /* cg_list protected by css_set_lock and tsk->alloc_lock */
71486 struct list_head cg_list;
71487 #endif
71488 +
71489 + const struct cred __rcu *cred; /* effective (overridable) subjective task
71490 + * credentials (COW) */
71491 +
71492 #ifdef CONFIG_FUTEX
71493 struct robust_list_head __user *robust_list;
71494 #ifdef CONFIG_COMPAT
71495 @@ -1605,8 +1642,74 @@ struct task_struct {
71496 #ifdef CONFIG_UPROBES
71497 struct uprobe_task *utask;
71498 #endif
71499 +
71500 +#ifdef CONFIG_GRKERNSEC
71501 + /* grsecurity */
71502 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71503 + u64 exec_id;
71504 +#endif
71505 +#ifdef CONFIG_GRKERNSEC_SETXID
71506 + const struct cred *delayed_cred;
71507 +#endif
71508 + struct dentry *gr_chroot_dentry;
71509 + struct acl_subject_label *acl;
71510 + struct acl_role_label *role;
71511 + struct file *exec_file;
71512 + unsigned long brute_expires;
71513 + u16 acl_role_id;
71514 + /* is this the task that authenticated to the special role */
71515 + u8 acl_sp_role;
71516 + u8 is_writable;
71517 + u8 brute;
71518 + u8 gr_is_chrooted;
71519 +#endif
71520 +
71521 };
71522
71523 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
71524 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
71525 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
71526 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
71527 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
71528 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
71529 +
71530 +#ifdef CONFIG_PAX_SOFTMODE
71531 +extern int pax_softmode;
71532 +#endif
71533 +
71534 +extern int pax_check_flags(unsigned long *);
71535 +
71536 +/* if tsk != current then task_lock must be held on it */
71537 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
71538 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
71539 +{
71540 + if (likely(tsk->mm))
71541 + return tsk->mm->pax_flags;
71542 + else
71543 + return 0UL;
71544 +}
71545 +
71546 +/* if tsk != current then task_lock must be held on it */
71547 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
71548 +{
71549 + if (likely(tsk->mm)) {
71550 + tsk->mm->pax_flags = flags;
71551 + return 0;
71552 + }
71553 + return -EINVAL;
71554 +}
71555 +#endif
71556 +
71557 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
71558 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
71559 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
71560 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
71561 +#endif
71562 +
71563 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
71564 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
71565 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
71566 +
71567 /* Future-safe accessor for struct task_struct's cpus_allowed. */
71568 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
71569
71570 @@ -1696,7 +1799,7 @@ struct pid_namespace;
71571 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
71572 struct pid_namespace *ns);
71573
71574 -static inline pid_t task_pid_nr(struct task_struct *tsk)
71575 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
71576 {
71577 return tsk->pid;
71578 }
71579 @@ -2155,7 +2258,9 @@ void yield(void);
71580 extern struct exec_domain default_exec_domain;
71581
71582 union thread_union {
71583 +#ifndef CONFIG_X86
71584 struct thread_info thread_info;
71585 +#endif
71586 unsigned long stack[THREAD_SIZE/sizeof(long)];
71587 };
71588
71589 @@ -2188,6 +2293,7 @@ extern struct pid_namespace init_pid_ns;
71590 */
71591
71592 extern struct task_struct *find_task_by_vpid(pid_t nr);
71593 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
71594 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
71595 struct pid_namespace *ns);
71596
71597 @@ -2344,7 +2450,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
71598 extern void exit_itimers(struct signal_struct *);
71599 extern void flush_itimer_signals(void);
71600
71601 -extern void do_group_exit(int);
71602 +extern __noreturn void do_group_exit(int);
71603
71604 extern int allow_signal(int);
71605 extern int disallow_signal(int);
71606 @@ -2545,9 +2651,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
71607
71608 #endif
71609
71610 -static inline int object_is_on_stack(void *obj)
71611 +static inline int object_starts_on_stack(void *obj)
71612 {
71613 - void *stack = task_stack_page(current);
71614 + const void *stack = task_stack_page(current);
71615
71616 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
71617 }
71618 diff --git a/include/linux/security.h b/include/linux/security.h
71619 index eee7478..290f7ba 100644
71620 --- a/include/linux/security.h
71621 +++ b/include/linux/security.h
71622 @@ -26,6 +26,7 @@
71623 #include <linux/capability.h>
71624 #include <linux/slab.h>
71625 #include <linux/err.h>
71626 +#include <linux/grsecurity.h>
71627
71628 struct linux_binprm;
71629 struct cred;
71630 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
71631 index 68a04a3..866e6a1 100644
71632 --- a/include/linux/seq_file.h
71633 +++ b/include/linux/seq_file.h
71634 @@ -26,6 +26,9 @@ struct seq_file {
71635 struct mutex lock;
71636 const struct seq_operations *op;
71637 int poll_event;
71638 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71639 + u64 exec_id;
71640 +#endif
71641 #ifdef CONFIG_USER_NS
71642 struct user_namespace *user_ns;
71643 #endif
71644 @@ -38,6 +41,7 @@ struct seq_operations {
71645 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
71646 int (*show) (struct seq_file *m, void *v);
71647 };
71648 +typedef struct seq_operations __no_const seq_operations_no_const;
71649
71650 #define SEQ_SKIP 1
71651
71652 diff --git a/include/linux/shm.h b/include/linux/shm.h
71653 index 429c199..4d42e38 100644
71654 --- a/include/linux/shm.h
71655 +++ b/include/linux/shm.h
71656 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
71657
71658 /* The task created the shm object. NULL if the task is dead. */
71659 struct task_struct *shm_creator;
71660 +#ifdef CONFIG_GRKERNSEC
71661 + time_t shm_createtime;
71662 + pid_t shm_lapid;
71663 +#endif
71664 };
71665
71666 /* shm_mode upper byte flags */
71667 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
71668 index 98399e2..7c74c41 100644
71669 --- a/include/linux/skbuff.h
71670 +++ b/include/linux/skbuff.h
71671 @@ -590,7 +590,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
71672 extern struct sk_buff *__alloc_skb(unsigned int size,
71673 gfp_t priority, int flags, int node);
71674 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
71675 -static inline struct sk_buff *alloc_skb(unsigned int size,
71676 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
71677 gfp_t priority)
71678 {
71679 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
71680 @@ -700,7 +700,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
71681 */
71682 static inline int skb_queue_empty(const struct sk_buff_head *list)
71683 {
71684 - return list->next == (struct sk_buff *)list;
71685 + return list->next == (const struct sk_buff *)list;
71686 }
71687
71688 /**
71689 @@ -713,7 +713,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
71690 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71691 const struct sk_buff *skb)
71692 {
71693 - return skb->next == (struct sk_buff *)list;
71694 + return skb->next == (const struct sk_buff *)list;
71695 }
71696
71697 /**
71698 @@ -726,7 +726,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71699 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
71700 const struct sk_buff *skb)
71701 {
71702 - return skb->prev == (struct sk_buff *)list;
71703 + return skb->prev == (const struct sk_buff *)list;
71704 }
71705
71706 /**
71707 @@ -1727,7 +1727,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
71708 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
71709 */
71710 #ifndef NET_SKB_PAD
71711 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
71712 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
71713 #endif
71714
71715 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
71716 @@ -2305,7 +2305,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
71717 int noblock, int *err);
71718 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
71719 struct poll_table_struct *wait);
71720 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
71721 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
71722 int offset, struct iovec *to,
71723 int size);
71724 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
71725 @@ -2595,6 +2595,9 @@ static inline void nf_reset(struct sk_buff *skb)
71726 nf_bridge_put(skb->nf_bridge);
71727 skb->nf_bridge = NULL;
71728 #endif
71729 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
71730 + skb->nf_trace = 0;
71731 +#endif
71732 }
71733
71734 /* Note: This doesn't put any conntrack and bridge info in dst. */
71735 diff --git a/include/linux/slab.h b/include/linux/slab.h
71736 index 5d168d7..720bff3 100644
71737 --- a/include/linux/slab.h
71738 +++ b/include/linux/slab.h
71739 @@ -12,13 +12,20 @@
71740 #include <linux/gfp.h>
71741 #include <linux/types.h>
71742 #include <linux/workqueue.h>
71743 -
71744 +#include <linux/err.h>
71745
71746 /*
71747 * Flags to pass to kmem_cache_create().
71748 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
71749 */
71750 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
71751 +
71752 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71753 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
71754 +#else
71755 +#define SLAB_USERCOPY 0x00000000UL
71756 +#endif
71757 +
71758 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
71759 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
71760 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
71761 @@ -89,10 +96,13 @@
71762 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
71763 * Both make kfree a no-op.
71764 */
71765 -#define ZERO_SIZE_PTR ((void *)16)
71766 +#define ZERO_SIZE_PTR \
71767 +({ \
71768 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
71769 + (void *)(-MAX_ERRNO-1L); \
71770 +})
71771
71772 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
71773 - (unsigned long)ZERO_SIZE_PTR)
71774 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
71775
71776 /*
71777 * Common fields provided in kmem_cache by all slab allocators
71778 @@ -112,7 +122,7 @@ struct kmem_cache {
71779 unsigned int align; /* Alignment as calculated */
71780 unsigned long flags; /* Active flags on the slab */
71781 const char *name; /* Slab name for sysfs */
71782 - int refcount; /* Use counter */
71783 + atomic_t refcount; /* Use counter */
71784 void (*ctor)(void *); /* Called on object slot creation */
71785 struct list_head list; /* List of all slab caches on the system */
71786 };
71787 @@ -232,6 +242,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
71788 void kfree(const void *);
71789 void kzfree(const void *);
71790 size_t ksize(const void *);
71791 +const char *check_heap_object(const void *ptr, unsigned long n);
71792 +bool is_usercopy_object(const void *ptr);
71793
71794 /*
71795 * Allocator specific definitions. These are mainly used to establish optimized
71796 @@ -311,6 +323,7 @@ size_t ksize(const void *);
71797 * for general use, and so are not documented here. For a full list of
71798 * potential flags, always refer to linux/gfp.h.
71799 */
71800 +
71801 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
71802 {
71803 if (size != 0 && n > SIZE_MAX / size)
71804 @@ -370,7 +383,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
71805 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71806 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71807 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71808 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71809 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
71810 #define kmalloc_track_caller(size, flags) \
71811 __kmalloc_track_caller(size, flags, _RET_IP_)
71812 #else
71813 @@ -390,7 +403,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71814 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71815 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71816 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71817 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
71818 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
71819 #define kmalloc_node_track_caller(size, flags, node) \
71820 __kmalloc_node_track_caller(size, flags, node, \
71821 _RET_IP_)
71822 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
71823 index 8bb6e0e..8eb0dbe 100644
71824 --- a/include/linux/slab_def.h
71825 +++ b/include/linux/slab_def.h
71826 @@ -52,7 +52,7 @@ struct kmem_cache {
71827 /* 4) cache creation/removal */
71828 const char *name;
71829 struct list_head list;
71830 - int refcount;
71831 + atomic_t refcount;
71832 int object_size;
71833 int align;
71834
71835 @@ -68,10 +68,10 @@ struct kmem_cache {
71836 unsigned long node_allocs;
71837 unsigned long node_frees;
71838 unsigned long node_overflow;
71839 - atomic_t allochit;
71840 - atomic_t allocmiss;
71841 - atomic_t freehit;
71842 - atomic_t freemiss;
71843 + atomic_unchecked_t allochit;
71844 + atomic_unchecked_t allocmiss;
71845 + atomic_unchecked_t freehit;
71846 + atomic_unchecked_t freemiss;
71847
71848 /*
71849 * If debugging is enabled, then the allocator can add additional
71850 @@ -111,11 +111,16 @@ struct cache_sizes {
71851 #ifdef CONFIG_ZONE_DMA
71852 struct kmem_cache *cs_dmacachep;
71853 #endif
71854 +
71855 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71856 + struct kmem_cache *cs_usercopycachep;
71857 +#endif
71858 +
71859 };
71860 extern struct cache_sizes malloc_sizes[];
71861
71862 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71863 -void *__kmalloc(size_t size, gfp_t flags);
71864 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
71865
71866 #ifdef CONFIG_TRACING
71867 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
71868 @@ -152,6 +157,13 @@ found:
71869 cachep = malloc_sizes[i].cs_dmacachep;
71870 else
71871 #endif
71872 +
71873 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71874 + if (flags & GFP_USERCOPY)
71875 + cachep = malloc_sizes[i].cs_usercopycachep;
71876 + else
71877 +#endif
71878 +
71879 cachep = malloc_sizes[i].cs_cachep;
71880
71881 ret = kmem_cache_alloc_trace(cachep, flags, size);
71882 @@ -162,7 +174,7 @@ found:
71883 }
71884
71885 #ifdef CONFIG_NUMA
71886 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
71887 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71888 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71889
71890 #ifdef CONFIG_TRACING
71891 @@ -205,6 +217,13 @@ found:
71892 cachep = malloc_sizes[i].cs_dmacachep;
71893 else
71894 #endif
71895 +
71896 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71897 + if (flags & GFP_USERCOPY)
71898 + cachep = malloc_sizes[i].cs_usercopycachep;
71899 + else
71900 +#endif
71901 +
71902 cachep = malloc_sizes[i].cs_cachep;
71903
71904 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
71905 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
71906 index f28e14a..7831211 100644
71907 --- a/include/linux/slob_def.h
71908 +++ b/include/linux/slob_def.h
71909 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
71910 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
71911 }
71912
71913 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71914 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71915
71916 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
71917 {
71918 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71919 return __kmalloc_node(size, flags, NUMA_NO_NODE);
71920 }
71921
71922 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
71923 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
71924 {
71925 return kmalloc(size, flags);
71926 }
71927 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
71928 index 9db4825..ed42fb5 100644
71929 --- a/include/linux/slub_def.h
71930 +++ b/include/linux/slub_def.h
71931 @@ -91,7 +91,7 @@ struct kmem_cache {
71932 struct kmem_cache_order_objects max;
71933 struct kmem_cache_order_objects min;
71934 gfp_t allocflags; /* gfp flags to use on each alloc */
71935 - int refcount; /* Refcount for slab cache destroy */
71936 + atomic_t refcount; /* Refcount for slab cache destroy */
71937 void (*ctor)(void *);
71938 int inuse; /* Offset to metadata */
71939 int align; /* Alignment */
71940 @@ -156,7 +156,7 @@ extern struct kmem_cache *kmalloc_caches[SLUB_PAGE_SHIFT];
71941 * Sorry that the following has to be that ugly but some versions of GCC
71942 * have trouble with constant propagation and loops.
71943 */
71944 -static __always_inline int kmalloc_index(size_t size)
71945 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
71946 {
71947 if (!size)
71948 return 0;
71949 @@ -221,7 +221,7 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
71950 }
71951
71952 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71953 -void *__kmalloc(size_t size, gfp_t flags);
71954 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
71955
71956 static __always_inline void *
71957 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
71958 @@ -265,7 +265,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
71959 }
71960 #endif
71961
71962 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
71963 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
71964 {
71965 unsigned int order = get_order(size);
71966 return kmalloc_order_trace(size, flags, order);
71967 @@ -290,7 +290,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71968 }
71969
71970 #ifdef CONFIG_NUMA
71971 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71972 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71973 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71974
71975 #ifdef CONFIG_TRACING
71976 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
71977 index e8d702e..0a56eb4 100644
71978 --- a/include/linux/sock_diag.h
71979 +++ b/include/linux/sock_diag.h
71980 @@ -10,7 +10,7 @@ struct sock;
71981 struct sock_diag_handler {
71982 __u8 family;
71983 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
71984 -};
71985 +} __do_const;
71986
71987 int sock_diag_register(const struct sock_diag_handler *h);
71988 void sock_diag_unregister(const struct sock_diag_handler *h);
71989 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
71990 index 680f9a3..f13aeb0 100644
71991 --- a/include/linux/sonet.h
71992 +++ b/include/linux/sonet.h
71993 @@ -7,7 +7,7 @@
71994 #include <uapi/linux/sonet.h>
71995
71996 struct k_sonet_stats {
71997 -#define __HANDLE_ITEM(i) atomic_t i
71998 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
71999 __SONET_ITEMS
72000 #undef __HANDLE_ITEM
72001 };
72002 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
72003 index 34206b8..3db7f1c 100644
72004 --- a/include/linux/sunrpc/clnt.h
72005 +++ b/include/linux/sunrpc/clnt.h
72006 @@ -96,7 +96,7 @@ struct rpc_procinfo {
72007 unsigned int p_timer; /* Which RTT timer to use */
72008 u32 p_statidx; /* Which procedure to account */
72009 const char * p_name; /* name of procedure */
72010 -};
72011 +} __do_const;
72012
72013 #ifdef __KERNEL__
72014
72015 @@ -176,9 +176,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
72016 {
72017 switch (sap->sa_family) {
72018 case AF_INET:
72019 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
72020 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
72021 case AF_INET6:
72022 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
72023 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
72024 }
72025 return 0;
72026 }
72027 @@ -211,7 +211,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
72028 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
72029 const struct sockaddr *src)
72030 {
72031 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
72032 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
72033 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
72034
72035 dsin->sin_family = ssin->sin_family;
72036 @@ -314,7 +314,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
72037 if (sa->sa_family != AF_INET6)
72038 return 0;
72039
72040 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
72041 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
72042 }
72043
72044 #endif /* __KERNEL__ */
72045 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
72046 index 676ddf5..4c519a1 100644
72047 --- a/include/linux/sunrpc/svc.h
72048 +++ b/include/linux/sunrpc/svc.h
72049 @@ -410,7 +410,7 @@ struct svc_procedure {
72050 unsigned int pc_count; /* call count */
72051 unsigned int pc_cachetype; /* cache info (NFS) */
72052 unsigned int pc_xdrressize; /* maximum size of XDR reply */
72053 -};
72054 +} __do_const;
72055
72056 /*
72057 * Function prototypes.
72058 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
72059 index 0b8e3e6..33e0a01 100644
72060 --- a/include/linux/sunrpc/svc_rdma.h
72061 +++ b/include/linux/sunrpc/svc_rdma.h
72062 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
72063 extern unsigned int svcrdma_max_requests;
72064 extern unsigned int svcrdma_max_req_size;
72065
72066 -extern atomic_t rdma_stat_recv;
72067 -extern atomic_t rdma_stat_read;
72068 -extern atomic_t rdma_stat_write;
72069 -extern atomic_t rdma_stat_sq_starve;
72070 -extern atomic_t rdma_stat_rq_starve;
72071 -extern atomic_t rdma_stat_rq_poll;
72072 -extern atomic_t rdma_stat_rq_prod;
72073 -extern atomic_t rdma_stat_sq_poll;
72074 -extern atomic_t rdma_stat_sq_prod;
72075 +extern atomic_unchecked_t rdma_stat_recv;
72076 +extern atomic_unchecked_t rdma_stat_read;
72077 +extern atomic_unchecked_t rdma_stat_write;
72078 +extern atomic_unchecked_t rdma_stat_sq_starve;
72079 +extern atomic_unchecked_t rdma_stat_rq_starve;
72080 +extern atomic_unchecked_t rdma_stat_rq_poll;
72081 +extern atomic_unchecked_t rdma_stat_rq_prod;
72082 +extern atomic_unchecked_t rdma_stat_sq_poll;
72083 +extern atomic_unchecked_t rdma_stat_sq_prod;
72084
72085 #define RPCRDMA_VERSION 1
72086
72087 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
72088 index dd74084a..7f509d5 100644
72089 --- a/include/linux/sunrpc/svcauth.h
72090 +++ b/include/linux/sunrpc/svcauth.h
72091 @@ -109,7 +109,7 @@ struct auth_ops {
72092 int (*release)(struct svc_rqst *rq);
72093 void (*domain_release)(struct auth_domain *);
72094 int (*set_client)(struct svc_rqst *rq);
72095 -};
72096 +} __do_const;
72097
72098 #define SVC_GARBAGE 1
72099 #define SVC_SYSERR 2
72100 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
72101 index 071d62c..4ccc7ac 100644
72102 --- a/include/linux/swiotlb.h
72103 +++ b/include/linux/swiotlb.h
72104 @@ -59,7 +59,8 @@ extern void
72105
72106 extern void
72107 swiotlb_free_coherent(struct device *hwdev, size_t size,
72108 - void *vaddr, dma_addr_t dma_handle);
72109 + void *vaddr, dma_addr_t dma_handle,
72110 + struct dma_attrs *attrs);
72111
72112 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
72113 unsigned long offset, size_t size,
72114 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
72115 index 45e2db2..1635156a 100644
72116 --- a/include/linux/syscalls.h
72117 +++ b/include/linux/syscalls.h
72118 @@ -615,7 +615,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
72119 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
72120 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
72121 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
72122 - struct sockaddr __user *, int);
72123 + struct sockaddr __user *, int) __intentional_overflow(0);
72124 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
72125 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
72126 unsigned int vlen, unsigned flags);
72127 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
72128 index 27b3b0b..e093dd9 100644
72129 --- a/include/linux/syscore_ops.h
72130 +++ b/include/linux/syscore_ops.h
72131 @@ -16,7 +16,7 @@ struct syscore_ops {
72132 int (*suspend)(void);
72133 void (*resume)(void);
72134 void (*shutdown)(void);
72135 -};
72136 +} __do_const;
72137
72138 extern void register_syscore_ops(struct syscore_ops *ops);
72139 extern void unregister_syscore_ops(struct syscore_ops *ops);
72140 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
72141 index 14a8ff2..af52bad 100644
72142 --- a/include/linux/sysctl.h
72143 +++ b/include/linux/sysctl.h
72144 @@ -34,13 +34,13 @@ struct ctl_table_root;
72145 struct ctl_table_header;
72146 struct ctl_dir;
72147
72148 -typedef struct ctl_table ctl_table;
72149 -
72150 typedef int proc_handler (struct ctl_table *ctl, int write,
72151 void __user *buffer, size_t *lenp, loff_t *ppos);
72152
72153 extern int proc_dostring(struct ctl_table *, int,
72154 void __user *, size_t *, loff_t *);
72155 +extern int proc_dostring_modpriv(struct ctl_table *, int,
72156 + void __user *, size_t *, loff_t *);
72157 extern int proc_dointvec(struct ctl_table *, int,
72158 void __user *, size_t *, loff_t *);
72159 extern int proc_dointvec_minmax(struct ctl_table *, int,
72160 @@ -115,7 +115,9 @@ struct ctl_table
72161 struct ctl_table_poll *poll;
72162 void *extra1;
72163 void *extra2;
72164 -};
72165 +} __do_const;
72166 +typedef struct ctl_table __no_const ctl_table_no_const;
72167 +typedef struct ctl_table ctl_table;
72168
72169 struct ctl_node {
72170 struct rb_node node;
72171 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
72172 index 381f06d..dc16cc7 100644
72173 --- a/include/linux/sysfs.h
72174 +++ b/include/linux/sysfs.h
72175 @@ -31,7 +31,8 @@ struct attribute {
72176 struct lock_class_key *key;
72177 struct lock_class_key skey;
72178 #endif
72179 -};
72180 +} __do_const;
72181 +typedef struct attribute __no_const attribute_no_const;
72182
72183 /**
72184 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
72185 @@ -59,8 +60,8 @@ struct attribute_group {
72186 umode_t (*is_visible)(struct kobject *,
72187 struct attribute *, int);
72188 struct attribute **attrs;
72189 -};
72190 -
72191 +} __do_const;
72192 +typedef struct attribute_group __no_const attribute_group_no_const;
72193
72194
72195 /**
72196 @@ -107,7 +108,8 @@ struct bin_attribute {
72197 char *, loff_t, size_t);
72198 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
72199 struct vm_area_struct *vma);
72200 -};
72201 +} __do_const;
72202 +typedef struct bin_attribute __no_const bin_attribute_no_const;
72203
72204 /**
72205 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
72206 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
72207 index 7faf933..9b85a0c 100644
72208 --- a/include/linux/sysrq.h
72209 +++ b/include/linux/sysrq.h
72210 @@ -16,6 +16,7 @@
72211
72212 #include <linux/errno.h>
72213 #include <linux/types.h>
72214 +#include <linux/compiler.h>
72215
72216 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
72217 #define SYSRQ_DEFAULT_ENABLE 1
72218 @@ -36,7 +37,7 @@ struct sysrq_key_op {
72219 char *help_msg;
72220 char *action_msg;
72221 int enable_mask;
72222 -};
72223 +} __do_const;
72224
72225 #ifdef CONFIG_MAGIC_SYSRQ
72226
72227 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
72228 index e7e0473..7989295 100644
72229 --- a/include/linux/thread_info.h
72230 +++ b/include/linux/thread_info.h
72231 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
72232 #error "no set_restore_sigmask() provided and default one won't work"
72233 #endif
72234
72235 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
72236 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
72237 +{
72238 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
72239 + if (!__builtin_constant_p(n))
72240 +#endif
72241 + __check_object_size(ptr, n, to_user);
72242 +}
72243 +
72244 #endif /* __KERNEL__ */
72245
72246 #endif /* _LINUX_THREAD_INFO_H */
72247 diff --git a/include/linux/tty.h b/include/linux/tty.h
72248 index 8db1b56..c16a040 100644
72249 --- a/include/linux/tty.h
72250 +++ b/include/linux/tty.h
72251 @@ -194,7 +194,7 @@ struct tty_port {
72252 const struct tty_port_operations *ops; /* Port operations */
72253 spinlock_t lock; /* Lock protecting tty field */
72254 int blocked_open; /* Waiting to open */
72255 - int count; /* Usage count */
72256 + atomic_t count; /* Usage count */
72257 wait_queue_head_t open_wait; /* Open waiters */
72258 wait_queue_head_t close_wait; /* Close waiters */
72259 wait_queue_head_t delta_msr_wait; /* Modem status change */
72260 @@ -490,7 +490,7 @@ extern int tty_port_open(struct tty_port *port,
72261 struct tty_struct *tty, struct file *filp);
72262 static inline int tty_port_users(struct tty_port *port)
72263 {
72264 - return port->count + port->blocked_open;
72265 + return atomic_read(&port->count) + port->blocked_open;
72266 }
72267
72268 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
72269 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
72270 index dd976cf..e272742 100644
72271 --- a/include/linux/tty_driver.h
72272 +++ b/include/linux/tty_driver.h
72273 @@ -284,7 +284,7 @@ struct tty_operations {
72274 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
72275 #endif
72276 const struct file_operations *proc_fops;
72277 -};
72278 +} __do_const;
72279
72280 struct tty_driver {
72281 int magic; /* magic number for this structure */
72282 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
72283 index fb79dd8d..07d4773 100644
72284 --- a/include/linux/tty_ldisc.h
72285 +++ b/include/linux/tty_ldisc.h
72286 @@ -149,7 +149,7 @@ struct tty_ldisc_ops {
72287
72288 struct module *owner;
72289
72290 - int refcount;
72291 + atomic_t refcount;
72292 };
72293
72294 struct tty_ldisc {
72295 diff --git a/include/linux/types.h b/include/linux/types.h
72296 index 4d118ba..c3ee9bf 100644
72297 --- a/include/linux/types.h
72298 +++ b/include/linux/types.h
72299 @@ -176,10 +176,26 @@ typedef struct {
72300 int counter;
72301 } atomic_t;
72302
72303 +#ifdef CONFIG_PAX_REFCOUNT
72304 +typedef struct {
72305 + int counter;
72306 +} atomic_unchecked_t;
72307 +#else
72308 +typedef atomic_t atomic_unchecked_t;
72309 +#endif
72310 +
72311 #ifdef CONFIG_64BIT
72312 typedef struct {
72313 long counter;
72314 } atomic64_t;
72315 +
72316 +#ifdef CONFIG_PAX_REFCOUNT
72317 +typedef struct {
72318 + long counter;
72319 +} atomic64_unchecked_t;
72320 +#else
72321 +typedef atomic64_t atomic64_unchecked_t;
72322 +#endif
72323 #endif
72324
72325 struct list_head {
72326 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
72327 index 5ca0951..ab496a5 100644
72328 --- a/include/linux/uaccess.h
72329 +++ b/include/linux/uaccess.h
72330 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
72331 long ret; \
72332 mm_segment_t old_fs = get_fs(); \
72333 \
72334 - set_fs(KERNEL_DS); \
72335 pagefault_disable(); \
72336 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
72337 - pagefault_enable(); \
72338 + set_fs(KERNEL_DS); \
72339 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
72340 set_fs(old_fs); \
72341 + pagefault_enable(); \
72342 ret; \
72343 })
72344
72345 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
72346 index 8e522cbc..aa8572d 100644
72347 --- a/include/linux/uidgid.h
72348 +++ b/include/linux/uidgid.h
72349 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
72350
72351 #endif /* CONFIG_USER_NS */
72352
72353 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
72354 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
72355 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
72356 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
72357 +
72358 #endif /* _LINUX_UIDGID_H */
72359 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
72360 index 99c1b4d..562e6f3 100644
72361 --- a/include/linux/unaligned/access_ok.h
72362 +++ b/include/linux/unaligned/access_ok.h
72363 @@ -4,34 +4,34 @@
72364 #include <linux/kernel.h>
72365 #include <asm/byteorder.h>
72366
72367 -static inline u16 get_unaligned_le16(const void *p)
72368 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
72369 {
72370 - return le16_to_cpup((__le16 *)p);
72371 + return le16_to_cpup((const __le16 *)p);
72372 }
72373
72374 -static inline u32 get_unaligned_le32(const void *p)
72375 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
72376 {
72377 - return le32_to_cpup((__le32 *)p);
72378 + return le32_to_cpup((const __le32 *)p);
72379 }
72380
72381 -static inline u64 get_unaligned_le64(const void *p)
72382 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
72383 {
72384 - return le64_to_cpup((__le64 *)p);
72385 + return le64_to_cpup((const __le64 *)p);
72386 }
72387
72388 -static inline u16 get_unaligned_be16(const void *p)
72389 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
72390 {
72391 - return be16_to_cpup((__be16 *)p);
72392 + return be16_to_cpup((const __be16 *)p);
72393 }
72394
72395 -static inline u32 get_unaligned_be32(const void *p)
72396 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
72397 {
72398 - return be32_to_cpup((__be32 *)p);
72399 + return be32_to_cpup((const __be32 *)p);
72400 }
72401
72402 -static inline u64 get_unaligned_be64(const void *p)
72403 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
72404 {
72405 - return be64_to_cpup((__be64 *)p);
72406 + return be64_to_cpup((const __be64 *)p);
72407 }
72408
72409 static inline void put_unaligned_le16(u16 val, void *p)
72410 diff --git a/include/linux/usb.h b/include/linux/usb.h
72411 index 4d22d0f..8d0e8f8 100644
72412 --- a/include/linux/usb.h
72413 +++ b/include/linux/usb.h
72414 @@ -554,7 +554,7 @@ struct usb_device {
72415 int maxchild;
72416
72417 u32 quirks;
72418 - atomic_t urbnum;
72419 + atomic_unchecked_t urbnum;
72420
72421 unsigned long active_duration;
72422
72423 @@ -1604,7 +1604,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
72424
72425 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
72426 __u8 request, __u8 requesttype, __u16 value, __u16 index,
72427 - void *data, __u16 size, int timeout);
72428 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
72429 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
72430 void *data, int len, int *actual_length, int timeout);
72431 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
72432 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
72433 index c5d36c6..108f4f9 100644
72434 --- a/include/linux/usb/renesas_usbhs.h
72435 +++ b/include/linux/usb/renesas_usbhs.h
72436 @@ -39,7 +39,7 @@ enum {
72437 */
72438 struct renesas_usbhs_driver_callback {
72439 int (*notify_hotplug)(struct platform_device *pdev);
72440 -};
72441 +} __no_const;
72442
72443 /*
72444 * callback functions for platform
72445 diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
72446 index 5209cfe..b6b215f 100644
72447 --- a/include/linux/user_namespace.h
72448 +++ b/include/linux/user_namespace.h
72449 @@ -21,7 +21,7 @@ struct user_namespace {
72450 struct uid_gid_map uid_map;
72451 struct uid_gid_map gid_map;
72452 struct uid_gid_map projid_map;
72453 - struct kref kref;
72454 + atomic_t count;
72455 struct user_namespace *parent;
72456 kuid_t owner;
72457 kgid_t group;
72458 @@ -37,18 +37,18 @@ extern struct user_namespace init_user_ns;
72459 static inline struct user_namespace *get_user_ns(struct user_namespace *ns)
72460 {
72461 if (ns)
72462 - kref_get(&ns->kref);
72463 + atomic_inc(&ns->count);
72464 return ns;
72465 }
72466
72467 extern int create_user_ns(struct cred *new);
72468 extern int unshare_userns(unsigned long unshare_flags, struct cred **new_cred);
72469 -extern void free_user_ns(struct kref *kref);
72470 +extern void free_user_ns(struct user_namespace *ns);
72471
72472 static inline void put_user_ns(struct user_namespace *ns)
72473 {
72474 - if (ns)
72475 - kref_put(&ns->kref, free_user_ns);
72476 + if (ns && atomic_dec_and_test(&ns->count))
72477 + free_user_ns(ns);
72478 }
72479
72480 struct seq_operations;
72481 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
72482 index 6f8fbcf..8259001 100644
72483 --- a/include/linux/vermagic.h
72484 +++ b/include/linux/vermagic.h
72485 @@ -25,9 +25,35 @@
72486 #define MODULE_ARCH_VERMAGIC ""
72487 #endif
72488
72489 +#ifdef CONFIG_PAX_REFCOUNT
72490 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
72491 +#else
72492 +#define MODULE_PAX_REFCOUNT ""
72493 +#endif
72494 +
72495 +#ifdef CONSTIFY_PLUGIN
72496 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
72497 +#else
72498 +#define MODULE_CONSTIFY_PLUGIN ""
72499 +#endif
72500 +
72501 +#ifdef STACKLEAK_PLUGIN
72502 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
72503 +#else
72504 +#define MODULE_STACKLEAK_PLUGIN ""
72505 +#endif
72506 +
72507 +#ifdef CONFIG_GRKERNSEC
72508 +#define MODULE_GRSEC "GRSEC "
72509 +#else
72510 +#define MODULE_GRSEC ""
72511 +#endif
72512 +
72513 #define VERMAGIC_STRING \
72514 UTS_RELEASE " " \
72515 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
72516 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
72517 - MODULE_ARCH_VERMAGIC
72518 + MODULE_ARCH_VERMAGIC \
72519 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
72520 + MODULE_GRSEC
72521
72522 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
72523 index 6071e91..ca6a489 100644
72524 --- a/include/linux/vmalloc.h
72525 +++ b/include/linux/vmalloc.h
72526 @@ -14,6 +14,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
72527 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
72528 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
72529 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
72530 +
72531 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
72532 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
72533 +#endif
72534 +
72535 /* bits [20..32] reserved for arch specific ioremap internals */
72536
72537 /*
72538 @@ -62,7 +67,7 @@ extern void *vmalloc_32_user(unsigned long size);
72539 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
72540 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
72541 unsigned long start, unsigned long end, gfp_t gfp_mask,
72542 - pgprot_t prot, int node, const void *caller);
72543 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
72544 extern void vfree(const void *addr);
72545
72546 extern void *vmap(struct page **pages, unsigned int count,
72547 @@ -124,8 +129,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
72548 extern void free_vm_area(struct vm_struct *area);
72549
72550 /* for /dev/kmem */
72551 -extern long vread(char *buf, char *addr, unsigned long count);
72552 -extern long vwrite(char *buf, char *addr, unsigned long count);
72553 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
72554 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
72555
72556 /*
72557 * Internals. Dont't use..
72558 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
72559 index a13291f..af51fa3 100644
72560 --- a/include/linux/vmstat.h
72561 +++ b/include/linux/vmstat.h
72562 @@ -95,18 +95,18 @@ static inline void vm_events_fold_cpu(int cpu)
72563 /*
72564 * Zone based page accounting with per cpu differentials.
72565 */
72566 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72567 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72568
72569 static inline void zone_page_state_add(long x, struct zone *zone,
72570 enum zone_stat_item item)
72571 {
72572 - atomic_long_add(x, &zone->vm_stat[item]);
72573 - atomic_long_add(x, &vm_stat[item]);
72574 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
72575 + atomic_long_add_unchecked(x, &vm_stat[item]);
72576 }
72577
72578 static inline unsigned long global_page_state(enum zone_stat_item item)
72579 {
72580 - long x = atomic_long_read(&vm_stat[item]);
72581 + long x = atomic_long_read_unchecked(&vm_stat[item]);
72582 #ifdef CONFIG_SMP
72583 if (x < 0)
72584 x = 0;
72585 @@ -117,7 +117,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
72586 static inline unsigned long zone_page_state(struct zone *zone,
72587 enum zone_stat_item item)
72588 {
72589 - long x = atomic_long_read(&zone->vm_stat[item]);
72590 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72591 #ifdef CONFIG_SMP
72592 if (x < 0)
72593 x = 0;
72594 @@ -134,7 +134,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
72595 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
72596 enum zone_stat_item item)
72597 {
72598 - long x = atomic_long_read(&zone->vm_stat[item]);
72599 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72600
72601 #ifdef CONFIG_SMP
72602 int cpu;
72603 @@ -226,8 +226,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
72604
72605 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
72606 {
72607 - atomic_long_inc(&zone->vm_stat[item]);
72608 - atomic_long_inc(&vm_stat[item]);
72609 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
72610 + atomic_long_inc_unchecked(&vm_stat[item]);
72611 }
72612
72613 static inline void __inc_zone_page_state(struct page *page,
72614 @@ -238,8 +238,8 @@ static inline void __inc_zone_page_state(struct page *page,
72615
72616 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
72617 {
72618 - atomic_long_dec(&zone->vm_stat[item]);
72619 - atomic_long_dec(&vm_stat[item]);
72620 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
72621 + atomic_long_dec_unchecked(&vm_stat[item]);
72622 }
72623
72624 static inline void __dec_zone_page_state(struct page *page,
72625 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
72626 index fdbafc6..b7ffd47 100644
72627 --- a/include/linux/xattr.h
72628 +++ b/include/linux/xattr.h
72629 @@ -28,7 +28,7 @@ struct xattr_handler {
72630 size_t size, int handler_flags);
72631 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
72632 size_t size, int flags, int handler_flags);
72633 -};
72634 +} __do_const;
72635
72636 struct xattr {
72637 char *name;
72638 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
72639 index 9c5a6b4..09c9438 100644
72640 --- a/include/linux/zlib.h
72641 +++ b/include/linux/zlib.h
72642 @@ -31,6 +31,7 @@
72643 #define _ZLIB_H
72644
72645 #include <linux/zconf.h>
72646 +#include <linux/compiler.h>
72647
72648 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
72649 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
72650 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
72651
72652 /* basic functions */
72653
72654 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
72655 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
72656 /*
72657 Returns the number of bytes that needs to be allocated for a per-
72658 stream workspace with the specified parameters. A pointer to this
72659 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
72660 index 95d1c91..6798cca 100644
72661 --- a/include/media/v4l2-dev.h
72662 +++ b/include/media/v4l2-dev.h
72663 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
72664 int (*mmap) (struct file *, struct vm_area_struct *);
72665 int (*open) (struct file *);
72666 int (*release) (struct file *);
72667 -};
72668 +} __do_const;
72669
72670 /*
72671 * Newer version of video_device, handled by videodev2.c
72672 diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
72673 index 4118ad1..cb7e25f 100644
72674 --- a/include/media/v4l2-ioctl.h
72675 +++ b/include/media/v4l2-ioctl.h
72676 @@ -284,7 +284,6 @@ struct v4l2_ioctl_ops {
72677 bool valid_prio, int cmd, void *arg);
72678 };
72679
72680 -
72681 /* v4l debugging and diagnostics */
72682
72683 /* Debug bitmask flags to be used on V4L2 */
72684 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
72685 index adcbb20..62c2559 100644
72686 --- a/include/net/9p/transport.h
72687 +++ b/include/net/9p/transport.h
72688 @@ -57,7 +57,7 @@ struct p9_trans_module {
72689 int (*cancel) (struct p9_client *, struct p9_req_t *req);
72690 int (*zc_request)(struct p9_client *, struct p9_req_t *,
72691 char *, char *, int , int, int, int);
72692 -};
72693 +} __do_const;
72694
72695 void v9fs_register_trans(struct p9_trans_module *m);
72696 void v9fs_unregister_trans(struct p9_trans_module *m);
72697 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
72698 index 7588ef4..e62d35f 100644
72699 --- a/include/net/bluetooth/l2cap.h
72700 +++ b/include/net/bluetooth/l2cap.h
72701 @@ -552,7 +552,7 @@ struct l2cap_ops {
72702 void (*defer) (struct l2cap_chan *chan);
72703 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
72704 unsigned long len, int nb);
72705 -};
72706 +} __do_const;
72707
72708 struct l2cap_conn {
72709 struct hci_conn *hcon;
72710 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
72711 index 9e5425b..8136ffc 100644
72712 --- a/include/net/caif/cfctrl.h
72713 +++ b/include/net/caif/cfctrl.h
72714 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
72715 void (*radioset_rsp)(void);
72716 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
72717 struct cflayer *client_layer);
72718 -};
72719 +} __no_const;
72720
72721 /* Link Setup Parameters for CAIF-Links. */
72722 struct cfctrl_link_param {
72723 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
72724 struct cfctrl {
72725 struct cfsrvl serv;
72726 struct cfctrl_rsp res;
72727 - atomic_t req_seq_no;
72728 - atomic_t rsp_seq_no;
72729 + atomic_unchecked_t req_seq_no;
72730 + atomic_unchecked_t rsp_seq_no;
72731 struct list_head list;
72732 /* Protects from simultaneous access to first_req list */
72733 spinlock_t info_list_lock;
72734 diff --git a/include/net/flow.h b/include/net/flow.h
72735 index 628e11b..4c475df 100644
72736 --- a/include/net/flow.h
72737 +++ b/include/net/flow.h
72738 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
72739
72740 extern void flow_cache_flush(void);
72741 extern void flow_cache_flush_deferred(void);
72742 -extern atomic_t flow_cache_genid;
72743 +extern atomic_unchecked_t flow_cache_genid;
72744
72745 #endif
72746 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
72747 index bdfbe68..4402ebe 100644
72748 --- a/include/net/genetlink.h
72749 +++ b/include/net/genetlink.h
72750 @@ -118,7 +118,7 @@ struct genl_ops {
72751 struct netlink_callback *cb);
72752 int (*done)(struct netlink_callback *cb);
72753 struct list_head ops_list;
72754 -};
72755 +} __do_const;
72756
72757 extern int genl_register_family(struct genl_family *family);
72758 extern int genl_register_family_with_ops(struct genl_family *family,
72759 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
72760 index e5062c9..48a9a4b 100644
72761 --- a/include/net/gro_cells.h
72762 +++ b/include/net/gro_cells.h
72763 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
72764 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
72765
72766 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
72767 - atomic_long_inc(&dev->rx_dropped);
72768 + atomic_long_inc_unchecked(&dev->rx_dropped);
72769 kfree_skb(skb);
72770 return;
72771 }
72772 @@ -73,8 +73,8 @@ static inline int gro_cells_init(struct gro_cells *gcells, struct net_device *de
72773 int i;
72774
72775 gcells->gro_cells_mask = roundup_pow_of_two(netif_get_num_default_rss_queues()) - 1;
72776 - gcells->cells = kcalloc(sizeof(struct gro_cell),
72777 - gcells->gro_cells_mask + 1,
72778 + gcells->cells = kcalloc(gcells->gro_cells_mask + 1,
72779 + sizeof(struct gro_cell),
72780 GFP_KERNEL);
72781 if (!gcells->cells)
72782 return -ENOMEM;
72783 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
72784 index 1832927..ce39aea 100644
72785 --- a/include/net/inet_connection_sock.h
72786 +++ b/include/net/inet_connection_sock.h
72787 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
72788 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
72789 int (*bind_conflict)(const struct sock *sk,
72790 const struct inet_bind_bucket *tb, bool relax);
72791 -};
72792 +} __do_const;
72793
72794 /** inet_connection_sock - INET connection oriented sock
72795 *
72796 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
72797 index 53f464d..ba76aaa 100644
72798 --- a/include/net/inetpeer.h
72799 +++ b/include/net/inetpeer.h
72800 @@ -47,8 +47,8 @@ struct inet_peer {
72801 */
72802 union {
72803 struct {
72804 - atomic_t rid; /* Frag reception counter */
72805 - atomic_t ip_id_count; /* IP ID for the next packet */
72806 + atomic_unchecked_t rid; /* Frag reception counter */
72807 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
72808 };
72809 struct rcu_head rcu;
72810 struct inet_peer *gc_next;
72811 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
72812 more++;
72813 inet_peer_refcheck(p);
72814 do {
72815 - old = atomic_read(&p->ip_id_count);
72816 + old = atomic_read_unchecked(&p->ip_id_count);
72817 new = old + more;
72818 if (!new)
72819 new = 1;
72820 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
72821 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
72822 return new;
72823 }
72824
72825 diff --git a/include/net/ip.h b/include/net/ip.h
72826 index a68f838..74518ab 100644
72827 --- a/include/net/ip.h
72828 +++ b/include/net/ip.h
72829 @@ -202,7 +202,7 @@ extern struct local_ports {
72830 } sysctl_local_ports;
72831 extern void inet_get_local_port_range(int *low, int *high);
72832
72833 -extern unsigned long *sysctl_local_reserved_ports;
72834 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
72835 static inline int inet_is_reserved_local_port(int port)
72836 {
72837 return test_bit(port, sysctl_local_reserved_ports);
72838 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
72839 index e49db91..76a81de 100644
72840 --- a/include/net/ip_fib.h
72841 +++ b/include/net/ip_fib.h
72842 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
72843
72844 #define FIB_RES_SADDR(net, res) \
72845 ((FIB_RES_NH(res).nh_saddr_genid == \
72846 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
72847 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
72848 FIB_RES_NH(res).nh_saddr : \
72849 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
72850 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
72851 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
72852 index 68c69d5..bdab192 100644
72853 --- a/include/net/ip_vs.h
72854 +++ b/include/net/ip_vs.h
72855 @@ -599,7 +599,7 @@ struct ip_vs_conn {
72856 struct ip_vs_conn *control; /* Master control connection */
72857 atomic_t n_control; /* Number of controlled ones */
72858 struct ip_vs_dest *dest; /* real server */
72859 - atomic_t in_pkts; /* incoming packet counter */
72860 + atomic_unchecked_t in_pkts; /* incoming packet counter */
72861
72862 /* packet transmitter for different forwarding methods. If it
72863 mangles the packet, it must return NF_DROP or better NF_STOLEN,
72864 @@ -737,7 +737,7 @@ struct ip_vs_dest {
72865 __be16 port; /* port number of the server */
72866 union nf_inet_addr addr; /* IP address of the server */
72867 volatile unsigned int flags; /* dest status flags */
72868 - atomic_t conn_flags; /* flags to copy to conn */
72869 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
72870 atomic_t weight; /* server weight */
72871
72872 atomic_t refcnt; /* reference counter */
72873 @@ -980,11 +980,11 @@ struct netns_ipvs {
72874 /* ip_vs_lblc */
72875 int sysctl_lblc_expiration;
72876 struct ctl_table_header *lblc_ctl_header;
72877 - struct ctl_table *lblc_ctl_table;
72878 + ctl_table_no_const *lblc_ctl_table;
72879 /* ip_vs_lblcr */
72880 int sysctl_lblcr_expiration;
72881 struct ctl_table_header *lblcr_ctl_header;
72882 - struct ctl_table *lblcr_ctl_table;
72883 + ctl_table_no_const *lblcr_ctl_table;
72884 /* ip_vs_est */
72885 struct list_head est_list; /* estimator list */
72886 spinlock_t est_lock;
72887 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
72888 index 80ffde3..968b0f4 100644
72889 --- a/include/net/irda/ircomm_tty.h
72890 +++ b/include/net/irda/ircomm_tty.h
72891 @@ -35,6 +35,7 @@
72892 #include <linux/termios.h>
72893 #include <linux/timer.h>
72894 #include <linux/tty.h> /* struct tty_struct */
72895 +#include <asm/local.h>
72896
72897 #include <net/irda/irias_object.h>
72898 #include <net/irda/ircomm_core.h>
72899 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
72900 index cc7c197..9f2da2a 100644
72901 --- a/include/net/iucv/af_iucv.h
72902 +++ b/include/net/iucv/af_iucv.h
72903 @@ -141,7 +141,7 @@ struct iucv_sock {
72904 struct iucv_sock_list {
72905 struct hlist_head head;
72906 rwlock_t lock;
72907 - atomic_t autobind_name;
72908 + atomic_unchecked_t autobind_name;
72909 };
72910
72911 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
72912 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
72913 index df83f69..9b640b8 100644
72914 --- a/include/net/llc_c_ac.h
72915 +++ b/include/net/llc_c_ac.h
72916 @@ -87,7 +87,7 @@
72917 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
72918 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
72919
72920 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72921 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72922
72923 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
72924 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
72925 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
72926 index 6ca3113..f8026dd 100644
72927 --- a/include/net/llc_c_ev.h
72928 +++ b/include/net/llc_c_ev.h
72929 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
72930 return (struct llc_conn_state_ev *)skb->cb;
72931 }
72932
72933 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72934 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72935 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72936 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72937
72938 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
72939 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
72940 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
72941 index 0e79cfb..f46db31 100644
72942 --- a/include/net/llc_c_st.h
72943 +++ b/include/net/llc_c_st.h
72944 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
72945 u8 next_state;
72946 llc_conn_ev_qfyr_t *ev_qualifiers;
72947 llc_conn_action_t *ev_actions;
72948 -};
72949 +} __do_const;
72950
72951 struct llc_conn_state {
72952 u8 current_state;
72953 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
72954 index 37a3bbd..55a4241 100644
72955 --- a/include/net/llc_s_ac.h
72956 +++ b/include/net/llc_s_ac.h
72957 @@ -23,7 +23,7 @@
72958 #define SAP_ACT_TEST_IND 9
72959
72960 /* All action functions must look like this */
72961 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72962 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72963
72964 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
72965 struct sk_buff *skb);
72966 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
72967 index 567c681..cd73ac0 100644
72968 --- a/include/net/llc_s_st.h
72969 +++ b/include/net/llc_s_st.h
72970 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
72971 llc_sap_ev_t ev;
72972 u8 next_state;
72973 llc_sap_action_t *ev_actions;
72974 -};
72975 +} __do_const;
72976
72977 struct llc_sap_state {
72978 u8 curr_state;
72979 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
72980 index ee50c5e..1bc3b1a 100644
72981 --- a/include/net/mac80211.h
72982 +++ b/include/net/mac80211.h
72983 @@ -3996,7 +3996,7 @@ struct rate_control_ops {
72984 void (*add_sta_debugfs)(void *priv, void *priv_sta,
72985 struct dentry *dir);
72986 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
72987 -};
72988 +} __do_const;
72989
72990 static inline int rate_supported(struct ieee80211_sta *sta,
72991 enum ieee80211_band band,
72992 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
72993 index 0dab173..1b76af0 100644
72994 --- a/include/net/neighbour.h
72995 +++ b/include/net/neighbour.h
72996 @@ -123,7 +123,7 @@ struct neigh_ops {
72997 void (*error_report)(struct neighbour *, struct sk_buff *);
72998 int (*output)(struct neighbour *, struct sk_buff *);
72999 int (*connected_output)(struct neighbour *, struct sk_buff *);
73000 -};
73001 +} __do_const;
73002
73003 struct pneigh_entry {
73004 struct pneigh_entry *next;
73005 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
73006 index de644bc..dfbcc4c 100644
73007 --- a/include/net/net_namespace.h
73008 +++ b/include/net/net_namespace.h
73009 @@ -115,7 +115,7 @@ struct net {
73010 #endif
73011 struct netns_ipvs *ipvs;
73012 struct sock *diag_nlsk;
73013 - atomic_t rt_genid;
73014 + atomic_unchecked_t rt_genid;
73015 };
73016
73017 /*
73018 @@ -272,7 +272,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
73019 #define __net_init __init
73020 #define __net_exit __exit_refok
73021 #define __net_initdata __initdata
73022 +#ifdef CONSTIFY_PLUGIN
73023 #define __net_initconst __initconst
73024 +#else
73025 +#define __net_initconst __initdata
73026 +#endif
73027 #endif
73028
73029 struct pernet_operations {
73030 @@ -282,7 +286,7 @@ struct pernet_operations {
73031 void (*exit_batch)(struct list_head *net_exit_list);
73032 int *id;
73033 size_t size;
73034 -};
73035 +} __do_const;
73036
73037 /*
73038 * Use these carefully. If you implement a network device and it
73039 @@ -330,12 +334,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
73040
73041 static inline int rt_genid(struct net *net)
73042 {
73043 - return atomic_read(&net->rt_genid);
73044 + return atomic_read_unchecked(&net->rt_genid);
73045 }
73046
73047 static inline void rt_genid_bump(struct net *net)
73048 {
73049 - atomic_inc(&net->rt_genid);
73050 + atomic_inc_unchecked(&net->rt_genid);
73051 }
73052
73053 #endif /* __NET_NET_NAMESPACE_H */
73054 diff --git a/include/net/netdma.h b/include/net/netdma.h
73055 index 8ba8ce2..99b7fff 100644
73056 --- a/include/net/netdma.h
73057 +++ b/include/net/netdma.h
73058 @@ -24,7 +24,7 @@
73059 #include <linux/dmaengine.h>
73060 #include <linux/skbuff.h>
73061
73062 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
73063 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
73064 struct sk_buff *skb, int offset, struct iovec *to,
73065 size_t len, struct dma_pinned_list *pinned_list);
73066
73067 diff --git a/include/net/netlink.h b/include/net/netlink.h
73068 index 9690b0f..87aded7 100644
73069 --- a/include/net/netlink.h
73070 +++ b/include/net/netlink.h
73071 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
73072 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
73073 {
73074 if (mark)
73075 - skb_trim(skb, (unsigned char *) mark - skb->data);
73076 + skb_trim(skb, (const unsigned char *) mark - skb->data);
73077 }
73078
73079 /**
73080 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
73081 index 923cb20..deae816 100644
73082 --- a/include/net/netns/conntrack.h
73083 +++ b/include/net/netns/conntrack.h
73084 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
73085 struct nf_proto_net {
73086 #ifdef CONFIG_SYSCTL
73087 struct ctl_table_header *ctl_table_header;
73088 - struct ctl_table *ctl_table;
73089 + ctl_table_no_const *ctl_table;
73090 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
73091 struct ctl_table_header *ctl_compat_header;
73092 - struct ctl_table *ctl_compat_table;
73093 + ctl_table_no_const *ctl_compat_table;
73094 #endif
73095 #endif
73096 unsigned int users;
73097 @@ -58,7 +58,7 @@ struct nf_ip_net {
73098 struct nf_icmp_net icmpv6;
73099 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
73100 struct ctl_table_header *ctl_table_header;
73101 - struct ctl_table *ctl_table;
73102 + ctl_table_no_const *ctl_table;
73103 #endif
73104 };
73105
73106 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
73107 index 2ae2b83..dbdc85e 100644
73108 --- a/include/net/netns/ipv4.h
73109 +++ b/include/net/netns/ipv4.h
73110 @@ -64,7 +64,7 @@ struct netns_ipv4 {
73111 kgid_t sysctl_ping_group_range[2];
73112 long sysctl_tcp_mem[3];
73113
73114 - atomic_t dev_addr_genid;
73115 + atomic_unchecked_t dev_addr_genid;
73116
73117 #ifdef CONFIG_IP_MROUTE
73118 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
73119 diff --git a/include/net/protocol.h b/include/net/protocol.h
73120 index 047c047..b9dad15 100644
73121 --- a/include/net/protocol.h
73122 +++ b/include/net/protocol.h
73123 @@ -44,7 +44,7 @@ struct net_protocol {
73124 void (*err_handler)(struct sk_buff *skb, u32 info);
73125 unsigned int no_policy:1,
73126 netns_ok:1;
73127 -};
73128 +} __do_const;
73129
73130 #if IS_ENABLED(CONFIG_IPV6)
73131 struct inet6_protocol {
73132 @@ -57,7 +57,7 @@ struct inet6_protocol {
73133 u8 type, u8 code, int offset,
73134 __be32 info);
73135 unsigned int flags; /* INET6_PROTO_xxx */
73136 -};
73137 +} __do_const;
73138
73139 #define INET6_PROTO_NOPOLICY 0x1
73140 #define INET6_PROTO_FINAL 0x2
73141 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
73142 index 5a15fab..d799ea7 100644
73143 --- a/include/net/rtnetlink.h
73144 +++ b/include/net/rtnetlink.h
73145 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
73146 const struct net_device *dev);
73147 unsigned int (*get_num_tx_queues)(void);
73148 unsigned int (*get_num_rx_queues)(void);
73149 -};
73150 +} __do_const;
73151
73152 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
73153 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
73154 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
73155 index 7fdf298..197e9f7 100644
73156 --- a/include/net/sctp/sctp.h
73157 +++ b/include/net/sctp/sctp.h
73158 @@ -330,9 +330,9 @@ do { \
73159
73160 #else /* SCTP_DEBUG */
73161
73162 -#define SCTP_DEBUG_PRINTK(whatever...)
73163 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
73164 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
73165 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
73166 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
73167 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
73168 #define SCTP_ENABLE_DEBUG
73169 #define SCTP_DISABLE_DEBUG
73170 #define SCTP_ASSERT(expr, str, func)
73171 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
73172 index 2a82d13..62a31c2 100644
73173 --- a/include/net/sctp/sm.h
73174 +++ b/include/net/sctp/sm.h
73175 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
73176 typedef struct {
73177 sctp_state_fn_t *fn;
73178 const char *name;
73179 -} sctp_sm_table_entry_t;
73180 +} __do_const sctp_sm_table_entry_t;
73181
73182 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
73183 * currently in use.
73184 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
73185 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
73186
73187 /* Extern declarations for major data structures. */
73188 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73189 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73190
73191
73192 /* Get the size of a DATA chunk payload. */
73193 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
73194 index fdeb85a..1329d95 100644
73195 --- a/include/net/sctp/structs.h
73196 +++ b/include/net/sctp/structs.h
73197 @@ -517,7 +517,7 @@ struct sctp_pf {
73198 struct sctp_association *asoc);
73199 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
73200 struct sctp_af *af;
73201 -};
73202 +} __do_const;
73203
73204
73205 /* Structure to track chunk fragments that have been acked, but peer
73206 diff --git a/include/net/sock.h b/include/net/sock.h
73207 index 25afaa0..8bb0070 100644
73208 --- a/include/net/sock.h
73209 +++ b/include/net/sock.h
73210 @@ -322,7 +322,7 @@ struct sock {
73211 #ifdef CONFIG_RPS
73212 __u32 sk_rxhash;
73213 #endif
73214 - atomic_t sk_drops;
73215 + atomic_unchecked_t sk_drops;
73216 int sk_rcvbuf;
73217
73218 struct sk_filter __rcu *sk_filter;
73219 @@ -1781,7 +1781,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
73220 }
73221
73222 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
73223 - char __user *from, char *to,
73224 + char __user *from, unsigned char *to,
73225 int copy, int offset)
73226 {
73227 if (skb->ip_summed == CHECKSUM_NONE) {
73228 @@ -2040,7 +2040,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
73229 }
73230 }
73231
73232 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73233 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73234
73235 /**
73236 * sk_page_frag - return an appropriate page_frag
73237 diff --git a/include/net/tcp.h b/include/net/tcp.h
73238 index aed42c7..43890c6 100644
73239 --- a/include/net/tcp.h
73240 +++ b/include/net/tcp.h
73241 @@ -530,7 +530,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
73242 extern void tcp_xmit_retransmit_queue(struct sock *);
73243 extern void tcp_simple_retransmit(struct sock *);
73244 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
73245 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73246 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73247
73248 extern void tcp_send_probe0(struct sock *);
73249 extern void tcp_send_partial(struct sock *);
73250 @@ -701,8 +701,8 @@ struct tcp_skb_cb {
73251 struct inet6_skb_parm h6;
73252 #endif
73253 } header; /* For incoming frames */
73254 - __u32 seq; /* Starting sequence number */
73255 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
73256 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
73257 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
73258 __u32 when; /* used to compute rtt's */
73259 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
73260
73261 @@ -716,7 +716,7 @@ struct tcp_skb_cb {
73262
73263 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
73264 /* 1 byte hole */
73265 - __u32 ack_seq; /* Sequence number ACK'd */
73266 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
73267 };
73268
73269 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
73270 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
73271 index 63445ed..d6fc34f 100644
73272 --- a/include/net/xfrm.h
73273 +++ b/include/net/xfrm.h
73274 @@ -304,7 +304,7 @@ struct xfrm_policy_afinfo {
73275 struct net_device *dev,
73276 const struct flowi *fl);
73277 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
73278 -};
73279 +} __do_const;
73280
73281 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
73282 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
73283 @@ -340,7 +340,7 @@ struct xfrm_state_afinfo {
73284 struct sk_buff *skb);
73285 int (*transport_finish)(struct sk_buff *skb,
73286 int async);
73287 -};
73288 +} __do_const;
73289
73290 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
73291 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
73292 @@ -423,7 +423,7 @@ struct xfrm_mode {
73293 struct module *owner;
73294 unsigned int encap;
73295 int flags;
73296 -};
73297 +} __do_const;
73298
73299 /* Flags for xfrm_mode. */
73300 enum {
73301 @@ -514,7 +514,7 @@ struct xfrm_policy {
73302 struct timer_list timer;
73303
73304 struct flow_cache_object flo;
73305 - atomic_t genid;
73306 + atomic_unchecked_t genid;
73307 u32 priority;
73308 u32 index;
73309 struct xfrm_mark mark;
73310 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
73311 index 1a046b1..ee0bef0 100644
73312 --- a/include/rdma/iw_cm.h
73313 +++ b/include/rdma/iw_cm.h
73314 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
73315 int backlog);
73316
73317 int (*destroy_listen)(struct iw_cm_id *cm_id);
73318 -};
73319 +} __no_const;
73320
73321 /**
73322 * iw_create_cm_id - Create an IW CM identifier.
73323 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
73324 index 399162b..b337f1a 100644
73325 --- a/include/scsi/libfc.h
73326 +++ b/include/scsi/libfc.h
73327 @@ -762,6 +762,7 @@ struct libfc_function_template {
73328 */
73329 void (*disc_stop_final) (struct fc_lport *);
73330 };
73331 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
73332
73333 /**
73334 * struct fc_disc - Discovery context
73335 @@ -866,7 +867,7 @@ struct fc_lport {
73336 struct fc_vport *vport;
73337
73338 /* Operational Information */
73339 - struct libfc_function_template tt;
73340 + libfc_function_template_no_const tt;
73341 u8 link_up;
73342 u8 qfull;
73343 enum fc_lport_state state;
73344 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
73345 index e65c62e..aa2e5a2 100644
73346 --- a/include/scsi/scsi_device.h
73347 +++ b/include/scsi/scsi_device.h
73348 @@ -170,9 +170,9 @@ struct scsi_device {
73349 unsigned int max_device_blocked; /* what device_blocked counts down from */
73350 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
73351
73352 - atomic_t iorequest_cnt;
73353 - atomic_t iodone_cnt;
73354 - atomic_t ioerr_cnt;
73355 + atomic_unchecked_t iorequest_cnt;
73356 + atomic_unchecked_t iodone_cnt;
73357 + atomic_unchecked_t ioerr_cnt;
73358
73359 struct device sdev_gendev,
73360 sdev_dev;
73361 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
73362 index b797e8f..8e2c3aa 100644
73363 --- a/include/scsi/scsi_transport_fc.h
73364 +++ b/include/scsi/scsi_transport_fc.h
73365 @@ -751,7 +751,8 @@ struct fc_function_template {
73366 unsigned long show_host_system_hostname:1;
73367
73368 unsigned long disable_target_scan:1;
73369 -};
73370 +} __do_const;
73371 +typedef struct fc_function_template __no_const fc_function_template_no_const;
73372
73373
73374 /**
73375 diff --git a/include/sound/soc.h b/include/sound/soc.h
73376 index bc56738..a4be132 100644
73377 --- a/include/sound/soc.h
73378 +++ b/include/sound/soc.h
73379 @@ -771,7 +771,7 @@ struct snd_soc_codec_driver {
73380 /* probe ordering - for components with runtime dependencies */
73381 int probe_order;
73382 int remove_order;
73383 -};
73384 +} __do_const;
73385
73386 /* SoC platform interface */
73387 struct snd_soc_platform_driver {
73388 @@ -817,7 +817,7 @@ struct snd_soc_platform_driver {
73389 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
73390 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
73391 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
73392 -};
73393 +} __do_const;
73394
73395 struct snd_soc_platform {
73396 const char *name;
73397 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
73398 index 663e34a..91b306a 100644
73399 --- a/include/target/target_core_base.h
73400 +++ b/include/target/target_core_base.h
73401 @@ -654,7 +654,7 @@ struct se_device {
73402 spinlock_t stats_lock;
73403 /* Active commands on this virtual SE device */
73404 atomic_t simple_cmds;
73405 - atomic_t dev_ordered_id;
73406 + atomic_unchecked_t dev_ordered_id;
73407 atomic_t dev_ordered_sync;
73408 atomic_t dev_qf_count;
73409 int export_count;
73410 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
73411 new file mode 100644
73412 index 0000000..fb634b7
73413 --- /dev/null
73414 +++ b/include/trace/events/fs.h
73415 @@ -0,0 +1,53 @@
73416 +#undef TRACE_SYSTEM
73417 +#define TRACE_SYSTEM fs
73418 +
73419 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
73420 +#define _TRACE_FS_H
73421 +
73422 +#include <linux/fs.h>
73423 +#include <linux/tracepoint.h>
73424 +
73425 +TRACE_EVENT(do_sys_open,
73426 +
73427 + TP_PROTO(const char *filename, int flags, int mode),
73428 +
73429 + TP_ARGS(filename, flags, mode),
73430 +
73431 + TP_STRUCT__entry(
73432 + __string( filename, filename )
73433 + __field( int, flags )
73434 + __field( int, mode )
73435 + ),
73436 +
73437 + TP_fast_assign(
73438 + __assign_str(filename, filename);
73439 + __entry->flags = flags;
73440 + __entry->mode = mode;
73441 + ),
73442 +
73443 + TP_printk("\"%s\" %x %o",
73444 + __get_str(filename), __entry->flags, __entry->mode)
73445 +);
73446 +
73447 +TRACE_EVENT(open_exec,
73448 +
73449 + TP_PROTO(const char *filename),
73450 +
73451 + TP_ARGS(filename),
73452 +
73453 + TP_STRUCT__entry(
73454 + __string( filename, filename )
73455 + ),
73456 +
73457 + TP_fast_assign(
73458 + __assign_str(filename, filename);
73459 + ),
73460 +
73461 + TP_printk("\"%s\"",
73462 + __get_str(filename))
73463 +);
73464 +
73465 +#endif /* _TRACE_FS_H */
73466 +
73467 +/* This part must be outside protection */
73468 +#include <trace/define_trace.h>
73469 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
73470 index 1c09820..7f5ec79 100644
73471 --- a/include/trace/events/irq.h
73472 +++ b/include/trace/events/irq.h
73473 @@ -36,7 +36,7 @@ struct softirq_action;
73474 */
73475 TRACE_EVENT(irq_handler_entry,
73476
73477 - TP_PROTO(int irq, struct irqaction *action),
73478 + TP_PROTO(int irq, const struct irqaction *action),
73479
73480 TP_ARGS(irq, action),
73481
73482 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
73483 */
73484 TRACE_EVENT(irq_handler_exit,
73485
73486 - TP_PROTO(int irq, struct irqaction *action, int ret),
73487 + TP_PROTO(int irq, const struct irqaction *action, int ret),
73488
73489 TP_ARGS(irq, action, ret),
73490
73491 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
73492 index 7caf44c..23c6f27 100644
73493 --- a/include/uapi/linux/a.out.h
73494 +++ b/include/uapi/linux/a.out.h
73495 @@ -39,6 +39,14 @@ enum machine_type {
73496 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
73497 };
73498
73499 +/* Constants for the N_FLAGS field */
73500 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73501 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
73502 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
73503 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
73504 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73505 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73506 +
73507 #if !defined (N_MAGIC)
73508 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
73509 #endif
73510 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
73511 index d876736..ccce5c0 100644
73512 --- a/include/uapi/linux/byteorder/little_endian.h
73513 +++ b/include/uapi/linux/byteorder/little_endian.h
73514 @@ -42,51 +42,51 @@
73515
73516 static inline __le64 __cpu_to_le64p(const __u64 *p)
73517 {
73518 - return (__force __le64)*p;
73519 + return (__force const __le64)*p;
73520 }
73521 -static inline __u64 __le64_to_cpup(const __le64 *p)
73522 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
73523 {
73524 - return (__force __u64)*p;
73525 + return (__force const __u64)*p;
73526 }
73527 static inline __le32 __cpu_to_le32p(const __u32 *p)
73528 {
73529 - return (__force __le32)*p;
73530 + return (__force const __le32)*p;
73531 }
73532 static inline __u32 __le32_to_cpup(const __le32 *p)
73533 {
73534 - return (__force __u32)*p;
73535 + return (__force const __u32)*p;
73536 }
73537 static inline __le16 __cpu_to_le16p(const __u16 *p)
73538 {
73539 - return (__force __le16)*p;
73540 + return (__force const __le16)*p;
73541 }
73542 static inline __u16 __le16_to_cpup(const __le16 *p)
73543 {
73544 - return (__force __u16)*p;
73545 + return (__force const __u16)*p;
73546 }
73547 static inline __be64 __cpu_to_be64p(const __u64 *p)
73548 {
73549 - return (__force __be64)__swab64p(p);
73550 + return (__force const __be64)__swab64p(p);
73551 }
73552 static inline __u64 __be64_to_cpup(const __be64 *p)
73553 {
73554 - return __swab64p((__u64 *)p);
73555 + return __swab64p((const __u64 *)p);
73556 }
73557 static inline __be32 __cpu_to_be32p(const __u32 *p)
73558 {
73559 - return (__force __be32)__swab32p(p);
73560 + return (__force const __be32)__swab32p(p);
73561 }
73562 -static inline __u32 __be32_to_cpup(const __be32 *p)
73563 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
73564 {
73565 - return __swab32p((__u32 *)p);
73566 + return __swab32p((const __u32 *)p);
73567 }
73568 static inline __be16 __cpu_to_be16p(const __u16 *p)
73569 {
73570 - return (__force __be16)__swab16p(p);
73571 + return (__force const __be16)__swab16p(p);
73572 }
73573 static inline __u16 __be16_to_cpup(const __be16 *p)
73574 {
73575 - return __swab16p((__u16 *)p);
73576 + return __swab16p((const __u16 *)p);
73577 }
73578 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
73579 #define __le64_to_cpus(x) do { (void)(x); } while (0)
73580 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
73581 index 126a817..d522bd1 100644
73582 --- a/include/uapi/linux/elf.h
73583 +++ b/include/uapi/linux/elf.h
73584 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
73585 #define PT_GNU_EH_FRAME 0x6474e550
73586
73587 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
73588 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
73589 +
73590 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
73591 +
73592 +/* Constants for the e_flags field */
73593 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73594 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
73595 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
73596 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
73597 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73598 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73599
73600 /*
73601 * Extended Numbering
73602 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
73603 #define DT_DEBUG 21
73604 #define DT_TEXTREL 22
73605 #define DT_JMPREL 23
73606 +#define DT_FLAGS 30
73607 + #define DF_TEXTREL 0x00000004
73608 #define DT_ENCODING 32
73609 #define OLD_DT_LOOS 0x60000000
73610 #define DT_LOOS 0x6000000d
73611 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
73612 #define PF_W 0x2
73613 #define PF_X 0x1
73614
73615 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
73616 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
73617 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
73618 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
73619 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
73620 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
73621 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
73622 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
73623 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
73624 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
73625 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
73626 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
73627 +
73628 typedef struct elf32_phdr{
73629 Elf32_Word p_type;
73630 Elf32_Off p_offset;
73631 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
73632 #define EI_OSABI 7
73633 #define EI_PAD 8
73634
73635 +#define EI_PAX 14
73636 +
73637 #define ELFMAG0 0x7f /* EI_MAG */
73638 #define ELFMAG1 'E'
73639 #define ELFMAG2 'L'
73640 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
73641 index aa169c4..6a2771d 100644
73642 --- a/include/uapi/linux/personality.h
73643 +++ b/include/uapi/linux/personality.h
73644 @@ -30,6 +30,7 @@ enum {
73645 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
73646 ADDR_NO_RANDOMIZE | \
73647 ADDR_COMPAT_LAYOUT | \
73648 + ADDR_LIMIT_3GB | \
73649 MMAP_PAGE_ZERO)
73650
73651 /*
73652 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
73653 index 7530e74..e714828 100644
73654 --- a/include/uapi/linux/screen_info.h
73655 +++ b/include/uapi/linux/screen_info.h
73656 @@ -43,7 +43,8 @@ struct screen_info {
73657 __u16 pages; /* 0x32 */
73658 __u16 vesa_attributes; /* 0x34 */
73659 __u32 capabilities; /* 0x36 */
73660 - __u8 _reserved[6]; /* 0x3a */
73661 + __u16 vesapm_size; /* 0x3a */
73662 + __u8 _reserved[4]; /* 0x3c */
73663 } __attribute__((packed));
73664
73665 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
73666 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
73667 index 0e011eb..82681b1 100644
73668 --- a/include/uapi/linux/swab.h
73669 +++ b/include/uapi/linux/swab.h
73670 @@ -43,7 +43,7 @@
73671 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
73672 */
73673
73674 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
73675 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
73676 {
73677 #ifdef __HAVE_BUILTIN_BSWAP16__
73678 return __builtin_bswap16(val);
73679 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
73680 #endif
73681 }
73682
73683 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
73684 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
73685 {
73686 #ifdef __HAVE_BUILTIN_BSWAP32__
73687 return __builtin_bswap32(val);
73688 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
73689 #endif
73690 }
73691
73692 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
73693 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
73694 {
73695 #ifdef __HAVE_BUILTIN_BSWAP64__
73696 return __builtin_bswap64(val);
73697 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
73698 index 6d67213..8dab561 100644
73699 --- a/include/uapi/linux/sysctl.h
73700 +++ b/include/uapi/linux/sysctl.h
73701 @@ -155,7 +155,11 @@ enum
73702 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
73703 };
73704
73705 -
73706 +#ifdef CONFIG_PAX_SOFTMODE
73707 +enum {
73708 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
73709 +};
73710 +#endif
73711
73712 /* CTL_VM names: */
73713 enum
73714 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
73715 index 26607bd..588b65f 100644
73716 --- a/include/uapi/linux/xattr.h
73717 +++ b/include/uapi/linux/xattr.h
73718 @@ -60,5 +60,9 @@
73719 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
73720 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
73721
73722 +/* User namespace */
73723 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
73724 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
73725 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
73726
73727 #endif /* _UAPI_LINUX_XATTR_H */
73728 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
73729 index f9466fa..f4e2b81 100644
73730 --- a/include/video/udlfb.h
73731 +++ b/include/video/udlfb.h
73732 @@ -53,10 +53,10 @@ struct dlfb_data {
73733 u32 pseudo_palette[256];
73734 int blank_mode; /*one of FB_BLANK_ */
73735 /* blit-only rendering path metrics, exposed through sysfs */
73736 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73737 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
73738 - atomic_t bytes_sent; /* to usb, after compression including overhead */
73739 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
73740 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73741 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
73742 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
73743 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
73744 };
73745
73746 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
73747 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
73748 index 0993a22..32ba2fe 100644
73749 --- a/include/video/uvesafb.h
73750 +++ b/include/video/uvesafb.h
73751 @@ -177,6 +177,7 @@ struct uvesafb_par {
73752 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
73753 u8 pmi_setpal; /* PMI for palette changes */
73754 u16 *pmi_base; /* protected mode interface location */
73755 + u8 *pmi_code; /* protected mode code location */
73756 void *pmi_start;
73757 void *pmi_pal;
73758 u8 *vbe_state_orig; /*
73759 diff --git a/init/Kconfig b/init/Kconfig
73760 index be8b7f5..1eeca9b 100644
73761 --- a/init/Kconfig
73762 +++ b/init/Kconfig
73763 @@ -990,6 +990,7 @@ endif # CGROUPS
73764
73765 config CHECKPOINT_RESTORE
73766 bool "Checkpoint/restore support" if EXPERT
73767 + depends on !GRKERNSEC
73768 default n
73769 help
73770 Enables additional kernel features in a sake of checkpoint/restore.
73771 @@ -1468,7 +1469,7 @@ config SLUB_DEBUG
73772
73773 config COMPAT_BRK
73774 bool "Disable heap randomization"
73775 - default y
73776 + default n
73777 help
73778 Randomizing heap placement makes heap exploits harder, but it
73779 also breaks ancient binaries (including anything libc5 based).
73780 @@ -1711,7 +1712,7 @@ config INIT_ALL_POSSIBLE
73781 config STOP_MACHINE
73782 bool
73783 default y
73784 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
73785 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
73786 help
73787 Need stop_machine() primitive.
73788
73789 diff --git a/init/Makefile b/init/Makefile
73790 index 7bc47ee..6da2dc7 100644
73791 --- a/init/Makefile
73792 +++ b/init/Makefile
73793 @@ -2,6 +2,9 @@
73794 # Makefile for the linux kernel.
73795 #
73796
73797 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
73798 +asflags-y := $(GCC_PLUGINS_AFLAGS)
73799 +
73800 obj-y := main.o version.o mounts.o
73801 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
73802 obj-y += noinitramfs.o
73803 diff --git a/init/do_mounts.c b/init/do_mounts.c
73804 index 1d1b634..a1c810f 100644
73805 --- a/init/do_mounts.c
73806 +++ b/init/do_mounts.c
73807 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
73808 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
73809 {
73810 struct super_block *s;
73811 - int err = sys_mount(name, "/root", fs, flags, data);
73812 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
73813 if (err)
73814 return err;
73815
73816 - sys_chdir("/root");
73817 + sys_chdir((const char __force_user *)"/root");
73818 s = current->fs->pwd.dentry->d_sb;
73819 ROOT_DEV = s->s_dev;
73820 printk(KERN_INFO
73821 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
73822 va_start(args, fmt);
73823 vsprintf(buf, fmt, args);
73824 va_end(args);
73825 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
73826 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
73827 if (fd >= 0) {
73828 sys_ioctl(fd, FDEJECT, 0);
73829 sys_close(fd);
73830 }
73831 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
73832 - fd = sys_open("/dev/console", O_RDWR, 0);
73833 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
73834 if (fd >= 0) {
73835 sys_ioctl(fd, TCGETS, (long)&termios);
73836 termios.c_lflag &= ~ICANON;
73837 sys_ioctl(fd, TCSETSF, (long)&termios);
73838 - sys_read(fd, &c, 1);
73839 + sys_read(fd, (char __user *)&c, 1);
73840 termios.c_lflag |= ICANON;
73841 sys_ioctl(fd, TCSETSF, (long)&termios);
73842 sys_close(fd);
73843 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
73844 mount_root();
73845 out:
73846 devtmpfs_mount("dev");
73847 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
73848 - sys_chroot(".");
73849 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
73850 + sys_chroot((const char __force_user *)".");
73851 }
73852 diff --git a/init/do_mounts.h b/init/do_mounts.h
73853 index f5b978a..69dbfe8 100644
73854 --- a/init/do_mounts.h
73855 +++ b/init/do_mounts.h
73856 @@ -15,15 +15,15 @@ extern int root_mountflags;
73857
73858 static inline int create_dev(char *name, dev_t dev)
73859 {
73860 - sys_unlink(name);
73861 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
73862 + sys_unlink((char __force_user *)name);
73863 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
73864 }
73865
73866 #if BITS_PER_LONG == 32
73867 static inline u32 bstat(char *name)
73868 {
73869 struct stat64 stat;
73870 - if (sys_stat64(name, &stat) != 0)
73871 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
73872 return 0;
73873 if (!S_ISBLK(stat.st_mode))
73874 return 0;
73875 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
73876 static inline u32 bstat(char *name)
73877 {
73878 struct stat stat;
73879 - if (sys_newstat(name, &stat) != 0)
73880 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
73881 return 0;
73882 if (!S_ISBLK(stat.st_mode))
73883 return 0;
73884 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
73885 index f9acf71..1e19144 100644
73886 --- a/init/do_mounts_initrd.c
73887 +++ b/init/do_mounts_initrd.c
73888 @@ -58,8 +58,8 @@ static void __init handle_initrd(void)
73889 create_dev("/dev/root.old", Root_RAM0);
73890 /* mount initrd on rootfs' /root */
73891 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
73892 - sys_mkdir("/old", 0700);
73893 - sys_chdir("/old");
73894 + sys_mkdir((const char __force_user *)"/old", 0700);
73895 + sys_chdir((const char __force_user *)"/old");
73896
73897 /*
73898 * In case that a resume from disk is carried out by linuxrc or one of
73899 @@ -73,31 +73,31 @@ static void __init handle_initrd(void)
73900 current->flags &= ~PF_FREEZER_SKIP;
73901
73902 /* move initrd to rootfs' /old */
73903 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
73904 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
73905 /* switch root and cwd back to / of rootfs */
73906 - sys_chroot("..");
73907 + sys_chroot((const char __force_user *)"..");
73908
73909 if (new_decode_dev(real_root_dev) == Root_RAM0) {
73910 - sys_chdir("/old");
73911 + sys_chdir((const char __force_user *)"/old");
73912 return;
73913 }
73914
73915 - sys_chdir("/");
73916 + sys_chdir((const char __force_user *)"/");
73917 ROOT_DEV = new_decode_dev(real_root_dev);
73918 mount_root();
73919
73920 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
73921 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
73922 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
73923 if (!error)
73924 printk("okay\n");
73925 else {
73926 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
73927 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
73928 if (error == -ENOENT)
73929 printk("/initrd does not exist. Ignored.\n");
73930 else
73931 printk("failed\n");
73932 printk(KERN_NOTICE "Unmounting old root\n");
73933 - sys_umount("/old", MNT_DETACH);
73934 + sys_umount((char __force_user *)"/old", MNT_DETACH);
73935 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
73936 if (fd < 0) {
73937 error = fd;
73938 @@ -120,11 +120,11 @@ int __init initrd_load(void)
73939 * mounted in the normal path.
73940 */
73941 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
73942 - sys_unlink("/initrd.image");
73943 + sys_unlink((const char __force_user *)"/initrd.image");
73944 handle_initrd();
73945 return 1;
73946 }
73947 }
73948 - sys_unlink("/initrd.image");
73949 + sys_unlink((const char __force_user *)"/initrd.image");
73950 return 0;
73951 }
73952 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
73953 index 8cb6db5..d729f50 100644
73954 --- a/init/do_mounts_md.c
73955 +++ b/init/do_mounts_md.c
73956 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
73957 partitioned ? "_d" : "", minor,
73958 md_setup_args[ent].device_names);
73959
73960 - fd = sys_open(name, 0, 0);
73961 + fd = sys_open((char __force_user *)name, 0, 0);
73962 if (fd < 0) {
73963 printk(KERN_ERR "md: open failed - cannot start "
73964 "array %s\n", name);
73965 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
73966 * array without it
73967 */
73968 sys_close(fd);
73969 - fd = sys_open(name, 0, 0);
73970 + fd = sys_open((char __force_user *)name, 0, 0);
73971 sys_ioctl(fd, BLKRRPART, 0);
73972 }
73973 sys_close(fd);
73974 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
73975
73976 wait_for_device_probe();
73977
73978 - fd = sys_open("/dev/md0", 0, 0);
73979 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
73980 if (fd >= 0) {
73981 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
73982 sys_close(fd);
73983 diff --git a/init/init_task.c b/init/init_task.c
73984 index 8b2f399..f0797c9 100644
73985 --- a/init/init_task.c
73986 +++ b/init/init_task.c
73987 @@ -20,5 +20,9 @@ EXPORT_SYMBOL(init_task);
73988 * Initial thread structure. Alignment of this is handled by a special
73989 * linker map entry.
73990 */
73991 +#ifdef CONFIG_X86
73992 +union thread_union init_thread_union __init_task_data;
73993 +#else
73994 union thread_union init_thread_union __init_task_data =
73995 { INIT_THREAD_INFO(init_task) };
73996 +#endif
73997 diff --git a/init/initramfs.c b/init/initramfs.c
73998 index 84c6bf1..8899338 100644
73999 --- a/init/initramfs.c
74000 +++ b/init/initramfs.c
74001 @@ -84,7 +84,7 @@ static void __init free_hash(void)
74002 }
74003 }
74004
74005 -static long __init do_utime(char *filename, time_t mtime)
74006 +static long __init do_utime(char __force_user *filename, time_t mtime)
74007 {
74008 struct timespec t[2];
74009
74010 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
74011 struct dir_entry *de, *tmp;
74012 list_for_each_entry_safe(de, tmp, &dir_list, list) {
74013 list_del(&de->list);
74014 - do_utime(de->name, de->mtime);
74015 + do_utime((char __force_user *)de->name, de->mtime);
74016 kfree(de->name);
74017 kfree(de);
74018 }
74019 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
74020 if (nlink >= 2) {
74021 char *old = find_link(major, minor, ino, mode, collected);
74022 if (old)
74023 - return (sys_link(old, collected) < 0) ? -1 : 1;
74024 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
74025 }
74026 return 0;
74027 }
74028 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
74029 {
74030 struct stat st;
74031
74032 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
74033 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
74034 if (S_ISDIR(st.st_mode))
74035 - sys_rmdir(path);
74036 + sys_rmdir((char __force_user *)path);
74037 else
74038 - sys_unlink(path);
74039 + sys_unlink((char __force_user *)path);
74040 }
74041 }
74042
74043 @@ -315,7 +315,7 @@ static int __init do_name(void)
74044 int openflags = O_WRONLY|O_CREAT;
74045 if (ml != 1)
74046 openflags |= O_TRUNC;
74047 - wfd = sys_open(collected, openflags, mode);
74048 + wfd = sys_open((char __force_user *)collected, openflags, mode);
74049
74050 if (wfd >= 0) {
74051 sys_fchown(wfd, uid, gid);
74052 @@ -327,17 +327,17 @@ static int __init do_name(void)
74053 }
74054 }
74055 } else if (S_ISDIR(mode)) {
74056 - sys_mkdir(collected, mode);
74057 - sys_chown(collected, uid, gid);
74058 - sys_chmod(collected, mode);
74059 + sys_mkdir((char __force_user *)collected, mode);
74060 + sys_chown((char __force_user *)collected, uid, gid);
74061 + sys_chmod((char __force_user *)collected, mode);
74062 dir_add(collected, mtime);
74063 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
74064 S_ISFIFO(mode) || S_ISSOCK(mode)) {
74065 if (maybe_link() == 0) {
74066 - sys_mknod(collected, mode, rdev);
74067 - sys_chown(collected, uid, gid);
74068 - sys_chmod(collected, mode);
74069 - do_utime(collected, mtime);
74070 + sys_mknod((char __force_user *)collected, mode, rdev);
74071 + sys_chown((char __force_user *)collected, uid, gid);
74072 + sys_chmod((char __force_user *)collected, mode);
74073 + do_utime((char __force_user *)collected, mtime);
74074 }
74075 }
74076 return 0;
74077 @@ -346,15 +346,15 @@ static int __init do_name(void)
74078 static int __init do_copy(void)
74079 {
74080 if (count >= body_len) {
74081 - sys_write(wfd, victim, body_len);
74082 + sys_write(wfd, (char __force_user *)victim, body_len);
74083 sys_close(wfd);
74084 - do_utime(vcollected, mtime);
74085 + do_utime((char __force_user *)vcollected, mtime);
74086 kfree(vcollected);
74087 eat(body_len);
74088 state = SkipIt;
74089 return 0;
74090 } else {
74091 - sys_write(wfd, victim, count);
74092 + sys_write(wfd, (char __force_user *)victim, count);
74093 body_len -= count;
74094 eat(count);
74095 return 1;
74096 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
74097 {
74098 collected[N_ALIGN(name_len) + body_len] = '\0';
74099 clean_path(collected, 0);
74100 - sys_symlink(collected + N_ALIGN(name_len), collected);
74101 - sys_lchown(collected, uid, gid);
74102 - do_utime(collected, mtime);
74103 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
74104 + sys_lchown((char __force_user *)collected, uid, gid);
74105 + do_utime((char __force_user *)collected, mtime);
74106 state = SkipIt;
74107 next_state = Reset;
74108 return 0;
74109 diff --git a/init/main.c b/init/main.c
74110 index cee4b5c..360e10a 100644
74111 --- a/init/main.c
74112 +++ b/init/main.c
74113 @@ -96,6 +96,8 @@ static inline void mark_rodata_ro(void) { }
74114 extern void tc_init(void);
74115 #endif
74116
74117 +extern void grsecurity_init(void);
74118 +
74119 /*
74120 * Debug helper: via this flag we know that we are in 'early bootup code'
74121 * where only the boot processor is running with IRQ disabled. This means
74122 @@ -149,6 +151,61 @@ static int __init set_reset_devices(char *str)
74123
74124 __setup("reset_devices", set_reset_devices);
74125
74126 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
74127 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
74128 +static int __init setup_grsec_proc_gid(char *str)
74129 +{
74130 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
74131 + return 1;
74132 +}
74133 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
74134 +#endif
74135 +
74136 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
74137 +extern char pax_enter_kernel_user[];
74138 +extern char pax_exit_kernel_user[];
74139 +extern pgdval_t clone_pgd_mask;
74140 +#endif
74141 +
74142 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
74143 +static int __init setup_pax_nouderef(char *str)
74144 +{
74145 +#ifdef CONFIG_X86_32
74146 + unsigned int cpu;
74147 + struct desc_struct *gdt;
74148 +
74149 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
74150 + gdt = get_cpu_gdt_table(cpu);
74151 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
74152 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
74153 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
74154 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
74155 + }
74156 + loadsegment(ds, __KERNEL_DS);
74157 + loadsegment(es, __KERNEL_DS);
74158 + loadsegment(ss, __KERNEL_DS);
74159 +#else
74160 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
74161 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
74162 + clone_pgd_mask = ~(pgdval_t)0UL;
74163 +#endif
74164 +
74165 + return 0;
74166 +}
74167 +early_param("pax_nouderef", setup_pax_nouderef);
74168 +#endif
74169 +
74170 +#ifdef CONFIG_PAX_SOFTMODE
74171 +int pax_softmode;
74172 +
74173 +static int __init setup_pax_softmode(char *str)
74174 +{
74175 + get_option(&str, &pax_softmode);
74176 + return 1;
74177 +}
74178 +__setup("pax_softmode=", setup_pax_softmode);
74179 +#endif
74180 +
74181 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
74182 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
74183 static const char *panic_later, *panic_param;
74184 @@ -681,6 +738,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
74185 {
74186 int count = preempt_count();
74187 int ret;
74188 + const char *msg1 = "", *msg2 = "";
74189
74190 if (initcall_debug)
74191 ret = do_one_initcall_debug(fn);
74192 @@ -693,15 +751,15 @@ int __init_or_module do_one_initcall(initcall_t fn)
74193 sprintf(msgbuf, "error code %d ", ret);
74194
74195 if (preempt_count() != count) {
74196 - strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
74197 + msg1 = " preemption imbalance";
74198 preempt_count() = count;
74199 }
74200 if (irqs_disabled()) {
74201 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
74202 + msg2 = " disabled interrupts";
74203 local_irq_enable();
74204 }
74205 - if (msgbuf[0]) {
74206 - printk("initcall %pF returned with %s\n", fn, msgbuf);
74207 + if (msgbuf[0] || *msg1 || *msg2) {
74208 + printk("initcall %pF returned with %s%s%s\n", fn, msgbuf, msg1, msg2);
74209 }
74210
74211 return ret;
74212 @@ -755,8 +813,14 @@ static void __init do_initcall_level(int level)
74213 level, level,
74214 &repair_env_string);
74215
74216 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
74217 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
74218 do_one_initcall(*fn);
74219 +
74220 +#ifdef LATENT_ENTROPY_PLUGIN
74221 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74222 +#endif
74223 +
74224 + }
74225 }
74226
74227 static void __init do_initcalls(void)
74228 @@ -790,8 +854,14 @@ static void __init do_pre_smp_initcalls(void)
74229 {
74230 initcall_t *fn;
74231
74232 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
74233 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
74234 do_one_initcall(*fn);
74235 +
74236 +#ifdef LATENT_ENTROPY_PLUGIN
74237 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74238 +#endif
74239 +
74240 + }
74241 }
74242
74243 static int run_init_process(const char *init_filename)
74244 @@ -877,7 +947,7 @@ static noinline void __init kernel_init_freeable(void)
74245 do_basic_setup();
74246
74247 /* Open the /dev/console on the rootfs, this should never fail */
74248 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
74249 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
74250 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
74251
74252 (void) sys_dup(0);
74253 @@ -890,11 +960,13 @@ static noinline void __init kernel_init_freeable(void)
74254 if (!ramdisk_execute_command)
74255 ramdisk_execute_command = "/init";
74256
74257 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
74258 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
74259 ramdisk_execute_command = NULL;
74260 prepare_namespace();
74261 }
74262
74263 + grsecurity_init();
74264 +
74265 /*
74266 * Ok, we have completed the initial bootup, and
74267 * we're essentially up and running. Get rid of the
74268 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
74269 index 130dfec..cc88451 100644
74270 --- a/ipc/ipc_sysctl.c
74271 +++ b/ipc/ipc_sysctl.c
74272 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
74273 static int proc_ipc_dointvec(ctl_table *table, int write,
74274 void __user *buffer, size_t *lenp, loff_t *ppos)
74275 {
74276 - struct ctl_table ipc_table;
74277 + ctl_table_no_const ipc_table;
74278
74279 memcpy(&ipc_table, table, sizeof(ipc_table));
74280 ipc_table.data = get_ipc(table);
74281 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
74282 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
74283 void __user *buffer, size_t *lenp, loff_t *ppos)
74284 {
74285 - struct ctl_table ipc_table;
74286 + ctl_table_no_const ipc_table;
74287
74288 memcpy(&ipc_table, table, sizeof(ipc_table));
74289 ipc_table.data = get_ipc(table);
74290 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
74291 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74292 void __user *buffer, size_t *lenp, loff_t *ppos)
74293 {
74294 - struct ctl_table ipc_table;
74295 + ctl_table_no_const ipc_table;
74296 size_t lenp_bef = *lenp;
74297 int rc;
74298
74299 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74300 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
74301 void __user *buffer, size_t *lenp, loff_t *ppos)
74302 {
74303 - struct ctl_table ipc_table;
74304 + ctl_table_no_const ipc_table;
74305 memcpy(&ipc_table, table, sizeof(ipc_table));
74306 ipc_table.data = get_ipc(table);
74307
74308 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
74309 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
74310 void __user *buffer, size_t *lenp, loff_t *ppos)
74311 {
74312 - struct ctl_table ipc_table;
74313 + ctl_table_no_const ipc_table;
74314 size_t lenp_bef = *lenp;
74315 int oldval;
74316 int rc;
74317 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
74318 index 383d638..943fdbb 100644
74319 --- a/ipc/mq_sysctl.c
74320 +++ b/ipc/mq_sysctl.c
74321 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
74322 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
74323 void __user *buffer, size_t *lenp, loff_t *ppos)
74324 {
74325 - struct ctl_table mq_table;
74326 + ctl_table_no_const mq_table;
74327 memcpy(&mq_table, table, sizeof(mq_table));
74328 mq_table.data = get_mq(table);
74329
74330 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
74331 index f3f40dc..ffe5a3a 100644
74332 --- a/ipc/mqueue.c
74333 +++ b/ipc/mqueue.c
74334 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
74335 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
74336 info->attr.mq_msgsize);
74337
74338 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
74339 spin_lock(&mq_lock);
74340 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
74341 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
74342 diff --git a/ipc/msg.c b/ipc/msg.c
74343 index 31cd1bf..9778e0f8 100644
74344 --- a/ipc/msg.c
74345 +++ b/ipc/msg.c
74346 @@ -309,18 +309,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
74347 return security_msg_queue_associate(msq, msgflg);
74348 }
74349
74350 +static struct ipc_ops msg_ops = {
74351 + .getnew = newque,
74352 + .associate = msg_security,
74353 + .more_checks = NULL
74354 +};
74355 +
74356 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
74357 {
74358 struct ipc_namespace *ns;
74359 - struct ipc_ops msg_ops;
74360 struct ipc_params msg_params;
74361
74362 ns = current->nsproxy->ipc_ns;
74363
74364 - msg_ops.getnew = newque;
74365 - msg_ops.associate = msg_security;
74366 - msg_ops.more_checks = NULL;
74367 -
74368 msg_params.key = key;
74369 msg_params.flg = msgflg;
74370
74371 @@ -872,6 +873,7 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp,
74372 goto out_unlock;
74373 break;
74374 }
74375 + msg = ERR_PTR(-EAGAIN);
74376 } else
74377 break;
74378 msg_counter++;
74379 diff --git a/ipc/sem.c b/ipc/sem.c
74380 index 58d31f1..cce7a55 100644
74381 --- a/ipc/sem.c
74382 +++ b/ipc/sem.c
74383 @@ -364,10 +364,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
74384 return 0;
74385 }
74386
74387 +static struct ipc_ops sem_ops = {
74388 + .getnew = newary,
74389 + .associate = sem_security,
74390 + .more_checks = sem_more_checks
74391 +};
74392 +
74393 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74394 {
74395 struct ipc_namespace *ns;
74396 - struct ipc_ops sem_ops;
74397 struct ipc_params sem_params;
74398
74399 ns = current->nsproxy->ipc_ns;
74400 @@ -375,10 +380,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74401 if (nsems < 0 || nsems > ns->sc_semmsl)
74402 return -EINVAL;
74403
74404 - sem_ops.getnew = newary;
74405 - sem_ops.associate = sem_security;
74406 - sem_ops.more_checks = sem_more_checks;
74407 -
74408 sem_params.key = key;
74409 sem_params.flg = semflg;
74410 sem_params.u.nsems = nsems;
74411 diff --git a/ipc/shm.c b/ipc/shm.c
74412 index 4fa6d8f..55cff14 100644
74413 --- a/ipc/shm.c
74414 +++ b/ipc/shm.c
74415 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
74416 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
74417 #endif
74418
74419 +#ifdef CONFIG_GRKERNSEC
74420 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74421 + const time_t shm_createtime, const kuid_t cuid,
74422 + const int shmid);
74423 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74424 + const time_t shm_createtime);
74425 +#endif
74426 +
74427 void shm_init_ns(struct ipc_namespace *ns)
74428 {
74429 ns->shm_ctlmax = SHMMAX;
74430 @@ -521,6 +529,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
74431 shp->shm_lprid = 0;
74432 shp->shm_atim = shp->shm_dtim = 0;
74433 shp->shm_ctim = get_seconds();
74434 +#ifdef CONFIG_GRKERNSEC
74435 + {
74436 + struct timespec timeval;
74437 + do_posix_clock_monotonic_gettime(&timeval);
74438 +
74439 + shp->shm_createtime = timeval.tv_sec;
74440 + }
74441 +#endif
74442 shp->shm_segsz = size;
74443 shp->shm_nattch = 0;
74444 shp->shm_file = file;
74445 @@ -572,18 +588,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
74446 return 0;
74447 }
74448
74449 +static struct ipc_ops shm_ops = {
74450 + .getnew = newseg,
74451 + .associate = shm_security,
74452 + .more_checks = shm_more_checks
74453 +};
74454 +
74455 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
74456 {
74457 struct ipc_namespace *ns;
74458 - struct ipc_ops shm_ops;
74459 struct ipc_params shm_params;
74460
74461 ns = current->nsproxy->ipc_ns;
74462
74463 - shm_ops.getnew = newseg;
74464 - shm_ops.associate = shm_security;
74465 - shm_ops.more_checks = shm_more_checks;
74466 -
74467 shm_params.key = key;
74468 shm_params.flg = shmflg;
74469 shm_params.u.size = size;
74470 @@ -1004,6 +1021,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74471 f_mode = FMODE_READ | FMODE_WRITE;
74472 }
74473 if (shmflg & SHM_EXEC) {
74474 +
74475 +#ifdef CONFIG_PAX_MPROTECT
74476 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
74477 + goto out;
74478 +#endif
74479 +
74480 prot |= PROT_EXEC;
74481 acc_mode |= S_IXUGO;
74482 }
74483 @@ -1027,9 +1050,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74484 if (err)
74485 goto out_unlock;
74486
74487 +#ifdef CONFIG_GRKERNSEC
74488 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
74489 + shp->shm_perm.cuid, shmid) ||
74490 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
74491 + err = -EACCES;
74492 + goto out_unlock;
74493 + }
74494 +#endif
74495 +
74496 path = shp->shm_file->f_path;
74497 path_get(&path);
74498 shp->shm_nattch++;
74499 +#ifdef CONFIG_GRKERNSEC
74500 + shp->shm_lapid = current->pid;
74501 +#endif
74502 size = i_size_read(path.dentry->d_inode);
74503 shm_unlock(shp);
74504
74505 diff --git a/kernel/acct.c b/kernel/acct.c
74506 index 051e071..15e0920 100644
74507 --- a/kernel/acct.c
74508 +++ b/kernel/acct.c
74509 @@ -550,7 +550,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
74510 */
74511 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
74512 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
74513 - file->f_op->write(file, (char *)&ac,
74514 + file->f_op->write(file, (char __force_user *)&ac,
74515 sizeof(acct_t), &file->f_pos);
74516 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
74517 set_fs(fs);
74518 diff --git a/kernel/audit.c b/kernel/audit.c
74519 index d596e53..dbef3c3 100644
74520 --- a/kernel/audit.c
74521 +++ b/kernel/audit.c
74522 @@ -116,7 +116,7 @@ u32 audit_sig_sid = 0;
74523 3) suppressed due to audit_rate_limit
74524 4) suppressed due to audit_backlog_limit
74525 */
74526 -static atomic_t audit_lost = ATOMIC_INIT(0);
74527 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
74528
74529 /* The netlink socket. */
74530 static struct sock *audit_sock;
74531 @@ -238,7 +238,7 @@ void audit_log_lost(const char *message)
74532 unsigned long now;
74533 int print;
74534
74535 - atomic_inc(&audit_lost);
74536 + atomic_inc_unchecked(&audit_lost);
74537
74538 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
74539
74540 @@ -257,7 +257,7 @@ void audit_log_lost(const char *message)
74541 printk(KERN_WARNING
74542 "audit: audit_lost=%d audit_rate_limit=%d "
74543 "audit_backlog_limit=%d\n",
74544 - atomic_read(&audit_lost),
74545 + atomic_read_unchecked(&audit_lost),
74546 audit_rate_limit,
74547 audit_backlog_limit);
74548 audit_panic(message);
74549 @@ -681,7 +681,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
74550 status_set.pid = audit_pid;
74551 status_set.rate_limit = audit_rate_limit;
74552 status_set.backlog_limit = audit_backlog_limit;
74553 - status_set.lost = atomic_read(&audit_lost);
74554 + status_set.lost = atomic_read_unchecked(&audit_lost);
74555 status_set.backlog = skb_queue_len(&audit_skb_queue);
74556 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
74557 &status_set, sizeof(status_set));
74558 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
74559 index a371f85..da826c1 100644
74560 --- a/kernel/auditsc.c
74561 +++ b/kernel/auditsc.c
74562 @@ -2292,7 +2292,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
74563 }
74564
74565 /* global counter which is incremented every time something logs in */
74566 -static atomic_t session_id = ATOMIC_INIT(0);
74567 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
74568
74569 /**
74570 * audit_set_loginuid - set current task's audit_context loginuid
74571 @@ -2316,7 +2316,7 @@ int audit_set_loginuid(kuid_t loginuid)
74572 return -EPERM;
74573 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
74574
74575 - sessionid = atomic_inc_return(&session_id);
74576 + sessionid = atomic_inc_return_unchecked(&session_id);
74577 if (context && context->in_syscall) {
74578 struct audit_buffer *ab;
74579
74580 diff --git a/kernel/capability.c b/kernel/capability.c
74581 index 493d972..f87dfbd 100644
74582 --- a/kernel/capability.c
74583 +++ b/kernel/capability.c
74584 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
74585 * before modification is attempted and the application
74586 * fails.
74587 */
74588 + if (tocopy > ARRAY_SIZE(kdata))
74589 + return -EFAULT;
74590 +
74591 if (copy_to_user(dataptr, kdata, tocopy
74592 * sizeof(struct __user_cap_data_struct))) {
74593 return -EFAULT;
74594 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
74595 int ret;
74596
74597 rcu_read_lock();
74598 - ret = security_capable(__task_cred(t), ns, cap);
74599 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
74600 + gr_task_is_capable(t, __task_cred(t), cap);
74601 rcu_read_unlock();
74602
74603 - return (ret == 0);
74604 + return ret;
74605 }
74606
74607 /**
74608 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
74609 int ret;
74610
74611 rcu_read_lock();
74612 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
74613 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
74614 rcu_read_unlock();
74615
74616 - return (ret == 0);
74617 + return ret;
74618 }
74619
74620 /**
74621 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
74622 BUG();
74623 }
74624
74625 - if (security_capable(current_cred(), ns, cap) == 0) {
74626 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
74627 current->flags |= PF_SUPERPRIV;
74628 return true;
74629 }
74630 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
74631 }
74632 EXPORT_SYMBOL(ns_capable);
74633
74634 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
74635 +{
74636 + if (unlikely(!cap_valid(cap))) {
74637 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
74638 + BUG();
74639 + }
74640 +
74641 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
74642 + current->flags |= PF_SUPERPRIV;
74643 + return true;
74644 + }
74645 + return false;
74646 +}
74647 +EXPORT_SYMBOL(ns_capable_nolog);
74648 +
74649 /**
74650 * capable - Determine if the current task has a superior capability in effect
74651 * @cap: The capability to be tested for
74652 @@ -408,6 +427,12 @@ bool capable(int cap)
74653 }
74654 EXPORT_SYMBOL(capable);
74655
74656 +bool capable_nolog(int cap)
74657 +{
74658 + return ns_capable_nolog(&init_user_ns, cap);
74659 +}
74660 +EXPORT_SYMBOL(capable_nolog);
74661 +
74662 /**
74663 * nsown_capable - Check superior capability to one's own user_ns
74664 * @cap: The capability in question
74665 @@ -440,3 +465,10 @@ bool inode_capable(const struct inode *inode, int cap)
74666
74667 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74668 }
74669 +
74670 +bool inode_capable_nolog(const struct inode *inode, int cap)
74671 +{
74672 + struct user_namespace *ns = current_user_ns();
74673 +
74674 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74675 +}
74676 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
74677 index 1e23664..570a83d 100644
74678 --- a/kernel/cgroup.c
74679 +++ b/kernel/cgroup.c
74680 @@ -5543,7 +5543,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
74681 struct css_set *cg = link->cg;
74682 struct task_struct *task;
74683 int count = 0;
74684 - seq_printf(seq, "css_set %p\n", cg);
74685 + seq_printf(seq, "css_set %pK\n", cg);
74686 list_for_each_entry(task, &cg->tasks, cg_list) {
74687 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
74688 seq_puts(seq, " ...\n");
74689 diff --git a/kernel/compat.c b/kernel/compat.c
74690 index 36700e9..73d770c 100644
74691 --- a/kernel/compat.c
74692 +++ b/kernel/compat.c
74693 @@ -13,6 +13,7 @@
74694
74695 #include <linux/linkage.h>
74696 #include <linux/compat.h>
74697 +#include <linux/module.h>
74698 #include <linux/errno.h>
74699 #include <linux/time.h>
74700 #include <linux/signal.h>
74701 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
74702 mm_segment_t oldfs;
74703 long ret;
74704
74705 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
74706 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
74707 oldfs = get_fs();
74708 set_fs(KERNEL_DS);
74709 ret = hrtimer_nanosleep_restart(restart);
74710 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
74711 oldfs = get_fs();
74712 set_fs(KERNEL_DS);
74713 ret = hrtimer_nanosleep(&tu,
74714 - rmtp ? (struct timespec __user *)&rmt : NULL,
74715 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
74716 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
74717 set_fs(oldfs);
74718
74719 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
74720 mm_segment_t old_fs = get_fs();
74721
74722 set_fs(KERNEL_DS);
74723 - ret = sys_sigpending((old_sigset_t __user *) &s);
74724 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
74725 set_fs(old_fs);
74726 if (ret == 0)
74727 ret = put_user(s, set);
74728 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
74729 mm_segment_t old_fs = get_fs();
74730
74731 set_fs(KERNEL_DS);
74732 - ret = sys_old_getrlimit(resource, &r);
74733 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
74734 set_fs(old_fs);
74735
74736 if (!ret) {
74737 @@ -523,7 +524,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
74738 mm_segment_t old_fs = get_fs();
74739
74740 set_fs(KERNEL_DS);
74741 - ret = sys_getrusage(who, (struct rusage __user *) &r);
74742 + ret = sys_getrusage(who, (struct rusage __force_user *) &r);
74743 set_fs(old_fs);
74744
74745 if (ret)
74746 @@ -552,8 +553,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
74747 set_fs (KERNEL_DS);
74748 ret = sys_wait4(pid,
74749 (stat_addr ?
74750 - (unsigned int __user *) &status : NULL),
74751 - options, (struct rusage __user *) &r);
74752 + (unsigned int __force_user *) &status : NULL),
74753 + options, (struct rusage __force_user *) &r);
74754 set_fs (old_fs);
74755
74756 if (ret > 0) {
74757 @@ -579,8 +580,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
74758 memset(&info, 0, sizeof(info));
74759
74760 set_fs(KERNEL_DS);
74761 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
74762 - uru ? (struct rusage __user *)&ru : NULL);
74763 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
74764 + uru ? (struct rusage __force_user *)&ru : NULL);
74765 set_fs(old_fs);
74766
74767 if ((ret < 0) || (info.si_signo == 0))
74768 @@ -714,8 +715,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
74769 oldfs = get_fs();
74770 set_fs(KERNEL_DS);
74771 err = sys_timer_settime(timer_id, flags,
74772 - (struct itimerspec __user *) &newts,
74773 - (struct itimerspec __user *) &oldts);
74774 + (struct itimerspec __force_user *) &newts,
74775 + (struct itimerspec __force_user *) &oldts);
74776 set_fs(oldfs);
74777 if (!err && old && put_compat_itimerspec(old, &oldts))
74778 return -EFAULT;
74779 @@ -732,7 +733,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
74780 oldfs = get_fs();
74781 set_fs(KERNEL_DS);
74782 err = sys_timer_gettime(timer_id,
74783 - (struct itimerspec __user *) &ts);
74784 + (struct itimerspec __force_user *) &ts);
74785 set_fs(oldfs);
74786 if (!err && put_compat_itimerspec(setting, &ts))
74787 return -EFAULT;
74788 @@ -751,7 +752,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
74789 oldfs = get_fs();
74790 set_fs(KERNEL_DS);
74791 err = sys_clock_settime(which_clock,
74792 - (struct timespec __user *) &ts);
74793 + (struct timespec __force_user *) &ts);
74794 set_fs(oldfs);
74795 return err;
74796 }
74797 @@ -766,7 +767,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
74798 oldfs = get_fs();
74799 set_fs(KERNEL_DS);
74800 err = sys_clock_gettime(which_clock,
74801 - (struct timespec __user *) &ts);
74802 + (struct timespec __force_user *) &ts);
74803 set_fs(oldfs);
74804 if (!err && put_compat_timespec(&ts, tp))
74805 return -EFAULT;
74806 @@ -786,7 +787,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
74807
74808 oldfs = get_fs();
74809 set_fs(KERNEL_DS);
74810 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
74811 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
74812 set_fs(oldfs);
74813
74814 err = compat_put_timex(utp, &txc);
74815 @@ -806,7 +807,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
74816 oldfs = get_fs();
74817 set_fs(KERNEL_DS);
74818 err = sys_clock_getres(which_clock,
74819 - (struct timespec __user *) &ts);
74820 + (struct timespec __force_user *) &ts);
74821 set_fs(oldfs);
74822 if (!err && tp && put_compat_timespec(&ts, tp))
74823 return -EFAULT;
74824 @@ -818,9 +819,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
74825 long err;
74826 mm_segment_t oldfs;
74827 struct timespec tu;
74828 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
74829 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
74830
74831 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
74832 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
74833 oldfs = get_fs();
74834 set_fs(KERNEL_DS);
74835 err = clock_nanosleep_restart(restart);
74836 @@ -852,8 +853,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
74837 oldfs = get_fs();
74838 set_fs(KERNEL_DS);
74839 err = sys_clock_nanosleep(which_clock, flags,
74840 - (struct timespec __user *) &in,
74841 - (struct timespec __user *) &out);
74842 + (struct timespec __force_user *) &in,
74843 + (struct timespec __force_user *) &out);
74844 set_fs(oldfs);
74845
74846 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
74847 diff --git a/kernel/configs.c b/kernel/configs.c
74848 index 42e8fa0..9e7406b 100644
74849 --- a/kernel/configs.c
74850 +++ b/kernel/configs.c
74851 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
74852 struct proc_dir_entry *entry;
74853
74854 /* create the current config file */
74855 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
74856 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
74857 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
74858 + &ikconfig_file_ops);
74859 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74860 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
74861 + &ikconfig_file_ops);
74862 +#endif
74863 +#else
74864 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
74865 &ikconfig_file_ops);
74866 +#endif
74867 +
74868 if (!entry)
74869 return -ENOMEM;
74870
74871 diff --git a/kernel/cred.c b/kernel/cred.c
74872 index e0573a4..3874e41 100644
74873 --- a/kernel/cred.c
74874 +++ b/kernel/cred.c
74875 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
74876 validate_creds(cred);
74877 alter_cred_subscribers(cred, -1);
74878 put_cred(cred);
74879 +
74880 +#ifdef CONFIG_GRKERNSEC_SETXID
74881 + cred = (struct cred *) tsk->delayed_cred;
74882 + if (cred != NULL) {
74883 + tsk->delayed_cred = NULL;
74884 + validate_creds(cred);
74885 + alter_cred_subscribers(cred, -1);
74886 + put_cred(cred);
74887 + }
74888 +#endif
74889 }
74890
74891 /**
74892 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
74893 * Always returns 0 thus allowing this function to be tail-called at the end
74894 * of, say, sys_setgid().
74895 */
74896 -int commit_creds(struct cred *new)
74897 +static int __commit_creds(struct cred *new)
74898 {
74899 struct task_struct *task = current;
74900 const struct cred *old = task->real_cred;
74901 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
74902
74903 get_cred(new); /* we will require a ref for the subj creds too */
74904
74905 + gr_set_role_label(task, new->uid, new->gid);
74906 +
74907 /* dumpability changes */
74908 if (!uid_eq(old->euid, new->euid) ||
74909 !gid_eq(old->egid, new->egid) ||
74910 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
74911 put_cred(old);
74912 return 0;
74913 }
74914 +#ifdef CONFIG_GRKERNSEC_SETXID
74915 +extern int set_user(struct cred *new);
74916 +
74917 +void gr_delayed_cred_worker(void)
74918 +{
74919 + const struct cred *new = current->delayed_cred;
74920 + struct cred *ncred;
74921 +
74922 + current->delayed_cred = NULL;
74923 +
74924 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
74925 + // from doing get_cred on it when queueing this
74926 + put_cred(new);
74927 + return;
74928 + } else if (new == NULL)
74929 + return;
74930 +
74931 + ncred = prepare_creds();
74932 + if (!ncred)
74933 + goto die;
74934 + // uids
74935 + ncred->uid = new->uid;
74936 + ncred->euid = new->euid;
74937 + ncred->suid = new->suid;
74938 + ncred->fsuid = new->fsuid;
74939 + // gids
74940 + ncred->gid = new->gid;
74941 + ncred->egid = new->egid;
74942 + ncred->sgid = new->sgid;
74943 + ncred->fsgid = new->fsgid;
74944 + // groups
74945 + if (set_groups(ncred, new->group_info) < 0) {
74946 + abort_creds(ncred);
74947 + goto die;
74948 + }
74949 + // caps
74950 + ncred->securebits = new->securebits;
74951 + ncred->cap_inheritable = new->cap_inheritable;
74952 + ncred->cap_permitted = new->cap_permitted;
74953 + ncred->cap_effective = new->cap_effective;
74954 + ncred->cap_bset = new->cap_bset;
74955 +
74956 + if (set_user(ncred)) {
74957 + abort_creds(ncred);
74958 + goto die;
74959 + }
74960 +
74961 + // from doing get_cred on it when queueing this
74962 + put_cred(new);
74963 +
74964 + __commit_creds(ncred);
74965 + return;
74966 +die:
74967 + // from doing get_cred on it when queueing this
74968 + put_cred(new);
74969 + do_group_exit(SIGKILL);
74970 +}
74971 +#endif
74972 +
74973 +int commit_creds(struct cred *new)
74974 +{
74975 +#ifdef CONFIG_GRKERNSEC_SETXID
74976 + int ret;
74977 + int schedule_it = 0;
74978 + struct task_struct *t;
74979 +
74980 + /* we won't get called with tasklist_lock held for writing
74981 + and interrupts disabled as the cred struct in that case is
74982 + init_cred
74983 + */
74984 + if (grsec_enable_setxid && !current_is_single_threaded() &&
74985 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
74986 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
74987 + schedule_it = 1;
74988 + }
74989 + ret = __commit_creds(new);
74990 + if (schedule_it) {
74991 + rcu_read_lock();
74992 + read_lock(&tasklist_lock);
74993 + for (t = next_thread(current); t != current;
74994 + t = next_thread(t)) {
74995 + if (t->delayed_cred == NULL) {
74996 + t->delayed_cred = get_cred(new);
74997 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
74998 + set_tsk_need_resched(t);
74999 + }
75000 + }
75001 + read_unlock(&tasklist_lock);
75002 + rcu_read_unlock();
75003 + }
75004 + return ret;
75005 +#else
75006 + return __commit_creds(new);
75007 +#endif
75008 +}
75009 +
75010 EXPORT_SYMBOL(commit_creds);
75011
75012 /**
75013 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
75014 index 9a61738..c5c8f3a 100644
75015 --- a/kernel/debug/debug_core.c
75016 +++ b/kernel/debug/debug_core.c
75017 @@ -122,7 +122,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
75018 */
75019 static atomic_t masters_in_kgdb;
75020 static atomic_t slaves_in_kgdb;
75021 -static atomic_t kgdb_break_tasklet_var;
75022 +static atomic_unchecked_t kgdb_break_tasklet_var;
75023 atomic_t kgdb_setting_breakpoint;
75024
75025 struct task_struct *kgdb_usethread;
75026 @@ -132,7 +132,7 @@ int kgdb_single_step;
75027 static pid_t kgdb_sstep_pid;
75028
75029 /* to keep track of the CPU which is doing the single stepping*/
75030 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
75031 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
75032
75033 /*
75034 * If you are debugging a problem where roundup (the collection of
75035 @@ -540,7 +540,7 @@ return_normal:
75036 * kernel will only try for the value of sstep_tries before
75037 * giving up and continuing on.
75038 */
75039 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
75040 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
75041 (kgdb_info[cpu].task &&
75042 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
75043 atomic_set(&kgdb_active, -1);
75044 @@ -634,8 +634,8 @@ cpu_master_loop:
75045 }
75046
75047 kgdb_restore:
75048 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
75049 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
75050 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
75051 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
75052 if (kgdb_info[sstep_cpu].task)
75053 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
75054 else
75055 @@ -887,18 +887,18 @@ static void kgdb_unregister_callbacks(void)
75056 static void kgdb_tasklet_bpt(unsigned long ing)
75057 {
75058 kgdb_breakpoint();
75059 - atomic_set(&kgdb_break_tasklet_var, 0);
75060 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
75061 }
75062
75063 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
75064
75065 void kgdb_schedule_breakpoint(void)
75066 {
75067 - if (atomic_read(&kgdb_break_tasklet_var) ||
75068 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
75069 atomic_read(&kgdb_active) != -1 ||
75070 atomic_read(&kgdb_setting_breakpoint))
75071 return;
75072 - atomic_inc(&kgdb_break_tasklet_var);
75073 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
75074 tasklet_schedule(&kgdb_tasklet_breakpoint);
75075 }
75076 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
75077 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
75078 index 8875254..7cf4928 100644
75079 --- a/kernel/debug/kdb/kdb_main.c
75080 +++ b/kernel/debug/kdb/kdb_main.c
75081 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
75082 continue;
75083
75084 kdb_printf("%-20s%8u 0x%p ", mod->name,
75085 - mod->core_size, (void *)mod);
75086 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
75087 #ifdef CONFIG_MODULE_UNLOAD
75088 kdb_printf("%4ld ", module_refcount(mod));
75089 #endif
75090 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
75091 kdb_printf(" (Loading)");
75092 else
75093 kdb_printf(" (Live)");
75094 - kdb_printf(" 0x%p", mod->module_core);
75095 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
75096
75097 #ifdef CONFIG_MODULE_UNLOAD
75098 {
75099 diff --git a/kernel/events/core.c b/kernel/events/core.c
75100 index 7b6646a..3cb1135 100644
75101 --- a/kernel/events/core.c
75102 +++ b/kernel/events/core.c
75103 @@ -182,7 +182,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
75104 return 0;
75105 }
75106
75107 -static atomic64_t perf_event_id;
75108 +static atomic64_unchecked_t perf_event_id;
75109
75110 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
75111 enum event_type_t event_type);
75112 @@ -2677,7 +2677,7 @@ static void __perf_event_read(void *info)
75113
75114 static inline u64 perf_event_count(struct perf_event *event)
75115 {
75116 - return local64_read(&event->count) + atomic64_read(&event->child_count);
75117 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
75118 }
75119
75120 static u64 perf_event_read(struct perf_event *event)
75121 @@ -3007,9 +3007,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
75122 mutex_lock(&event->child_mutex);
75123 total += perf_event_read(event);
75124 *enabled += event->total_time_enabled +
75125 - atomic64_read(&event->child_total_time_enabled);
75126 + atomic64_read_unchecked(&event->child_total_time_enabled);
75127 *running += event->total_time_running +
75128 - atomic64_read(&event->child_total_time_running);
75129 + atomic64_read_unchecked(&event->child_total_time_running);
75130
75131 list_for_each_entry(child, &event->child_list, child_list) {
75132 total += perf_event_read(child);
75133 @@ -3412,10 +3412,10 @@ void perf_event_update_userpage(struct perf_event *event)
75134 userpg->offset -= local64_read(&event->hw.prev_count);
75135
75136 userpg->time_enabled = enabled +
75137 - atomic64_read(&event->child_total_time_enabled);
75138 + atomic64_read_unchecked(&event->child_total_time_enabled);
75139
75140 userpg->time_running = running +
75141 - atomic64_read(&event->child_total_time_running);
75142 + atomic64_read_unchecked(&event->child_total_time_running);
75143
75144 arch_perf_update_userpage(userpg, now);
75145
75146 @@ -3974,11 +3974,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
75147 values[n++] = perf_event_count(event);
75148 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
75149 values[n++] = enabled +
75150 - atomic64_read(&event->child_total_time_enabled);
75151 + atomic64_read_unchecked(&event->child_total_time_enabled);
75152 }
75153 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
75154 values[n++] = running +
75155 - atomic64_read(&event->child_total_time_running);
75156 + atomic64_read_unchecked(&event->child_total_time_running);
75157 }
75158 if (read_format & PERF_FORMAT_ID)
75159 values[n++] = primary_event_id(event);
75160 @@ -4721,12 +4721,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
75161 * need to add enough zero bytes after the string to handle
75162 * the 64bit alignment we do later.
75163 */
75164 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
75165 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
75166 if (!buf) {
75167 name = strncpy(tmp, "//enomem", sizeof(tmp));
75168 goto got_name;
75169 }
75170 - name = d_path(&file->f_path, buf, PATH_MAX);
75171 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
75172 if (IS_ERR(name)) {
75173 name = strncpy(tmp, "//toolong", sizeof(tmp));
75174 goto got_name;
75175 @@ -6165,7 +6165,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
75176 event->parent = parent_event;
75177
75178 event->ns = get_pid_ns(task_active_pid_ns(current));
75179 - event->id = atomic64_inc_return(&perf_event_id);
75180 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
75181
75182 event->state = PERF_EVENT_STATE_INACTIVE;
75183
75184 @@ -6790,10 +6790,10 @@ static void sync_child_event(struct perf_event *child_event,
75185 /*
75186 * Add back the child's count to the parent's count:
75187 */
75188 - atomic64_add(child_val, &parent_event->child_count);
75189 - atomic64_add(child_event->total_time_enabled,
75190 + atomic64_add_unchecked(child_val, &parent_event->child_count);
75191 + atomic64_add_unchecked(child_event->total_time_enabled,
75192 &parent_event->child_total_time_enabled);
75193 - atomic64_add(child_event->total_time_running,
75194 + atomic64_add_unchecked(child_event->total_time_running,
75195 &parent_event->child_total_time_running);
75196
75197 /*
75198 diff --git a/kernel/exit.c b/kernel/exit.c
75199 index b4df219..f13c02d 100644
75200 --- a/kernel/exit.c
75201 +++ b/kernel/exit.c
75202 @@ -170,6 +170,10 @@ void release_task(struct task_struct * p)
75203 struct task_struct *leader;
75204 int zap_leader;
75205 repeat:
75206 +#ifdef CONFIG_NET
75207 + gr_del_task_from_ip_table(p);
75208 +#endif
75209 +
75210 /* don't need to get the RCU readlock here - the process is dead and
75211 * can't be modifying its own credentials. But shut RCU-lockdep up */
75212 rcu_read_lock();
75213 @@ -338,7 +342,7 @@ int allow_signal(int sig)
75214 * know it'll be handled, so that they don't get converted to
75215 * SIGKILL or just silently dropped.
75216 */
75217 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
75218 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
75219 recalc_sigpending();
75220 spin_unlock_irq(&current->sighand->siglock);
75221 return 0;
75222 @@ -708,6 +712,8 @@ void do_exit(long code)
75223 struct task_struct *tsk = current;
75224 int group_dead;
75225
75226 + set_fs(USER_DS);
75227 +
75228 profile_task_exit(tsk);
75229
75230 WARN_ON(blk_needs_flush_plug(tsk));
75231 @@ -724,7 +730,6 @@ void do_exit(long code)
75232 * mm_release()->clear_child_tid() from writing to a user-controlled
75233 * kernel address.
75234 */
75235 - set_fs(USER_DS);
75236
75237 ptrace_event(PTRACE_EVENT_EXIT, code);
75238
75239 @@ -783,6 +788,9 @@ void do_exit(long code)
75240 tsk->exit_code = code;
75241 taskstats_exit(tsk, group_dead);
75242
75243 + gr_acl_handle_psacct(tsk, code);
75244 + gr_acl_handle_exit();
75245 +
75246 exit_mm(tsk);
75247
75248 if (group_dead)
75249 @@ -903,7 +911,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
75250 * Take down every thread in the group. This is called by fatal signals
75251 * as well as by sys_exit_group (below).
75252 */
75253 -void
75254 +__noreturn void
75255 do_group_exit(int exit_code)
75256 {
75257 struct signal_struct *sig = current->signal;
75258 diff --git a/kernel/fork.c b/kernel/fork.c
75259 index 5630e52..0cee608 100644
75260 --- a/kernel/fork.c
75261 +++ b/kernel/fork.c
75262 @@ -318,7 +318,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
75263 *stackend = STACK_END_MAGIC; /* for overflow detection */
75264
75265 #ifdef CONFIG_CC_STACKPROTECTOR
75266 - tsk->stack_canary = get_random_int();
75267 + tsk->stack_canary = pax_get_random_long();
75268 #endif
75269
75270 /*
75271 @@ -344,13 +344,81 @@ free_tsk:
75272 }
75273
75274 #ifdef CONFIG_MMU
75275 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
75276 +{
75277 + struct vm_area_struct *tmp;
75278 + unsigned long charge;
75279 + struct mempolicy *pol;
75280 + struct file *file;
75281 +
75282 + charge = 0;
75283 + if (mpnt->vm_flags & VM_ACCOUNT) {
75284 + unsigned long len = vma_pages(mpnt);
75285 +
75286 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75287 + goto fail_nomem;
75288 + charge = len;
75289 + }
75290 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75291 + if (!tmp)
75292 + goto fail_nomem;
75293 + *tmp = *mpnt;
75294 + tmp->vm_mm = mm;
75295 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
75296 + pol = mpol_dup(vma_policy(mpnt));
75297 + if (IS_ERR(pol))
75298 + goto fail_nomem_policy;
75299 + vma_set_policy(tmp, pol);
75300 + if (anon_vma_fork(tmp, mpnt))
75301 + goto fail_nomem_anon_vma_fork;
75302 + tmp->vm_flags &= ~VM_LOCKED;
75303 + tmp->vm_next = tmp->vm_prev = NULL;
75304 + tmp->vm_mirror = NULL;
75305 + file = tmp->vm_file;
75306 + if (file) {
75307 + struct inode *inode = file->f_path.dentry->d_inode;
75308 + struct address_space *mapping = file->f_mapping;
75309 +
75310 + get_file(file);
75311 + if (tmp->vm_flags & VM_DENYWRITE)
75312 + atomic_dec(&inode->i_writecount);
75313 + mutex_lock(&mapping->i_mmap_mutex);
75314 + if (tmp->vm_flags & VM_SHARED)
75315 + mapping->i_mmap_writable++;
75316 + flush_dcache_mmap_lock(mapping);
75317 + /* insert tmp into the share list, just after mpnt */
75318 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75319 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
75320 + else
75321 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
75322 + flush_dcache_mmap_unlock(mapping);
75323 + mutex_unlock(&mapping->i_mmap_mutex);
75324 + }
75325 +
75326 + /*
75327 + * Clear hugetlb-related page reserves for children. This only
75328 + * affects MAP_PRIVATE mappings. Faults generated by the child
75329 + * are not guaranteed to succeed, even if read-only
75330 + */
75331 + if (is_vm_hugetlb_page(tmp))
75332 + reset_vma_resv_huge_pages(tmp);
75333 +
75334 + return tmp;
75335 +
75336 +fail_nomem_anon_vma_fork:
75337 + mpol_put(pol);
75338 +fail_nomem_policy:
75339 + kmem_cache_free(vm_area_cachep, tmp);
75340 +fail_nomem:
75341 + vm_unacct_memory(charge);
75342 + return NULL;
75343 +}
75344 +
75345 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75346 {
75347 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
75348 struct rb_node **rb_link, *rb_parent;
75349 int retval;
75350 - unsigned long charge;
75351 - struct mempolicy *pol;
75352
75353 uprobe_start_dup_mmap();
75354 down_write(&oldmm->mmap_sem);
75355 @@ -364,8 +432,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75356 mm->locked_vm = 0;
75357 mm->mmap = NULL;
75358 mm->mmap_cache = NULL;
75359 - mm->free_area_cache = oldmm->mmap_base;
75360 - mm->cached_hole_size = ~0UL;
75361 + mm->free_area_cache = oldmm->free_area_cache;
75362 + mm->cached_hole_size = oldmm->cached_hole_size;
75363 mm->map_count = 0;
75364 cpumask_clear(mm_cpumask(mm));
75365 mm->mm_rb = RB_ROOT;
75366 @@ -381,57 +449,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75367
75368 prev = NULL;
75369 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
75370 - struct file *file;
75371 -
75372 if (mpnt->vm_flags & VM_DONTCOPY) {
75373 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
75374 -vma_pages(mpnt));
75375 continue;
75376 }
75377 - charge = 0;
75378 - if (mpnt->vm_flags & VM_ACCOUNT) {
75379 - unsigned long len = vma_pages(mpnt);
75380 -
75381 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75382 - goto fail_nomem;
75383 - charge = len;
75384 - }
75385 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75386 - if (!tmp)
75387 - goto fail_nomem;
75388 - *tmp = *mpnt;
75389 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
75390 - pol = mpol_dup(vma_policy(mpnt));
75391 - retval = PTR_ERR(pol);
75392 - if (IS_ERR(pol))
75393 - goto fail_nomem_policy;
75394 - vma_set_policy(tmp, pol);
75395 - tmp->vm_mm = mm;
75396 - if (anon_vma_fork(tmp, mpnt))
75397 - goto fail_nomem_anon_vma_fork;
75398 - tmp->vm_flags &= ~VM_LOCKED;
75399 - tmp->vm_next = tmp->vm_prev = NULL;
75400 - file = tmp->vm_file;
75401 - if (file) {
75402 - struct inode *inode = file->f_path.dentry->d_inode;
75403 - struct address_space *mapping = file->f_mapping;
75404 -
75405 - get_file(file);
75406 - if (tmp->vm_flags & VM_DENYWRITE)
75407 - atomic_dec(&inode->i_writecount);
75408 - mutex_lock(&mapping->i_mmap_mutex);
75409 - if (tmp->vm_flags & VM_SHARED)
75410 - mapping->i_mmap_writable++;
75411 - flush_dcache_mmap_lock(mapping);
75412 - /* insert tmp into the share list, just after mpnt */
75413 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75414 - vma_nonlinear_insert(tmp,
75415 - &mapping->i_mmap_nonlinear);
75416 - else
75417 - vma_interval_tree_insert_after(tmp, mpnt,
75418 - &mapping->i_mmap);
75419 - flush_dcache_mmap_unlock(mapping);
75420 - mutex_unlock(&mapping->i_mmap_mutex);
75421 + tmp = dup_vma(mm, oldmm, mpnt);
75422 + if (!tmp) {
75423 + retval = -ENOMEM;
75424 + goto out;
75425 }
75426
75427 /*
75428 @@ -463,6 +489,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75429 if (retval)
75430 goto out;
75431 }
75432 +
75433 +#ifdef CONFIG_PAX_SEGMEXEC
75434 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
75435 + struct vm_area_struct *mpnt_m;
75436 +
75437 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
75438 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
75439 +
75440 + if (!mpnt->vm_mirror)
75441 + continue;
75442 +
75443 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
75444 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
75445 + mpnt->vm_mirror = mpnt_m;
75446 + } else {
75447 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
75448 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
75449 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
75450 + mpnt->vm_mirror->vm_mirror = mpnt;
75451 + }
75452 + }
75453 + BUG_ON(mpnt_m);
75454 + }
75455 +#endif
75456 +
75457 /* a new mm has just been created */
75458 arch_dup_mmap(oldmm, mm);
75459 retval = 0;
75460 @@ -472,14 +523,6 @@ out:
75461 up_write(&oldmm->mmap_sem);
75462 uprobe_end_dup_mmap();
75463 return retval;
75464 -fail_nomem_anon_vma_fork:
75465 - mpol_put(pol);
75466 -fail_nomem_policy:
75467 - kmem_cache_free(vm_area_cachep, tmp);
75468 -fail_nomem:
75469 - retval = -ENOMEM;
75470 - vm_unacct_memory(charge);
75471 - goto out;
75472 }
75473
75474 static inline int mm_alloc_pgd(struct mm_struct *mm)
75475 @@ -694,8 +737,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
75476 return ERR_PTR(err);
75477
75478 mm = get_task_mm(task);
75479 - if (mm && mm != current->mm &&
75480 - !ptrace_may_access(task, mode)) {
75481 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
75482 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
75483 mmput(mm);
75484 mm = ERR_PTR(-EACCES);
75485 }
75486 @@ -917,13 +960,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
75487 spin_unlock(&fs->lock);
75488 return -EAGAIN;
75489 }
75490 - fs->users++;
75491 + atomic_inc(&fs->users);
75492 spin_unlock(&fs->lock);
75493 return 0;
75494 }
75495 tsk->fs = copy_fs_struct(fs);
75496 if (!tsk->fs)
75497 return -ENOMEM;
75498 + /* Carry through gr_chroot_dentry and is_chrooted instead
75499 + of recomputing it here. Already copied when the task struct
75500 + is duplicated. This allows pivot_root to not be treated as
75501 + a chroot
75502 + */
75503 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
75504 +
75505 return 0;
75506 }
75507
75508 @@ -1196,6 +1246,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75509 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
75510 #endif
75511 retval = -EAGAIN;
75512 +
75513 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
75514 +
75515 if (atomic_read(&p->real_cred->user->processes) >=
75516 task_rlimit(p, RLIMIT_NPROC)) {
75517 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
75518 @@ -1435,6 +1488,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75519 goto bad_fork_free_pid;
75520 }
75521
75522 + /* synchronizes with gr_set_acls()
75523 + we need to call this past the point of no return for fork()
75524 + */
75525 + gr_copy_label(p);
75526 +
75527 if (clone_flags & CLONE_THREAD) {
75528 current->signal->nr_threads++;
75529 atomic_inc(&current->signal->live);
75530 @@ -1518,6 +1576,8 @@ bad_fork_cleanup_count:
75531 bad_fork_free:
75532 free_task(p);
75533 fork_out:
75534 + gr_log_forkfail(retval);
75535 +
75536 return ERR_PTR(retval);
75537 }
75538
75539 @@ -1568,6 +1628,23 @@ long do_fork(unsigned long clone_flags,
75540 return -EINVAL;
75541 }
75542
75543 +#ifdef CONFIG_GRKERNSEC
75544 + if (clone_flags & CLONE_NEWUSER) {
75545 + /*
75546 + * This doesn't really inspire confidence:
75547 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
75548 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
75549 + * Increases kernel attack surface in areas developers
75550 + * previously cared little about ("low importance due
75551 + * to requiring "root" capability")
75552 + * To be removed when this code receives *proper* review
75553 + */
75554 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
75555 + !capable(CAP_SETGID))
75556 + return -EPERM;
75557 + }
75558 +#endif
75559 +
75560 /*
75561 * Determine whether and which event to report to ptracer. When
75562 * called from kernel_thread or CLONE_UNTRACED is explicitly
75563 @@ -1602,6 +1679,8 @@ long do_fork(unsigned long clone_flags,
75564 if (clone_flags & CLONE_PARENT_SETTID)
75565 put_user(nr, parent_tidptr);
75566
75567 + gr_handle_brute_check();
75568 +
75569 if (clone_flags & CLONE_VFORK) {
75570 p->vfork_done = &vfork;
75571 init_completion(&vfork);
75572 @@ -1755,7 +1834,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
75573 return 0;
75574
75575 /* don't need lock here; in the worst case we'll do useless copy */
75576 - if (fs->users == 1)
75577 + if (atomic_read(&fs->users) == 1)
75578 return 0;
75579
75580 *new_fsp = copy_fs_struct(fs);
75581 @@ -1869,7 +1948,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
75582 fs = current->fs;
75583 spin_lock(&fs->lock);
75584 current->fs = new_fs;
75585 - if (--fs->users)
75586 + gr_set_chroot_entries(current, &current->fs->root);
75587 + if (atomic_dec_return(&fs->users))
75588 new_fs = NULL;
75589 else
75590 new_fs = fs;
75591 diff --git a/kernel/futex.c b/kernel/futex.c
75592 index 8879430..31696f1 100644
75593 --- a/kernel/futex.c
75594 +++ b/kernel/futex.c
75595 @@ -54,6 +54,7 @@
75596 #include <linux/mount.h>
75597 #include <linux/pagemap.h>
75598 #include <linux/syscalls.h>
75599 +#include <linux/ptrace.h>
75600 #include <linux/signal.h>
75601 #include <linux/export.h>
75602 #include <linux/magic.h>
75603 @@ -239,6 +240,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
75604 struct page *page, *page_head;
75605 int err, ro = 0;
75606
75607 +#ifdef CONFIG_PAX_SEGMEXEC
75608 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
75609 + return -EFAULT;
75610 +#endif
75611 +
75612 /*
75613 * The futex address must be "naturally" aligned.
75614 */
75615 @@ -2731,6 +2737,7 @@ static int __init futex_init(void)
75616 {
75617 u32 curval;
75618 int i;
75619 + mm_segment_t oldfs;
75620
75621 /*
75622 * This will fail and we want it. Some arch implementations do
75623 @@ -2742,8 +2749,11 @@ static int __init futex_init(void)
75624 * implementation, the non-functional ones will return
75625 * -ENOSYS.
75626 */
75627 + oldfs = get_fs();
75628 + set_fs(USER_DS);
75629 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
75630 futex_cmpxchg_enabled = 1;
75631 + set_fs(oldfs);
75632
75633 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
75634 plist_head_init(&futex_queues[i].chain);
75635 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
75636 index a9642d5..51eb98c 100644
75637 --- a/kernel/futex_compat.c
75638 +++ b/kernel/futex_compat.c
75639 @@ -31,7 +31,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
75640 return 0;
75641 }
75642
75643 -static void __user *futex_uaddr(struct robust_list __user *entry,
75644 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
75645 compat_long_t futex_offset)
75646 {
75647 compat_uptr_t base = ptr_to_compat(entry);
75648 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
75649 index 9b22d03..6295b62 100644
75650 --- a/kernel/gcov/base.c
75651 +++ b/kernel/gcov/base.c
75652 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
75653 }
75654
75655 #ifdef CONFIG_MODULES
75656 -static inline int within(void *addr, void *start, unsigned long size)
75657 -{
75658 - return ((addr >= start) && (addr < start + size));
75659 -}
75660 -
75661 /* Update list and generate events when modules are unloaded. */
75662 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75663 void *data)
75664 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75665 prev = NULL;
75666 /* Remove entries located in module from linked list. */
75667 for (info = gcov_info_head; info; info = info->next) {
75668 - if (within(info, mod->module_core, mod->core_size)) {
75669 + if (within_module_core_rw((unsigned long)info, mod)) {
75670 if (prev)
75671 prev->next = info->next;
75672 else
75673 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
75674 index cdd5607..c3fc919 100644
75675 --- a/kernel/hrtimer.c
75676 +++ b/kernel/hrtimer.c
75677 @@ -1407,7 +1407,7 @@ void hrtimer_peek_ahead_timers(void)
75678 local_irq_restore(flags);
75679 }
75680
75681 -static void run_hrtimer_softirq(struct softirq_action *h)
75682 +static void run_hrtimer_softirq(void)
75683 {
75684 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
75685
75686 @@ -1751,7 +1751,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
75687 return NOTIFY_OK;
75688 }
75689
75690 -static struct notifier_block __cpuinitdata hrtimers_nb = {
75691 +static struct notifier_block hrtimers_nb = {
75692 .notifier_call = hrtimer_cpu_notify,
75693 };
75694
75695 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
75696 index 60f48fa..7f3a770 100644
75697 --- a/kernel/jump_label.c
75698 +++ b/kernel/jump_label.c
75699 @@ -13,6 +13,7 @@
75700 #include <linux/sort.h>
75701 #include <linux/err.h>
75702 #include <linux/static_key.h>
75703 +#include <linux/mm.h>
75704
75705 #ifdef HAVE_JUMP_LABEL
75706
75707 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
75708
75709 size = (((unsigned long)stop - (unsigned long)start)
75710 / sizeof(struct jump_entry));
75711 + pax_open_kernel();
75712 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
75713 + pax_close_kernel();
75714 }
75715
75716 static void jump_label_update(struct static_key *key, int enable);
75717 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
75718 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
75719 struct jump_entry *iter;
75720
75721 + pax_open_kernel();
75722 for (iter = iter_start; iter < iter_stop; iter++) {
75723 if (within_module_init(iter->code, mod))
75724 iter->code = 0;
75725 }
75726 + pax_close_kernel();
75727 }
75728
75729 static int
75730 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
75731 index 2169fee..706ccca 100644
75732 --- a/kernel/kallsyms.c
75733 +++ b/kernel/kallsyms.c
75734 @@ -11,6 +11,9 @@
75735 * Changed the compression method from stem compression to "table lookup"
75736 * compression (see scripts/kallsyms.c for a more complete description)
75737 */
75738 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75739 +#define __INCLUDED_BY_HIDESYM 1
75740 +#endif
75741 #include <linux/kallsyms.h>
75742 #include <linux/module.h>
75743 #include <linux/init.h>
75744 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
75745
75746 static inline int is_kernel_inittext(unsigned long addr)
75747 {
75748 + if (system_state != SYSTEM_BOOTING)
75749 + return 0;
75750 +
75751 if (addr >= (unsigned long)_sinittext
75752 && addr <= (unsigned long)_einittext)
75753 return 1;
75754 return 0;
75755 }
75756
75757 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75758 +#ifdef CONFIG_MODULES
75759 +static inline int is_module_text(unsigned long addr)
75760 +{
75761 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
75762 + return 1;
75763 +
75764 + addr = ktla_ktva(addr);
75765 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
75766 +}
75767 +#else
75768 +static inline int is_module_text(unsigned long addr)
75769 +{
75770 + return 0;
75771 +}
75772 +#endif
75773 +#endif
75774 +
75775 static inline int is_kernel_text(unsigned long addr)
75776 {
75777 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
75778 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
75779
75780 static inline int is_kernel(unsigned long addr)
75781 {
75782 +
75783 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75784 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
75785 + return 1;
75786 +
75787 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
75788 +#else
75789 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
75790 +#endif
75791 +
75792 return 1;
75793 return in_gate_area_no_mm(addr);
75794 }
75795
75796 static int is_ksym_addr(unsigned long addr)
75797 {
75798 +
75799 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75800 + if (is_module_text(addr))
75801 + return 0;
75802 +#endif
75803 +
75804 if (all_var)
75805 return is_kernel(addr);
75806
75807 @@ -470,7 +509,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
75808
75809 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
75810 {
75811 - iter->name[0] = '\0';
75812 iter->nameoff = get_symbol_offset(new_pos);
75813 iter->pos = new_pos;
75814 }
75815 @@ -518,6 +556,11 @@ static int s_show(struct seq_file *m, void *p)
75816 {
75817 struct kallsym_iter *iter = m->private;
75818
75819 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75820 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
75821 + return 0;
75822 +#endif
75823 +
75824 /* Some debugging symbols have no name. Ignore them. */
75825 if (!iter->name[0])
75826 return 0;
75827 @@ -531,6 +574,7 @@ static int s_show(struct seq_file *m, void *p)
75828 */
75829 type = iter->exported ? toupper(iter->type) :
75830 tolower(iter->type);
75831 +
75832 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
75833 type, iter->name, iter->module_name);
75834 } else
75835 @@ -556,7 +600,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
75836 struct kallsym_iter *iter;
75837 int ret;
75838
75839 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
75840 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
75841 if (!iter)
75842 return -ENOMEM;
75843 reset_iter(iter, 0);
75844 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
75845 index e30ac0f..3528cac 100644
75846 --- a/kernel/kcmp.c
75847 +++ b/kernel/kcmp.c
75848 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
75849 struct task_struct *task1, *task2;
75850 int ret;
75851
75852 +#ifdef CONFIG_GRKERNSEC
75853 + return -ENOSYS;
75854 +#endif
75855 +
75856 rcu_read_lock();
75857
75858 /*
75859 diff --git a/kernel/kexec.c b/kernel/kexec.c
75860 index 5e4bd78..00c5b91 100644
75861 --- a/kernel/kexec.c
75862 +++ b/kernel/kexec.c
75863 @@ -1045,7 +1045,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
75864 unsigned long flags)
75865 {
75866 struct compat_kexec_segment in;
75867 - struct kexec_segment out, __user *ksegments;
75868 + struct kexec_segment out;
75869 + struct kexec_segment __user *ksegments;
75870 unsigned long i, result;
75871
75872 /* Don't allow clients that don't understand the native
75873 diff --git a/kernel/kmod.c b/kernel/kmod.c
75874 index 0023a87..9c0c068 100644
75875 --- a/kernel/kmod.c
75876 +++ b/kernel/kmod.c
75877 @@ -74,7 +74,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
75878 kfree(info->argv);
75879 }
75880
75881 -static int call_modprobe(char *module_name, int wait)
75882 +static int call_modprobe(char *module_name, char *module_param, int wait)
75883 {
75884 static char *envp[] = {
75885 "HOME=/",
75886 @@ -83,7 +83,7 @@ static int call_modprobe(char *module_name, int wait)
75887 NULL
75888 };
75889
75890 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
75891 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
75892 if (!argv)
75893 goto out;
75894
75895 @@ -95,7 +95,8 @@ static int call_modprobe(char *module_name, int wait)
75896 argv[1] = "-q";
75897 argv[2] = "--";
75898 argv[3] = module_name; /* check free_modprobe_argv() */
75899 - argv[4] = NULL;
75900 + argv[4] = module_param;
75901 + argv[5] = NULL;
75902
75903 return call_usermodehelper_fns(modprobe_path, argv, envp,
75904 wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
75905 @@ -120,9 +121,8 @@ out:
75906 * If module auto-loading support is disabled then this function
75907 * becomes a no-operation.
75908 */
75909 -int __request_module(bool wait, const char *fmt, ...)
75910 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
75911 {
75912 - va_list args;
75913 char module_name[MODULE_NAME_LEN];
75914 unsigned int max_modprobes;
75915 int ret;
75916 @@ -130,9 +130,7 @@ int __request_module(bool wait, const char *fmt, ...)
75917 #define MAX_KMOD_CONCURRENT 50 /* Completely arbitrary value - KAO */
75918 static int kmod_loop_msg;
75919
75920 - va_start(args, fmt);
75921 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
75922 - va_end(args);
75923 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
75924 if (ret >= MODULE_NAME_LEN)
75925 return -ENAMETOOLONG;
75926
75927 @@ -140,6 +138,20 @@ int __request_module(bool wait, const char *fmt, ...)
75928 if (ret)
75929 return ret;
75930
75931 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75932 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75933 + /* hack to workaround consolekit/udisks stupidity */
75934 + read_lock(&tasklist_lock);
75935 + if (!strcmp(current->comm, "mount") &&
75936 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
75937 + read_unlock(&tasklist_lock);
75938 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
75939 + return -EPERM;
75940 + }
75941 + read_unlock(&tasklist_lock);
75942 + }
75943 +#endif
75944 +
75945 /* If modprobe needs a service that is in a module, we get a recursive
75946 * loop. Limit the number of running kmod threads to max_threads/2 or
75947 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
75948 @@ -168,11 +180,52 @@ int __request_module(bool wait, const char *fmt, ...)
75949
75950 trace_module_request(module_name, wait, _RET_IP_);
75951
75952 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75953 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75954
75955 atomic_dec(&kmod_concurrent);
75956 return ret;
75957 }
75958 +
75959 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
75960 +{
75961 + va_list args;
75962 + int ret;
75963 +
75964 + va_start(args, fmt);
75965 + ret = ____request_module(wait, module_param, fmt, args);
75966 + va_end(args);
75967 +
75968 + return ret;
75969 +}
75970 +
75971 +int __request_module(bool wait, const char *fmt, ...)
75972 +{
75973 + va_list args;
75974 + int ret;
75975 +
75976 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75977 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75978 + char module_param[MODULE_NAME_LEN];
75979 +
75980 + memset(module_param, 0, sizeof(module_param));
75981 +
75982 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
75983 +
75984 + va_start(args, fmt);
75985 + ret = ____request_module(wait, module_param, fmt, args);
75986 + va_end(args);
75987 +
75988 + return ret;
75989 + }
75990 +#endif
75991 +
75992 + va_start(args, fmt);
75993 + ret = ____request_module(wait, NULL, fmt, args);
75994 + va_end(args);
75995 +
75996 + return ret;
75997 +}
75998 +
75999 EXPORT_SYMBOL(__request_module);
76000 #endif /* CONFIG_MODULES */
76001
76002 @@ -283,7 +336,7 @@ static int wait_for_helper(void *data)
76003 *
76004 * Thus the __user pointer cast is valid here.
76005 */
76006 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
76007 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
76008
76009 /*
76010 * If ret is 0, either ____call_usermodehelper failed and the
76011 @@ -635,7 +688,7 @@ EXPORT_SYMBOL(call_usermodehelper_fns);
76012 static int proc_cap_handler(struct ctl_table *table, int write,
76013 void __user *buffer, size_t *lenp, loff_t *ppos)
76014 {
76015 - struct ctl_table t;
76016 + ctl_table_no_const t;
76017 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
76018 kernel_cap_t new_cap;
76019 int err, i;
76020 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
76021 index 098f396..fe85ff1 100644
76022 --- a/kernel/kprobes.c
76023 +++ b/kernel/kprobes.c
76024 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
76025 * kernel image and loaded module images reside. This is required
76026 * so x86_64 can correctly handle the %rip-relative fixups.
76027 */
76028 - kip->insns = module_alloc(PAGE_SIZE);
76029 + kip->insns = module_alloc_exec(PAGE_SIZE);
76030 if (!kip->insns) {
76031 kfree(kip);
76032 return NULL;
76033 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
76034 */
76035 if (!list_is_singular(&kip->list)) {
76036 list_del(&kip->list);
76037 - module_free(NULL, kip->insns);
76038 + module_free_exec(NULL, kip->insns);
76039 kfree(kip);
76040 }
76041 return 1;
76042 @@ -2063,7 +2063,7 @@ static int __init init_kprobes(void)
76043 {
76044 int i, err = 0;
76045 unsigned long offset = 0, size = 0;
76046 - char *modname, namebuf[128];
76047 + char *modname, namebuf[KSYM_NAME_LEN];
76048 const char *symbol_name;
76049 void *addr;
76050 struct kprobe_blackpoint *kb;
76051 @@ -2148,11 +2148,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
76052 kprobe_type = "k";
76053
76054 if (sym)
76055 - seq_printf(pi, "%p %s %s+0x%x %s ",
76056 + seq_printf(pi, "%pK %s %s+0x%x %s ",
76057 p->addr, kprobe_type, sym, offset,
76058 (modname ? modname : " "));
76059 else
76060 - seq_printf(pi, "%p %s %p ",
76061 + seq_printf(pi, "%pK %s %pK ",
76062 p->addr, kprobe_type, p->addr);
76063
76064 if (!pp)
76065 @@ -2190,7 +2190,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
76066 const char *sym = NULL;
76067 unsigned int i = *(loff_t *) v;
76068 unsigned long offset = 0;
76069 - char *modname, namebuf[128];
76070 + char *modname, namebuf[KSYM_NAME_LEN];
76071
76072 head = &kprobe_table[i];
76073 preempt_disable();
76074 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
76075 index 6ada93c..dce7d5d 100644
76076 --- a/kernel/ksysfs.c
76077 +++ b/kernel/ksysfs.c
76078 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
76079 {
76080 if (count+1 > UEVENT_HELPER_PATH_LEN)
76081 return -ENOENT;
76082 + if (!capable(CAP_SYS_ADMIN))
76083 + return -EPERM;
76084 memcpy(uevent_helper, buf, count);
76085 uevent_helper[count] = '\0';
76086 if (count && uevent_helper[count-1] == '\n')
76087 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
76088 return count;
76089 }
76090
76091 -static struct bin_attribute notes_attr = {
76092 +static bin_attribute_no_const notes_attr __read_only = {
76093 .attr = {
76094 .name = "notes",
76095 .mode = S_IRUGO,
76096 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
76097 index 7981e5b..7f2105c 100644
76098 --- a/kernel/lockdep.c
76099 +++ b/kernel/lockdep.c
76100 @@ -590,6 +590,10 @@ static int static_obj(void *obj)
76101 end = (unsigned long) &_end,
76102 addr = (unsigned long) obj;
76103
76104 +#ifdef CONFIG_PAX_KERNEXEC
76105 + start = ktla_ktva(start);
76106 +#endif
76107 +
76108 /*
76109 * static variable?
76110 */
76111 @@ -730,6 +734,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
76112 if (!static_obj(lock->key)) {
76113 debug_locks_off();
76114 printk("INFO: trying to register non-static key.\n");
76115 + printk("lock:%pS key:%pS.\n", lock, lock->key);
76116 printk("the code is fine but needs lockdep annotation.\n");
76117 printk("turning off the locking correctness validator.\n");
76118 dump_stack();
76119 @@ -3078,7 +3083,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
76120 if (!class)
76121 return 0;
76122 }
76123 - atomic_inc((atomic_t *)&class->ops);
76124 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
76125 if (very_verbose(class)) {
76126 printk("\nacquire class [%p] %s", class->key, class->name);
76127 if (class->name_version > 1)
76128 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
76129 index b2c71c5..7b88d63 100644
76130 --- a/kernel/lockdep_proc.c
76131 +++ b/kernel/lockdep_proc.c
76132 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
76133 return 0;
76134 }
76135
76136 - seq_printf(m, "%p", class->key);
76137 + seq_printf(m, "%pK", class->key);
76138 #ifdef CONFIG_DEBUG_LOCKDEP
76139 seq_printf(m, " OPS:%8ld", class->ops);
76140 #endif
76141 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
76142
76143 list_for_each_entry(entry, &class->locks_after, entry) {
76144 if (entry->distance == 1) {
76145 - seq_printf(m, " -> [%p] ", entry->class->key);
76146 + seq_printf(m, " -> [%pK] ", entry->class->key);
76147 print_name(m, entry->class);
76148 seq_puts(m, "\n");
76149 }
76150 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
76151 if (!class->key)
76152 continue;
76153
76154 - seq_printf(m, "[%p] ", class->key);
76155 + seq_printf(m, "[%pK] ", class->key);
76156 print_name(m, class);
76157 seq_puts(m, "\n");
76158 }
76159 @@ -495,7 +495,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->contention_point[i]);
76166 seq_printf(m, "%40s %14lu %29s %pS\n",
76167 name, stats->contention_point[i],
76168 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76169 if (!i)
76170 seq_line(m, '-', 40-namelen, namelen);
76171
76172 - snprintf(ip, sizeof(ip), "[<%p>]",
76173 + snprintf(ip, sizeof(ip), "[<%pK>]",
76174 (void *)class->contending_point[i]);
76175 seq_printf(m, "%40s %14lu %29s %pS\n",
76176 name, stats->contending_point[i],
76177 diff --git a/kernel/module.c b/kernel/module.c
76178 index eab0827..f488603 100644
76179 --- a/kernel/module.c
76180 +++ b/kernel/module.c
76181 @@ -61,6 +61,7 @@
76182 #include <linux/pfn.h>
76183 #include <linux/bsearch.h>
76184 #include <linux/fips.h>
76185 +#include <linux/grsecurity.h>
76186 #include <uapi/linux/module.h>
76187 #include "module-internal.h"
76188
76189 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
76190
76191 /* Bounds of module allocation, for speeding __module_address.
76192 * Protected by module_mutex. */
76193 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
76194 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
76195 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
76196
76197 int register_module_notifier(struct notifier_block * nb)
76198 {
76199 @@ -322,7 +324,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76200 return true;
76201
76202 list_for_each_entry_rcu(mod, &modules, list) {
76203 - struct symsearch arr[] = {
76204 + struct symsearch modarr[] = {
76205 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
76206 NOT_GPL_ONLY, false },
76207 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
76208 @@ -347,7 +349,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76209 if (mod->state == MODULE_STATE_UNFORMED)
76210 continue;
76211
76212 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
76213 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
76214 return true;
76215 }
76216 return false;
76217 @@ -484,7 +486,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
76218 static int percpu_modalloc(struct module *mod,
76219 unsigned long size, unsigned long align)
76220 {
76221 - if (align > PAGE_SIZE) {
76222 + if (align-1 >= PAGE_SIZE) {
76223 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
76224 mod->name, align, PAGE_SIZE);
76225 align = PAGE_SIZE;
76226 @@ -1088,7 +1090,7 @@ struct module_attribute module_uevent =
76227 static ssize_t show_coresize(struct module_attribute *mattr,
76228 struct module_kobject *mk, char *buffer)
76229 {
76230 - return sprintf(buffer, "%u\n", mk->mod->core_size);
76231 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
76232 }
76233
76234 static struct module_attribute modinfo_coresize =
76235 @@ -1097,7 +1099,7 @@ static struct module_attribute modinfo_coresize =
76236 static ssize_t show_initsize(struct module_attribute *mattr,
76237 struct module_kobject *mk, char *buffer)
76238 {
76239 - return sprintf(buffer, "%u\n", mk->mod->init_size);
76240 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
76241 }
76242
76243 static struct module_attribute modinfo_initsize =
76244 @@ -1311,7 +1313,7 @@ resolve_symbol_wait(struct module *mod,
76245 */
76246 #ifdef CONFIG_SYSFS
76247
76248 -#ifdef CONFIG_KALLSYMS
76249 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
76250 static inline bool sect_empty(const Elf_Shdr *sect)
76251 {
76252 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
76253 @@ -1451,7 +1453,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
76254 {
76255 unsigned int notes, loaded, i;
76256 struct module_notes_attrs *notes_attrs;
76257 - struct bin_attribute *nattr;
76258 + bin_attribute_no_const *nattr;
76259
76260 /* failed to create section attributes, so can't create notes */
76261 if (!mod->sect_attrs)
76262 @@ -1563,7 +1565,7 @@ static void del_usage_links(struct module *mod)
76263 static int module_add_modinfo_attrs(struct module *mod)
76264 {
76265 struct module_attribute *attr;
76266 - struct module_attribute *temp_attr;
76267 + module_attribute_no_const *temp_attr;
76268 int error = 0;
76269 int i;
76270
76271 @@ -1777,21 +1779,21 @@ static void set_section_ro_nx(void *base,
76272
76273 static void unset_module_core_ro_nx(struct module *mod)
76274 {
76275 - set_page_attributes(mod->module_core + mod->core_text_size,
76276 - mod->module_core + mod->core_size,
76277 + set_page_attributes(mod->module_core_rw,
76278 + mod->module_core_rw + mod->core_size_rw,
76279 set_memory_x);
76280 - set_page_attributes(mod->module_core,
76281 - mod->module_core + mod->core_ro_size,
76282 + set_page_attributes(mod->module_core_rx,
76283 + mod->module_core_rx + mod->core_size_rx,
76284 set_memory_rw);
76285 }
76286
76287 static void unset_module_init_ro_nx(struct module *mod)
76288 {
76289 - set_page_attributes(mod->module_init + mod->init_text_size,
76290 - mod->module_init + mod->init_size,
76291 + set_page_attributes(mod->module_init_rw,
76292 + mod->module_init_rw + mod->init_size_rw,
76293 set_memory_x);
76294 - set_page_attributes(mod->module_init,
76295 - mod->module_init + mod->init_ro_size,
76296 + set_page_attributes(mod->module_init_rx,
76297 + mod->module_init_rx + mod->init_size_rx,
76298 set_memory_rw);
76299 }
76300
76301 @@ -1804,14 +1806,14 @@ void set_all_modules_text_rw(void)
76302 list_for_each_entry_rcu(mod, &modules, list) {
76303 if (mod->state == MODULE_STATE_UNFORMED)
76304 continue;
76305 - if ((mod->module_core) && (mod->core_text_size)) {
76306 - set_page_attributes(mod->module_core,
76307 - mod->module_core + mod->core_text_size,
76308 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76309 + set_page_attributes(mod->module_core_rx,
76310 + mod->module_core_rx + mod->core_size_rx,
76311 set_memory_rw);
76312 }
76313 - if ((mod->module_init) && (mod->init_text_size)) {
76314 - set_page_attributes(mod->module_init,
76315 - mod->module_init + mod->init_text_size,
76316 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76317 + set_page_attributes(mod->module_init_rx,
76318 + mod->module_init_rx + mod->init_size_rx,
76319 set_memory_rw);
76320 }
76321 }
76322 @@ -1827,14 +1829,14 @@ void set_all_modules_text_ro(void)
76323 list_for_each_entry_rcu(mod, &modules, list) {
76324 if (mod->state == MODULE_STATE_UNFORMED)
76325 continue;
76326 - if ((mod->module_core) && (mod->core_text_size)) {
76327 - set_page_attributes(mod->module_core,
76328 - mod->module_core + mod->core_text_size,
76329 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76330 + set_page_attributes(mod->module_core_rx,
76331 + mod->module_core_rx + mod->core_size_rx,
76332 set_memory_ro);
76333 }
76334 - if ((mod->module_init) && (mod->init_text_size)) {
76335 - set_page_attributes(mod->module_init,
76336 - mod->module_init + mod->init_text_size,
76337 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76338 + set_page_attributes(mod->module_init_rx,
76339 + mod->module_init_rx + mod->init_size_rx,
76340 set_memory_ro);
76341 }
76342 }
76343 @@ -1880,16 +1882,19 @@ static void free_module(struct module *mod)
76344
76345 /* This may be NULL, but that's OK */
76346 unset_module_init_ro_nx(mod);
76347 - module_free(mod, mod->module_init);
76348 + module_free(mod, mod->module_init_rw);
76349 + module_free_exec(mod, mod->module_init_rx);
76350 kfree(mod->args);
76351 percpu_modfree(mod);
76352
76353 /* Free lock-classes: */
76354 - lockdep_free_key_range(mod->module_core, mod->core_size);
76355 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
76356 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
76357
76358 /* Finally, free the core (containing the module structure) */
76359 unset_module_core_ro_nx(mod);
76360 - module_free(mod, mod->module_core);
76361 + module_free_exec(mod, mod->module_core_rx);
76362 + module_free(mod, mod->module_core_rw);
76363
76364 #ifdef CONFIG_MPU
76365 update_protections(current->mm);
76366 @@ -1959,9 +1964,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76367 int ret = 0;
76368 const struct kernel_symbol *ksym;
76369
76370 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76371 + int is_fs_load = 0;
76372 + int register_filesystem_found = 0;
76373 + char *p;
76374 +
76375 + p = strstr(mod->args, "grsec_modharden_fs");
76376 + if (p) {
76377 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
76378 + /* copy \0 as well */
76379 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
76380 + is_fs_load = 1;
76381 + }
76382 +#endif
76383 +
76384 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
76385 const char *name = info->strtab + sym[i].st_name;
76386
76387 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76388 + /* it's a real shame this will never get ripped and copied
76389 + upstream! ;(
76390 + */
76391 + if (is_fs_load && !strcmp(name, "register_filesystem"))
76392 + register_filesystem_found = 1;
76393 +#endif
76394 +
76395 switch (sym[i].st_shndx) {
76396 case SHN_COMMON:
76397 /* We compiled with -fno-common. These are not
76398 @@ -1982,7 +2009,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76399 ksym = resolve_symbol_wait(mod, info, name);
76400 /* Ok if resolved. */
76401 if (ksym && !IS_ERR(ksym)) {
76402 + pax_open_kernel();
76403 sym[i].st_value = ksym->value;
76404 + pax_close_kernel();
76405 break;
76406 }
76407
76408 @@ -2001,11 +2030,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76409 secbase = (unsigned long)mod_percpu(mod);
76410 else
76411 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
76412 + pax_open_kernel();
76413 sym[i].st_value += secbase;
76414 + pax_close_kernel();
76415 break;
76416 }
76417 }
76418
76419 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76420 + if (is_fs_load && !register_filesystem_found) {
76421 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
76422 + ret = -EPERM;
76423 + }
76424 +#endif
76425 +
76426 return ret;
76427 }
76428
76429 @@ -2089,22 +2127,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
76430 || s->sh_entsize != ~0UL
76431 || strstarts(sname, ".init"))
76432 continue;
76433 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
76434 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76435 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
76436 + else
76437 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
76438 pr_debug("\t%s\n", sname);
76439 }
76440 - switch (m) {
76441 - case 0: /* executable */
76442 - mod->core_size = debug_align(mod->core_size);
76443 - mod->core_text_size = mod->core_size;
76444 - break;
76445 - case 1: /* RO: text and ro-data */
76446 - mod->core_size = debug_align(mod->core_size);
76447 - mod->core_ro_size = mod->core_size;
76448 - break;
76449 - case 3: /* whole core */
76450 - mod->core_size = debug_align(mod->core_size);
76451 - break;
76452 - }
76453 }
76454
76455 pr_debug("Init section allocation order:\n");
76456 @@ -2118,23 +2146,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
76457 || s->sh_entsize != ~0UL
76458 || !strstarts(sname, ".init"))
76459 continue;
76460 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
76461 - | INIT_OFFSET_MASK);
76462 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76463 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
76464 + else
76465 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
76466 + s->sh_entsize |= INIT_OFFSET_MASK;
76467 pr_debug("\t%s\n", sname);
76468 }
76469 - switch (m) {
76470 - case 0: /* executable */
76471 - mod->init_size = debug_align(mod->init_size);
76472 - mod->init_text_size = mod->init_size;
76473 - break;
76474 - case 1: /* RO: text and ro-data */
76475 - mod->init_size = debug_align(mod->init_size);
76476 - mod->init_ro_size = mod->init_size;
76477 - break;
76478 - case 3: /* whole init */
76479 - mod->init_size = debug_align(mod->init_size);
76480 - break;
76481 - }
76482 }
76483 }
76484
76485 @@ -2306,7 +2324,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76486
76487 /* Put symbol section at end of init part of module. */
76488 symsect->sh_flags |= SHF_ALLOC;
76489 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
76490 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
76491 info->index.sym) | INIT_OFFSET_MASK;
76492 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
76493
76494 @@ -2323,13 +2341,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76495 }
76496
76497 /* Append room for core symbols at end of core part. */
76498 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
76499 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
76500 - mod->core_size += strtab_size;
76501 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
76502 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
76503 + mod->core_size_rx += strtab_size;
76504
76505 /* Put string table section at end of init part of module. */
76506 strsect->sh_flags |= SHF_ALLOC;
76507 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
76508 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
76509 info->index.str) | INIT_OFFSET_MASK;
76510 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
76511 }
76512 @@ -2347,12 +2365,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76513 /* Make sure we get permanent strtab: don't use info->strtab. */
76514 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
76515
76516 + pax_open_kernel();
76517 +
76518 /* Set types up while we still have access to sections. */
76519 for (i = 0; i < mod->num_symtab; i++)
76520 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
76521
76522 - mod->core_symtab = dst = mod->module_core + info->symoffs;
76523 - mod->core_strtab = s = mod->module_core + info->stroffs;
76524 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
76525 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
76526 src = mod->symtab;
76527 for (ndst = i = 0; i < mod->num_symtab; i++) {
76528 if (i == 0 ||
76529 @@ -2364,6 +2384,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76530 }
76531 }
76532 mod->core_num_syms = ndst;
76533 +
76534 + pax_close_kernel();
76535 }
76536 #else
76537 static inline void layout_symtab(struct module *mod, struct load_info *info)
76538 @@ -2397,17 +2419,33 @@ void * __weak module_alloc(unsigned long size)
76539 return vmalloc_exec(size);
76540 }
76541
76542 -static void *module_alloc_update_bounds(unsigned long size)
76543 +static void *module_alloc_update_bounds_rw(unsigned long size)
76544 {
76545 void *ret = module_alloc(size);
76546
76547 if (ret) {
76548 mutex_lock(&module_mutex);
76549 /* Update module bounds. */
76550 - if ((unsigned long)ret < module_addr_min)
76551 - module_addr_min = (unsigned long)ret;
76552 - if ((unsigned long)ret + size > module_addr_max)
76553 - module_addr_max = (unsigned long)ret + size;
76554 + if ((unsigned long)ret < module_addr_min_rw)
76555 + module_addr_min_rw = (unsigned long)ret;
76556 + if ((unsigned long)ret + size > module_addr_max_rw)
76557 + module_addr_max_rw = (unsigned long)ret + size;
76558 + mutex_unlock(&module_mutex);
76559 + }
76560 + return ret;
76561 +}
76562 +
76563 +static void *module_alloc_update_bounds_rx(unsigned long size)
76564 +{
76565 + void *ret = module_alloc_exec(size);
76566 +
76567 + if (ret) {
76568 + mutex_lock(&module_mutex);
76569 + /* Update module bounds. */
76570 + if ((unsigned long)ret < module_addr_min_rx)
76571 + module_addr_min_rx = (unsigned long)ret;
76572 + if ((unsigned long)ret + size > module_addr_max_rx)
76573 + module_addr_max_rx = (unsigned long)ret + size;
76574 mutex_unlock(&module_mutex);
76575 }
76576 return ret;
76577 @@ -2683,8 +2721,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
76578 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76579 {
76580 const char *modmagic = get_modinfo(info, "vermagic");
76581 + const char *license = get_modinfo(info, "license");
76582 int err;
76583
76584 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
76585 + if (!license || !license_is_gpl_compatible(license))
76586 + return -ENOEXEC;
76587 +#endif
76588 +
76589 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
76590 modmagic = NULL;
76591
76592 @@ -2710,7 +2754,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76593 }
76594
76595 /* Set up license info based on the info section */
76596 - set_license(mod, get_modinfo(info, "license"));
76597 + set_license(mod, license);
76598
76599 return 0;
76600 }
76601 @@ -2804,7 +2848,7 @@ static int move_module(struct module *mod, struct load_info *info)
76602 void *ptr;
76603
76604 /* Do the allocs. */
76605 - ptr = module_alloc_update_bounds(mod->core_size);
76606 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
76607 /*
76608 * The pointer to this block is stored in the module structure
76609 * which is inside the block. Just mark it as not being a
76610 @@ -2814,11 +2858,11 @@ static int move_module(struct module *mod, struct load_info *info)
76611 if (!ptr)
76612 return -ENOMEM;
76613
76614 - memset(ptr, 0, mod->core_size);
76615 - mod->module_core = ptr;
76616 + memset(ptr, 0, mod->core_size_rw);
76617 + mod->module_core_rw = ptr;
76618
76619 - if (mod->init_size) {
76620 - ptr = module_alloc_update_bounds(mod->init_size);
76621 + if (mod->init_size_rw) {
76622 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
76623 /*
76624 * The pointer to this block is stored in the module structure
76625 * which is inside the block. This block doesn't need to be
76626 @@ -2827,13 +2871,45 @@ static int move_module(struct module *mod, struct load_info *info)
76627 */
76628 kmemleak_ignore(ptr);
76629 if (!ptr) {
76630 - module_free(mod, mod->module_core);
76631 + module_free(mod, mod->module_core_rw);
76632 return -ENOMEM;
76633 }
76634 - memset(ptr, 0, mod->init_size);
76635 - mod->module_init = ptr;
76636 + memset(ptr, 0, mod->init_size_rw);
76637 + mod->module_init_rw = ptr;
76638 } else
76639 - mod->module_init = NULL;
76640 + mod->module_init_rw = NULL;
76641 +
76642 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
76643 + kmemleak_not_leak(ptr);
76644 + if (!ptr) {
76645 + if (mod->module_init_rw)
76646 + module_free(mod, mod->module_init_rw);
76647 + module_free(mod, mod->module_core_rw);
76648 + return -ENOMEM;
76649 + }
76650 +
76651 + pax_open_kernel();
76652 + memset(ptr, 0, mod->core_size_rx);
76653 + pax_close_kernel();
76654 + mod->module_core_rx = ptr;
76655 +
76656 + if (mod->init_size_rx) {
76657 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
76658 + kmemleak_ignore(ptr);
76659 + if (!ptr && mod->init_size_rx) {
76660 + module_free_exec(mod, mod->module_core_rx);
76661 + if (mod->module_init_rw)
76662 + module_free(mod, mod->module_init_rw);
76663 + module_free(mod, mod->module_core_rw);
76664 + return -ENOMEM;
76665 + }
76666 +
76667 + pax_open_kernel();
76668 + memset(ptr, 0, mod->init_size_rx);
76669 + pax_close_kernel();
76670 + mod->module_init_rx = ptr;
76671 + } else
76672 + mod->module_init_rx = NULL;
76673
76674 /* Transfer each section which specifies SHF_ALLOC */
76675 pr_debug("final section addresses:\n");
76676 @@ -2844,16 +2920,45 @@ static int move_module(struct module *mod, struct load_info *info)
76677 if (!(shdr->sh_flags & SHF_ALLOC))
76678 continue;
76679
76680 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
76681 - dest = mod->module_init
76682 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76683 - else
76684 - dest = mod->module_core + shdr->sh_entsize;
76685 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
76686 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76687 + dest = mod->module_init_rw
76688 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76689 + else
76690 + dest = mod->module_init_rx
76691 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76692 + } else {
76693 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76694 + dest = mod->module_core_rw + shdr->sh_entsize;
76695 + else
76696 + dest = mod->module_core_rx + shdr->sh_entsize;
76697 + }
76698 +
76699 + if (shdr->sh_type != SHT_NOBITS) {
76700 +
76701 +#ifdef CONFIG_PAX_KERNEXEC
76702 +#ifdef CONFIG_X86_64
76703 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
76704 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
76705 +#endif
76706 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
76707 + pax_open_kernel();
76708 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76709 + pax_close_kernel();
76710 + } else
76711 +#endif
76712
76713 - if (shdr->sh_type != SHT_NOBITS)
76714 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76715 + }
76716 /* Update sh_addr to point to copy in image. */
76717 - shdr->sh_addr = (unsigned long)dest;
76718 +
76719 +#ifdef CONFIG_PAX_KERNEXEC
76720 + if (shdr->sh_flags & SHF_EXECINSTR)
76721 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
76722 + else
76723 +#endif
76724 +
76725 + shdr->sh_addr = (unsigned long)dest;
76726 pr_debug("\t0x%lx %s\n",
76727 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
76728 }
76729 @@ -2908,12 +3013,12 @@ static void flush_module_icache(const struct module *mod)
76730 * Do it before processing of module parameters, so the module
76731 * can provide parameter accessor functions of its own.
76732 */
76733 - if (mod->module_init)
76734 - flush_icache_range((unsigned long)mod->module_init,
76735 - (unsigned long)mod->module_init
76736 - + mod->init_size);
76737 - flush_icache_range((unsigned long)mod->module_core,
76738 - (unsigned long)mod->module_core + mod->core_size);
76739 + if (mod->module_init_rx)
76740 + flush_icache_range((unsigned long)mod->module_init_rx,
76741 + (unsigned long)mod->module_init_rx
76742 + + mod->init_size_rx);
76743 + flush_icache_range((unsigned long)mod->module_core_rx,
76744 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
76745
76746 set_fs(old_fs);
76747 }
76748 @@ -2983,8 +3088,10 @@ out:
76749 static void module_deallocate(struct module *mod, struct load_info *info)
76750 {
76751 percpu_modfree(mod);
76752 - module_free(mod, mod->module_init);
76753 - module_free(mod, mod->module_core);
76754 + module_free_exec(mod, mod->module_init_rx);
76755 + module_free_exec(mod, mod->module_core_rx);
76756 + module_free(mod, mod->module_init_rw);
76757 + module_free(mod, mod->module_core_rw);
76758 }
76759
76760 int __weak module_finalize(const Elf_Ehdr *hdr,
76761 @@ -2997,7 +3104,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
76762 static int post_relocation(struct module *mod, const struct load_info *info)
76763 {
76764 /* Sort exception table now relocations are done. */
76765 + pax_open_kernel();
76766 sort_extable(mod->extable, mod->extable + mod->num_exentries);
76767 + pax_close_kernel();
76768
76769 /* Copy relocated percpu area over. */
76770 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
76771 @@ -3051,16 +3160,16 @@ static int do_init_module(struct module *mod)
76772 MODULE_STATE_COMING, mod);
76773
76774 /* Set RO and NX regions for core */
76775 - set_section_ro_nx(mod->module_core,
76776 - mod->core_text_size,
76777 - mod->core_ro_size,
76778 - mod->core_size);
76779 + set_section_ro_nx(mod->module_core_rx,
76780 + mod->core_size_rx,
76781 + mod->core_size_rx,
76782 + mod->core_size_rx);
76783
76784 /* Set RO and NX regions for init */
76785 - set_section_ro_nx(mod->module_init,
76786 - mod->init_text_size,
76787 - mod->init_ro_size,
76788 - mod->init_size);
76789 + set_section_ro_nx(mod->module_init_rx,
76790 + mod->init_size_rx,
76791 + mod->init_size_rx,
76792 + mod->init_size_rx);
76793
76794 do_mod_ctors(mod);
76795 /* Start the module */
76796 @@ -3122,11 +3231,12 @@ static int do_init_module(struct module *mod)
76797 mod->strtab = mod->core_strtab;
76798 #endif
76799 unset_module_init_ro_nx(mod);
76800 - module_free(mod, mod->module_init);
76801 - mod->module_init = NULL;
76802 - mod->init_size = 0;
76803 - mod->init_ro_size = 0;
76804 - mod->init_text_size = 0;
76805 + module_free(mod, mod->module_init_rw);
76806 + module_free_exec(mod, mod->module_init_rx);
76807 + mod->module_init_rw = NULL;
76808 + mod->module_init_rx = NULL;
76809 + mod->init_size_rw = 0;
76810 + mod->init_size_rx = 0;
76811 mutex_unlock(&module_mutex);
76812 wake_up_all(&module_wq);
76813
76814 @@ -3209,9 +3319,38 @@ again:
76815 if (err)
76816 goto free_unload;
76817
76818 + /* Now copy in args */
76819 + mod->args = strndup_user(uargs, ~0UL >> 1);
76820 + if (IS_ERR(mod->args)) {
76821 + err = PTR_ERR(mod->args);
76822 + goto free_unload;
76823 + }
76824 +
76825 /* Set up MODINFO_ATTR fields */
76826 setup_modinfo(mod, info);
76827
76828 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76829 + {
76830 + char *p, *p2;
76831 +
76832 + if (strstr(mod->args, "grsec_modharden_netdev")) {
76833 + 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);
76834 + err = -EPERM;
76835 + goto free_modinfo;
76836 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
76837 + p += sizeof("grsec_modharden_normal") - 1;
76838 + p2 = strstr(p, "_");
76839 + if (p2) {
76840 + *p2 = '\0';
76841 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
76842 + *p2 = '_';
76843 + }
76844 + err = -EPERM;
76845 + goto free_modinfo;
76846 + }
76847 + }
76848 +#endif
76849 +
76850 /* Fix up syms, so that st_value is a pointer to location. */
76851 err = simplify_symbols(mod, info);
76852 if (err < 0)
76853 @@ -3227,13 +3366,6 @@ again:
76854
76855 flush_module_icache(mod);
76856
76857 - /* Now copy in args */
76858 - mod->args = strndup_user(uargs, ~0UL >> 1);
76859 - if (IS_ERR(mod->args)) {
76860 - err = PTR_ERR(mod->args);
76861 - goto free_arch_cleanup;
76862 - }
76863 -
76864 dynamic_debug_setup(info->debug, info->num_debug);
76865
76866 mutex_lock(&module_mutex);
76867 @@ -3278,11 +3410,10 @@ again:
76868 mutex_unlock(&module_mutex);
76869 dynamic_debug_remove(info->debug);
76870 synchronize_sched();
76871 - kfree(mod->args);
76872 - free_arch_cleanup:
76873 module_arch_cleanup(mod);
76874 free_modinfo:
76875 free_modinfo(mod);
76876 + kfree(mod->args);
76877 free_unload:
76878 module_unload_free(mod);
76879 unlink_mod:
76880 @@ -3365,10 +3496,16 @@ static const char *get_ksymbol(struct module *mod,
76881 unsigned long nextval;
76882
76883 /* At worse, next value is at end of module */
76884 - if (within_module_init(addr, mod))
76885 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
76886 + if (within_module_init_rx(addr, mod))
76887 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
76888 + else if (within_module_init_rw(addr, mod))
76889 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
76890 + else if (within_module_core_rx(addr, mod))
76891 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
76892 + else if (within_module_core_rw(addr, mod))
76893 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
76894 else
76895 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
76896 + return NULL;
76897
76898 /* Scan for closest preceding symbol, and next symbol. (ELF
76899 starts real symbols at 1). */
76900 @@ -3621,7 +3758,7 @@ static int m_show(struct seq_file *m, void *p)
76901 return 0;
76902
76903 seq_printf(m, "%s %u",
76904 - mod->name, mod->init_size + mod->core_size);
76905 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
76906 print_unload_info(m, mod);
76907
76908 /* Informative for users. */
76909 @@ -3630,7 +3767,7 @@ static int m_show(struct seq_file *m, void *p)
76910 mod->state == MODULE_STATE_COMING ? "Loading":
76911 "Live");
76912 /* Used by oprofile and other similar tools. */
76913 - seq_printf(m, " 0x%pK", mod->module_core);
76914 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
76915
76916 /* Taints info */
76917 if (mod->taints)
76918 @@ -3666,7 +3803,17 @@ static const struct file_operations proc_modules_operations = {
76919
76920 static int __init proc_modules_init(void)
76921 {
76922 +#ifndef CONFIG_GRKERNSEC_HIDESYM
76923 +#ifdef CONFIG_GRKERNSEC_PROC_USER
76924 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76925 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76926 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
76927 +#else
76928 proc_create("modules", 0, NULL, &proc_modules_operations);
76929 +#endif
76930 +#else
76931 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76932 +#endif
76933 return 0;
76934 }
76935 module_init(proc_modules_init);
76936 @@ -3727,14 +3874,14 @@ struct module *__module_address(unsigned long addr)
76937 {
76938 struct module *mod;
76939
76940 - if (addr < module_addr_min || addr > module_addr_max)
76941 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
76942 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
76943 return NULL;
76944
76945 list_for_each_entry_rcu(mod, &modules, list) {
76946 if (mod->state == MODULE_STATE_UNFORMED)
76947 continue;
76948 - if (within_module_core(addr, mod)
76949 - || within_module_init(addr, mod))
76950 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
76951 return mod;
76952 }
76953 return NULL;
76954 @@ -3769,11 +3916,20 @@ bool is_module_text_address(unsigned long addr)
76955 */
76956 struct module *__module_text_address(unsigned long addr)
76957 {
76958 - struct module *mod = __module_address(addr);
76959 + struct module *mod;
76960 +
76961 +#ifdef CONFIG_X86_32
76962 + addr = ktla_ktva(addr);
76963 +#endif
76964 +
76965 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
76966 + return NULL;
76967 +
76968 + mod = __module_address(addr);
76969 +
76970 if (mod) {
76971 /* Make sure it's within the text section. */
76972 - if (!within(addr, mod->module_init, mod->init_text_size)
76973 - && !within(addr, mod->module_core, mod->core_text_size))
76974 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
76975 mod = NULL;
76976 }
76977 return mod;
76978 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
76979 index 7e3443f..b2a1e6b 100644
76980 --- a/kernel/mutex-debug.c
76981 +++ b/kernel/mutex-debug.c
76982 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
76983 }
76984
76985 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76986 - struct thread_info *ti)
76987 + struct task_struct *task)
76988 {
76989 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
76990
76991 /* Mark the current thread as blocked on the lock: */
76992 - ti->task->blocked_on = waiter;
76993 + task->blocked_on = waiter;
76994 }
76995
76996 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76997 - struct thread_info *ti)
76998 + struct task_struct *task)
76999 {
77000 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
77001 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
77002 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
77003 - ti->task->blocked_on = NULL;
77004 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
77005 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
77006 + task->blocked_on = NULL;
77007
77008 list_del_init(&waiter->list);
77009 waiter->task = NULL;
77010 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
77011 index 0799fd3..d06ae3b 100644
77012 --- a/kernel/mutex-debug.h
77013 +++ b/kernel/mutex-debug.h
77014 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
77015 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
77016 extern void debug_mutex_add_waiter(struct mutex *lock,
77017 struct mutex_waiter *waiter,
77018 - struct thread_info *ti);
77019 + struct task_struct *task);
77020 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
77021 - struct thread_info *ti);
77022 + struct task_struct *task);
77023 extern void debug_mutex_unlock(struct mutex *lock);
77024 extern void debug_mutex_init(struct mutex *lock, const char *name,
77025 struct lock_class_key *key);
77026 diff --git a/kernel/mutex.c b/kernel/mutex.c
77027 index a307cc9..27fd2e9 100644
77028 --- a/kernel/mutex.c
77029 +++ b/kernel/mutex.c
77030 @@ -198,7 +198,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
77031 spin_lock_mutex(&lock->wait_lock, flags);
77032
77033 debug_mutex_lock_common(lock, &waiter);
77034 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
77035 + debug_mutex_add_waiter(lock, &waiter, task);
77036
77037 /* add waiting tasks to the end of the waitqueue (FIFO): */
77038 list_add_tail(&waiter.list, &lock->wait_list);
77039 @@ -227,8 +227,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
77040 * TASK_UNINTERRUPTIBLE case.)
77041 */
77042 if (unlikely(signal_pending_state(state, task))) {
77043 - mutex_remove_waiter(lock, &waiter,
77044 - task_thread_info(task));
77045 + mutex_remove_waiter(lock, &waiter, task);
77046 mutex_release(&lock->dep_map, 1, ip);
77047 spin_unlock_mutex(&lock->wait_lock, flags);
77048
77049 @@ -247,7 +246,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
77050 done:
77051 lock_acquired(&lock->dep_map, ip);
77052 /* got the lock - rejoice! */
77053 - mutex_remove_waiter(lock, &waiter, current_thread_info());
77054 + mutex_remove_waiter(lock, &waiter, task);
77055 mutex_set_owner(lock);
77056
77057 /* set it to 0 if there are no waiters left: */
77058 diff --git a/kernel/notifier.c b/kernel/notifier.c
77059 index 2d5cc4c..d9ea600 100644
77060 --- a/kernel/notifier.c
77061 +++ b/kernel/notifier.c
77062 @@ -5,6 +5,7 @@
77063 #include <linux/rcupdate.h>
77064 #include <linux/vmalloc.h>
77065 #include <linux/reboot.h>
77066 +#include <linux/mm.h>
77067
77068 /*
77069 * Notifier list for kernel code which wants to be called
77070 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
77071 while ((*nl) != NULL) {
77072 if (n->priority > (*nl)->priority)
77073 break;
77074 - nl = &((*nl)->next);
77075 + nl = (struct notifier_block **)&((*nl)->next);
77076 }
77077 - n->next = *nl;
77078 + pax_open_kernel();
77079 + *(const void **)&n->next = *nl;
77080 rcu_assign_pointer(*nl, n);
77081 + pax_close_kernel();
77082 return 0;
77083 }
77084
77085 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
77086 return 0;
77087 if (n->priority > (*nl)->priority)
77088 break;
77089 - nl = &((*nl)->next);
77090 + nl = (struct notifier_block **)&((*nl)->next);
77091 }
77092 - n->next = *nl;
77093 + pax_open_kernel();
77094 + *(const void **)&n->next = *nl;
77095 rcu_assign_pointer(*nl, n);
77096 + pax_close_kernel();
77097 return 0;
77098 }
77099
77100 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
77101 {
77102 while ((*nl) != NULL) {
77103 if ((*nl) == n) {
77104 + pax_open_kernel();
77105 rcu_assign_pointer(*nl, n->next);
77106 + pax_close_kernel();
77107 return 0;
77108 }
77109 - nl = &((*nl)->next);
77110 + nl = (struct notifier_block **)&((*nl)->next);
77111 }
77112 return -ENOENT;
77113 }
77114 diff --git a/kernel/panic.c b/kernel/panic.c
77115 index e1b2822..5edc1d9 100644
77116 --- a/kernel/panic.c
77117 +++ b/kernel/panic.c
77118 @@ -410,7 +410,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
77119 const char *board;
77120
77121 printk(KERN_WARNING "------------[ cut here ]------------\n");
77122 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
77123 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
77124 board = dmi_get_system_info(DMI_PRODUCT_NAME);
77125 if (board)
77126 printk(KERN_WARNING "Hardware name: %s\n", board);
77127 @@ -465,7 +465,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
77128 */
77129 void __stack_chk_fail(void)
77130 {
77131 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
77132 + dump_stack();
77133 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
77134 __builtin_return_address(0));
77135 }
77136 EXPORT_SYMBOL(__stack_chk_fail);
77137 diff --git a/kernel/pid.c b/kernel/pid.c
77138 index f2c6a68..4922d97 100644
77139 --- a/kernel/pid.c
77140 +++ b/kernel/pid.c
77141 @@ -33,6 +33,7 @@
77142 #include <linux/rculist.h>
77143 #include <linux/bootmem.h>
77144 #include <linux/hash.h>
77145 +#include <linux/security.h>
77146 #include <linux/pid_namespace.h>
77147 #include <linux/init_task.h>
77148 #include <linux/syscalls.h>
77149 @@ -46,7 +47,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
77150
77151 int pid_max = PID_MAX_DEFAULT;
77152
77153 -#define RESERVED_PIDS 300
77154 +#define RESERVED_PIDS 500
77155
77156 int pid_max_min = RESERVED_PIDS + 1;
77157 int pid_max_max = PID_MAX_LIMIT;
77158 @@ -441,10 +442,18 @@ EXPORT_SYMBOL(pid_task);
77159 */
77160 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
77161 {
77162 + struct task_struct *task;
77163 +
77164 rcu_lockdep_assert(rcu_read_lock_held(),
77165 "find_task_by_pid_ns() needs rcu_read_lock()"
77166 " protection");
77167 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77168 +
77169 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77170 +
77171 + if (gr_pid_is_chrooted(task))
77172 + return NULL;
77173 +
77174 + return task;
77175 }
77176
77177 struct task_struct *find_task_by_vpid(pid_t vnr)
77178 @@ -452,6 +461,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
77179 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
77180 }
77181
77182 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
77183 +{
77184 + rcu_lockdep_assert(rcu_read_lock_held(),
77185 + "find_task_by_pid_ns() needs rcu_read_lock()"
77186 + " protection");
77187 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
77188 +}
77189 +
77190 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
77191 {
77192 struct pid *pid;
77193 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
77194 index bea15bd..789f3d0 100644
77195 --- a/kernel/pid_namespace.c
77196 +++ b/kernel/pid_namespace.c
77197 @@ -249,7 +249,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
77198 void __user *buffer, size_t *lenp, loff_t *ppos)
77199 {
77200 struct pid_namespace *pid_ns = task_active_pid_ns(current);
77201 - struct ctl_table tmp = *table;
77202 + ctl_table_no_const tmp = *table;
77203
77204 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
77205 return -EPERM;
77206 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
77207 index 942ca27..111e609 100644
77208 --- a/kernel/posix-cpu-timers.c
77209 +++ b/kernel/posix-cpu-timers.c
77210 @@ -1576,14 +1576,14 @@ struct k_clock clock_posix_cpu = {
77211
77212 static __init int init_posix_cpu_timers(void)
77213 {
77214 - struct k_clock process = {
77215 + static struct k_clock process = {
77216 .clock_getres = process_cpu_clock_getres,
77217 .clock_get = process_cpu_clock_get,
77218 .timer_create = process_cpu_timer_create,
77219 .nsleep = process_cpu_nsleep,
77220 .nsleep_restart = process_cpu_nsleep_restart,
77221 };
77222 - struct k_clock thread = {
77223 + static struct k_clock thread = {
77224 .clock_getres = thread_cpu_clock_getres,
77225 .clock_get = thread_cpu_clock_get,
77226 .timer_create = thread_cpu_timer_create,
77227 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
77228 index e885be1..380fe76 100644
77229 --- a/kernel/posix-timers.c
77230 +++ b/kernel/posix-timers.c
77231 @@ -43,6 +43,7 @@
77232 #include <linux/idr.h>
77233 #include <linux/posix-clock.h>
77234 #include <linux/posix-timers.h>
77235 +#include <linux/grsecurity.h>
77236 #include <linux/syscalls.h>
77237 #include <linux/wait.h>
77238 #include <linux/workqueue.h>
77239 @@ -129,7 +130,7 @@ static DEFINE_SPINLOCK(idr_lock);
77240 * which we beg off on and pass to do_sys_settimeofday().
77241 */
77242
77243 -static struct k_clock posix_clocks[MAX_CLOCKS];
77244 +static struct k_clock *posix_clocks[MAX_CLOCKS];
77245
77246 /*
77247 * These ones are defined below.
77248 @@ -227,7 +228,7 @@ static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
77249 */
77250 static __init int init_posix_timers(void)
77251 {
77252 - struct k_clock clock_realtime = {
77253 + static struct k_clock clock_realtime = {
77254 .clock_getres = hrtimer_get_res,
77255 .clock_get = posix_clock_realtime_get,
77256 .clock_set = posix_clock_realtime_set,
77257 @@ -239,7 +240,7 @@ 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 = {
77262 + static struct k_clock clock_monotonic = {
77263 .clock_getres = hrtimer_get_res,
77264 .clock_get = posix_ktime_get_ts,
77265 .nsleep = common_nsleep,
77266 @@ -249,19 +250,19 @@ static __init int init_posix_timers(void)
77267 .timer_get = common_timer_get,
77268 .timer_del = common_timer_del,
77269 };
77270 - struct k_clock clock_monotonic_raw = {
77271 + static struct k_clock clock_monotonic_raw = {
77272 .clock_getres = hrtimer_get_res,
77273 .clock_get = posix_get_monotonic_raw,
77274 };
77275 - struct k_clock clock_realtime_coarse = {
77276 + static struct k_clock clock_realtime_coarse = {
77277 .clock_getres = posix_get_coarse_res,
77278 .clock_get = posix_get_realtime_coarse,
77279 };
77280 - struct k_clock clock_monotonic_coarse = {
77281 + static struct k_clock clock_monotonic_coarse = {
77282 .clock_getres = posix_get_coarse_res,
77283 .clock_get = posix_get_monotonic_coarse,
77284 };
77285 - struct k_clock clock_boottime = {
77286 + static struct k_clock clock_boottime = {
77287 .clock_getres = hrtimer_get_res,
77288 .clock_get = posix_get_boottime,
77289 .nsleep = common_nsleep,
77290 @@ -473,7 +474,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
77291 return;
77292 }
77293
77294 - posix_clocks[clock_id] = *new_clock;
77295 + posix_clocks[clock_id] = new_clock;
77296 }
77297 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
77298
77299 @@ -519,9 +520,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
77300 return (id & CLOCKFD_MASK) == CLOCKFD ?
77301 &clock_posix_dynamic : &clock_posix_cpu;
77302
77303 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
77304 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
77305 return NULL;
77306 - return &posix_clocks[id];
77307 + return posix_clocks[id];
77308 }
77309
77310 static int common_timer_create(struct k_itimer *new_timer)
77311 @@ -966,6 +967,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
77312 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
77313 return -EFAULT;
77314
77315 + /* only the CLOCK_REALTIME clock can be set, all other clocks
77316 + have their clock_set fptr set to a nosettime dummy function
77317 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
77318 + call common_clock_set, which calls do_sys_settimeofday, which
77319 + we hook
77320 + */
77321 +
77322 return kc->clock_set(which_clock, &new_tp);
77323 }
77324
77325 diff --git a/kernel/power/process.c b/kernel/power/process.c
77326 index d5a258b..4271191 100644
77327 --- a/kernel/power/process.c
77328 +++ b/kernel/power/process.c
77329 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
77330 u64 elapsed_csecs64;
77331 unsigned int elapsed_csecs;
77332 bool wakeup = false;
77333 + bool timedout = false;
77334
77335 do_gettimeofday(&start);
77336
77337 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
77338
77339 while (true) {
77340 todo = 0;
77341 + if (time_after(jiffies, end_time))
77342 + timedout = true;
77343 read_lock(&tasklist_lock);
77344 do_each_thread(g, p) {
77345 if (p == current || !freeze_task(p))
77346 continue;
77347
77348 - if (!freezer_should_skip(p))
77349 + if (!freezer_should_skip(p)) {
77350 todo++;
77351 + if (timedout) {
77352 + printk(KERN_ERR "Task refusing to freeze:\n");
77353 + sched_show_task(p);
77354 + }
77355 + }
77356 } while_each_thread(g, p);
77357 read_unlock(&tasklist_lock);
77358
77359 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
77360 todo += wq_busy;
77361 }
77362
77363 - if (!todo || time_after(jiffies, end_time))
77364 + if (!todo || timedout)
77365 break;
77366
77367 if (pm_wakeup_pending()) {
77368 diff --git a/kernel/printk.c b/kernel/printk.c
77369 index 267ce78..2487112 100644
77370 --- a/kernel/printk.c
77371 +++ b/kernel/printk.c
77372 @@ -609,11 +609,17 @@ static unsigned int devkmsg_poll(struct file *file, poll_table *wait)
77373 return ret;
77374 }
77375
77376 +static int check_syslog_permissions(int type, bool from_file);
77377 +
77378 static int devkmsg_open(struct inode *inode, struct file *file)
77379 {
77380 struct devkmsg_user *user;
77381 int err;
77382
77383 + err = check_syslog_permissions(SYSLOG_ACTION_OPEN, SYSLOG_FROM_FILE);
77384 + if (err)
77385 + return err;
77386 +
77387 /* write-only does not need any file context */
77388 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
77389 return 0;
77390 @@ -822,7 +828,7 @@ static int syslog_action_restricted(int type)
77391 if (dmesg_restrict)
77392 return 1;
77393 /* Unless restricted, we allow "read all" and "get buffer size" for everybody */
77394 - return type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
77395 + return type != SYSLOG_ACTION_OPEN && type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
77396 }
77397
77398 static int check_syslog_permissions(int type, bool from_file)
77399 @@ -834,6 +840,11 @@ static int check_syslog_permissions(int type, bool from_file)
77400 if (from_file && type != SYSLOG_ACTION_OPEN)
77401 return 0;
77402
77403 +#ifdef CONFIG_GRKERNSEC_DMESG
77404 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
77405 + return -EPERM;
77406 +#endif
77407 +
77408 if (syslog_action_restricted(type)) {
77409 if (capable(CAP_SYSLOG))
77410 return 0;
77411 diff --git a/kernel/profile.c b/kernel/profile.c
77412 index 1f39181..86093471 100644
77413 --- a/kernel/profile.c
77414 +++ b/kernel/profile.c
77415 @@ -40,7 +40,7 @@ struct profile_hit {
77416 /* Oprofile timer tick hook */
77417 static int (*timer_hook)(struct pt_regs *) __read_mostly;
77418
77419 -static atomic_t *prof_buffer;
77420 +static atomic_unchecked_t *prof_buffer;
77421 static unsigned long prof_len, prof_shift;
77422
77423 int prof_on __read_mostly;
77424 @@ -282,7 +282,7 @@ static void profile_flip_buffers(void)
77425 hits[i].pc = 0;
77426 continue;
77427 }
77428 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77429 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77430 hits[i].hits = hits[i].pc = 0;
77431 }
77432 }
77433 @@ -343,9 +343,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77434 * Add the current hit(s) and flush the write-queue out
77435 * to the global buffer:
77436 */
77437 - atomic_add(nr_hits, &prof_buffer[pc]);
77438 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
77439 for (i = 0; i < NR_PROFILE_HIT; ++i) {
77440 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77441 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77442 hits[i].pc = hits[i].hits = 0;
77443 }
77444 out:
77445 @@ -420,7 +420,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77446 {
77447 unsigned long pc;
77448 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
77449 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77450 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77451 }
77452 #endif /* !CONFIG_SMP */
77453
77454 @@ -518,7 +518,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
77455 return -EFAULT;
77456 buf++; p++; count--; read++;
77457 }
77458 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
77459 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
77460 if (copy_to_user(buf, (void *)pnt, count))
77461 return -EFAULT;
77462 read += count;
77463 @@ -549,7 +549,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
77464 }
77465 #endif
77466 profile_discard_flip_buffers();
77467 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
77468 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
77469 return count;
77470 }
77471
77472 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
77473 index 6cbeaae..cfe7ff0 100644
77474 --- a/kernel/ptrace.c
77475 +++ b/kernel/ptrace.c
77476 @@ -324,7 +324,7 @@ static int ptrace_attach(struct task_struct *task, long request,
77477 if (seize)
77478 flags |= PT_SEIZED;
77479 rcu_read_lock();
77480 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77481 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77482 flags |= PT_PTRACE_CAP;
77483 rcu_read_unlock();
77484 task->ptrace = flags;
77485 @@ -535,7 +535,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
77486 break;
77487 return -EIO;
77488 }
77489 - if (copy_to_user(dst, buf, retval))
77490 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
77491 return -EFAULT;
77492 copied += retval;
77493 src += retval;
77494 @@ -720,7 +720,7 @@ int ptrace_request(struct task_struct *child, long request,
77495 bool seized = child->ptrace & PT_SEIZED;
77496 int ret = -EIO;
77497 siginfo_t siginfo, *si;
77498 - void __user *datavp = (void __user *) data;
77499 + void __user *datavp = (__force void __user *) data;
77500 unsigned long __user *datalp = datavp;
77501 unsigned long flags;
77502
77503 @@ -922,14 +922,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
77504 goto out;
77505 }
77506
77507 + if (gr_handle_ptrace(child, request)) {
77508 + ret = -EPERM;
77509 + goto out_put_task_struct;
77510 + }
77511 +
77512 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77513 ret = ptrace_attach(child, request, addr, data);
77514 /*
77515 * Some architectures need to do book-keeping after
77516 * a ptrace attach.
77517 */
77518 - if (!ret)
77519 + if (!ret) {
77520 arch_ptrace_attach(child);
77521 + gr_audit_ptrace(child);
77522 + }
77523 goto out_put_task_struct;
77524 }
77525
77526 @@ -957,7 +964,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
77527 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
77528 if (copied != sizeof(tmp))
77529 return -EIO;
77530 - return put_user(tmp, (unsigned long __user *)data);
77531 + return put_user(tmp, (__force unsigned long __user *)data);
77532 }
77533
77534 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
77535 @@ -1051,7 +1058,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
77536 }
77537
77538 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77539 - compat_long_t addr, compat_long_t data)
77540 + compat_ulong_t addr, compat_ulong_t data)
77541 {
77542 struct task_struct *child;
77543 long ret;
77544 @@ -1067,14 +1074,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77545 goto out;
77546 }
77547
77548 + if (gr_handle_ptrace(child, request)) {
77549 + ret = -EPERM;
77550 + goto out_put_task_struct;
77551 + }
77552 +
77553 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77554 ret = ptrace_attach(child, request, addr, data);
77555 /*
77556 * Some architectures need to do book-keeping after
77557 * a ptrace attach.
77558 */
77559 - if (!ret)
77560 + if (!ret) {
77561 arch_ptrace_attach(child);
77562 + gr_audit_ptrace(child);
77563 + }
77564 goto out_put_task_struct;
77565 }
77566
77567 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
77568 index e7dce58..ad0d7b7 100644
77569 --- a/kernel/rcutiny.c
77570 +++ b/kernel/rcutiny.c
77571 @@ -46,7 +46,7 @@
77572 struct rcu_ctrlblk;
77573 static void invoke_rcu_callbacks(void);
77574 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
77575 -static void rcu_process_callbacks(struct softirq_action *unused);
77576 +static void rcu_process_callbacks(void);
77577 static void __call_rcu(struct rcu_head *head,
77578 void (*func)(struct rcu_head *rcu),
77579 struct rcu_ctrlblk *rcp);
77580 @@ -310,7 +310,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
77581 rcu_is_callbacks_kthread()));
77582 }
77583
77584 -static void rcu_process_callbacks(struct softirq_action *unused)
77585 +static void rcu_process_callbacks(void)
77586 {
77587 __rcu_process_callbacks(&rcu_sched_ctrlblk);
77588 __rcu_process_callbacks(&rcu_bh_ctrlblk);
77589 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
77590 index f85016a..91cb03b 100644
77591 --- a/kernel/rcutiny_plugin.h
77592 +++ b/kernel/rcutiny_plugin.h
77593 @@ -896,7 +896,7 @@ static int rcu_kthread(void *arg)
77594 have_rcu_kthread_work = morework;
77595 local_irq_restore(flags);
77596 if (work)
77597 - rcu_process_callbacks(NULL);
77598 + rcu_process_callbacks();
77599 schedule_timeout_interruptible(1); /* Leave CPU for others. */
77600 }
77601
77602 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
77603 index 31dea01..ad91ffb 100644
77604 --- a/kernel/rcutorture.c
77605 +++ b/kernel/rcutorture.c
77606 @@ -163,12 +163,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
77607 { 0 };
77608 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
77609 { 0 };
77610 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77611 -static atomic_t n_rcu_torture_alloc;
77612 -static atomic_t n_rcu_torture_alloc_fail;
77613 -static atomic_t n_rcu_torture_free;
77614 -static atomic_t n_rcu_torture_mberror;
77615 -static atomic_t n_rcu_torture_error;
77616 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77617 +static atomic_unchecked_t n_rcu_torture_alloc;
77618 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
77619 +static atomic_unchecked_t n_rcu_torture_free;
77620 +static atomic_unchecked_t n_rcu_torture_mberror;
77621 +static atomic_unchecked_t n_rcu_torture_error;
77622 static long n_rcu_torture_barrier_error;
77623 static long n_rcu_torture_boost_ktrerror;
77624 static long n_rcu_torture_boost_rterror;
77625 @@ -272,11 +272,11 @@ rcu_torture_alloc(void)
77626
77627 spin_lock_bh(&rcu_torture_lock);
77628 if (list_empty(&rcu_torture_freelist)) {
77629 - atomic_inc(&n_rcu_torture_alloc_fail);
77630 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
77631 spin_unlock_bh(&rcu_torture_lock);
77632 return NULL;
77633 }
77634 - atomic_inc(&n_rcu_torture_alloc);
77635 + atomic_inc_unchecked(&n_rcu_torture_alloc);
77636 p = rcu_torture_freelist.next;
77637 list_del_init(p);
77638 spin_unlock_bh(&rcu_torture_lock);
77639 @@ -289,7 +289,7 @@ rcu_torture_alloc(void)
77640 static void
77641 rcu_torture_free(struct rcu_torture *p)
77642 {
77643 - atomic_inc(&n_rcu_torture_free);
77644 + atomic_inc_unchecked(&n_rcu_torture_free);
77645 spin_lock_bh(&rcu_torture_lock);
77646 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
77647 spin_unlock_bh(&rcu_torture_lock);
77648 @@ -409,7 +409,7 @@ rcu_torture_cb(struct rcu_head *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 rcu_torture_free(rp);
77657 @@ -457,7 +457,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
77658 i = 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 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77664 rp->rtort_mbtest = 0;
77665 list_del(&rp->rtort_free);
77666 @@ -975,7 +975,7 @@ rcu_torture_writer(void *arg)
77667 i = old_rp->rtort_pipe_count;
77668 if (i > RCU_TORTURE_PIPE_LEN)
77669 i = RCU_TORTURE_PIPE_LEN;
77670 - atomic_inc(&rcu_torture_wcount[i]);
77671 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77672 old_rp->rtort_pipe_count++;
77673 cur_ops->deferred_free(old_rp);
77674 }
77675 @@ -1060,7 +1060,7 @@ static void rcu_torture_timer(unsigned long unused)
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 spin_lock(&rand_lock);
77682 cur_ops->read_delay(&rand);
77683 n_rcu_torture_timers++;
77684 @@ -1124,7 +1124,7 @@ rcu_torture_reader(void *arg)
77685 }
77686 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
77687 if (p->rtort_mbtest == 0)
77688 - atomic_inc(&n_rcu_torture_mberror);
77689 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77690 cur_ops->read_delay(&rand);
77691 preempt_disable();
77692 pipe_count = p->rtort_pipe_count;
77693 @@ -1183,11 +1183,11 @@ rcu_torture_printk(char *page)
77694 rcu_torture_current,
77695 rcu_torture_current_version,
77696 list_empty(&rcu_torture_freelist),
77697 - atomic_read(&n_rcu_torture_alloc),
77698 - atomic_read(&n_rcu_torture_alloc_fail),
77699 - atomic_read(&n_rcu_torture_free));
77700 + atomic_read_unchecked(&n_rcu_torture_alloc),
77701 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
77702 + atomic_read_unchecked(&n_rcu_torture_free));
77703 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
77704 - atomic_read(&n_rcu_torture_mberror),
77705 + atomic_read_unchecked(&n_rcu_torture_mberror),
77706 n_rcu_torture_boost_ktrerror,
77707 n_rcu_torture_boost_rterror);
77708 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
77709 @@ -1206,14 +1206,14 @@ rcu_torture_printk(char *page)
77710 n_barrier_attempts,
77711 n_rcu_torture_barrier_error);
77712 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
77713 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
77714 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
77715 n_rcu_torture_barrier_error != 0 ||
77716 n_rcu_torture_boost_ktrerror != 0 ||
77717 n_rcu_torture_boost_rterror != 0 ||
77718 n_rcu_torture_boost_failure != 0 ||
77719 i > 1) {
77720 cnt += sprintf(&page[cnt], "!!! ");
77721 - atomic_inc(&n_rcu_torture_error);
77722 + atomic_inc_unchecked(&n_rcu_torture_error);
77723 WARN_ON_ONCE(1);
77724 }
77725 cnt += sprintf(&page[cnt], "Reader Pipe: ");
77726 @@ -1227,7 +1227,7 @@ rcu_torture_printk(char *page)
77727 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
77728 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77729 cnt += sprintf(&page[cnt], " %d",
77730 - atomic_read(&rcu_torture_wcount[i]));
77731 + atomic_read_unchecked(&rcu_torture_wcount[i]));
77732 }
77733 cnt += sprintf(&page[cnt], "\n");
77734 if (cur_ops->stats)
77735 @@ -1920,7 +1920,7 @@ rcu_torture_cleanup(void)
77736
77737 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
77738
77739 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77740 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77741 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
77742 else if (n_online_successes != n_online_attempts ||
77743 n_offline_successes != n_offline_attempts)
77744 @@ -1989,18 +1989,18 @@ rcu_torture_init(void)
77745
77746 rcu_torture_current = NULL;
77747 rcu_torture_current_version = 0;
77748 - atomic_set(&n_rcu_torture_alloc, 0);
77749 - atomic_set(&n_rcu_torture_alloc_fail, 0);
77750 - atomic_set(&n_rcu_torture_free, 0);
77751 - atomic_set(&n_rcu_torture_mberror, 0);
77752 - atomic_set(&n_rcu_torture_error, 0);
77753 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
77754 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
77755 + atomic_set_unchecked(&n_rcu_torture_free, 0);
77756 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
77757 + atomic_set_unchecked(&n_rcu_torture_error, 0);
77758 n_rcu_torture_barrier_error = 0;
77759 n_rcu_torture_boost_ktrerror = 0;
77760 n_rcu_torture_boost_rterror = 0;
77761 n_rcu_torture_boost_failure = 0;
77762 n_rcu_torture_boosts = 0;
77763 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
77764 - atomic_set(&rcu_torture_wcount[i], 0);
77765 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
77766 for_each_possible_cpu(cpu) {
77767 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77768 per_cpu(rcu_torture_count, cpu)[i] = 0;
77769 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
77770 index e441b77..dd54f17 100644
77771 --- a/kernel/rcutree.c
77772 +++ b/kernel/rcutree.c
77773 @@ -349,9 +349,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
77774 rcu_prepare_for_idle(smp_processor_id());
77775 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77776 smp_mb__before_atomic_inc(); /* See above. */
77777 - atomic_inc(&rdtp->dynticks);
77778 + atomic_inc_unchecked(&rdtp->dynticks);
77779 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
77780 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77781 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77782
77783 /*
77784 * It is illegal to enter an extended quiescent state while
77785 @@ -487,10 +487,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
77786 int user)
77787 {
77788 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
77789 - atomic_inc(&rdtp->dynticks);
77790 + atomic_inc_unchecked(&rdtp->dynticks);
77791 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77792 smp_mb__after_atomic_inc(); /* See above. */
77793 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77794 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77795 rcu_cleanup_after_idle(smp_processor_id());
77796 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
77797 if (!user && !is_idle_task(current)) {
77798 @@ -629,14 +629,14 @@ void rcu_nmi_enter(void)
77799 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
77800
77801 if (rdtp->dynticks_nmi_nesting == 0 &&
77802 - (atomic_read(&rdtp->dynticks) & 0x1))
77803 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
77804 return;
77805 rdtp->dynticks_nmi_nesting++;
77806 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
77807 - atomic_inc(&rdtp->dynticks);
77808 + atomic_inc_unchecked(&rdtp->dynticks);
77809 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77810 smp_mb__after_atomic_inc(); /* See above. */
77811 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77812 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77813 }
77814
77815 /**
77816 @@ -655,9 +655,9 @@ void rcu_nmi_exit(void)
77817 return;
77818 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77819 smp_mb__before_atomic_inc(); /* See above. */
77820 - atomic_inc(&rdtp->dynticks);
77821 + atomic_inc_unchecked(&rdtp->dynticks);
77822 smp_mb__after_atomic_inc(); /* Force delay to next write. */
77823 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77824 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77825 }
77826
77827 /**
77828 @@ -671,7 +671,7 @@ int rcu_is_cpu_idle(void)
77829 int ret;
77830
77831 preempt_disable();
77832 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77833 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77834 preempt_enable();
77835 return ret;
77836 }
77837 @@ -739,7 +739,7 @@ int rcu_is_cpu_rrupt_from_idle(void)
77838 */
77839 static int dyntick_save_progress_counter(struct rcu_data *rdp)
77840 {
77841 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
77842 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77843 return (rdp->dynticks_snap & 0x1) == 0;
77844 }
77845
77846 @@ -754,7 +754,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
77847 unsigned int curr;
77848 unsigned int snap;
77849
77850 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
77851 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77852 snap = (unsigned int)rdp->dynticks_snap;
77853
77854 /*
77855 @@ -802,10 +802,10 @@ static int jiffies_till_stall_check(void)
77856 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
77857 */
77858 if (till_stall_check < 3) {
77859 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
77860 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
77861 till_stall_check = 3;
77862 } else if (till_stall_check > 300) {
77863 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
77864 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
77865 till_stall_check = 300;
77866 }
77867 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
77868 @@ -1592,7 +1592,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
77869 rsp->qlen += rdp->qlen;
77870 rdp->n_cbs_orphaned += rdp->qlen;
77871 rdp->qlen_lazy = 0;
77872 - ACCESS_ONCE(rdp->qlen) = 0;
77873 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77874 }
77875
77876 /*
77877 @@ -1838,7 +1838,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
77878 }
77879 smp_mb(); /* List handling before counting for rcu_barrier(). */
77880 rdp->qlen_lazy -= count_lazy;
77881 - ACCESS_ONCE(rdp->qlen) -= count;
77882 + ACCESS_ONCE_RW(rdp->qlen) -= count;
77883 rdp->n_cbs_invoked += count;
77884
77885 /* Reinstate batch limit if we have worked down the excess. */
77886 @@ -2031,7 +2031,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
77887 /*
77888 * Do RCU core processing for the current CPU.
77889 */
77890 -static void rcu_process_callbacks(struct softirq_action *unused)
77891 +static void rcu_process_callbacks(void)
77892 {
77893 struct rcu_state *rsp;
77894
77895 @@ -2154,7 +2154,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
77896 local_irq_restore(flags);
77897 return;
77898 }
77899 - ACCESS_ONCE(rdp->qlen)++;
77900 + ACCESS_ONCE_RW(rdp->qlen)++;
77901 if (lazy)
77902 rdp->qlen_lazy++;
77903 else
77904 @@ -2363,11 +2363,11 @@ void synchronize_sched_expedited(void)
77905 * counter wrap on a 32-bit system. Quite a few more CPUs would of
77906 * course be required on a 64-bit system.
77907 */
77908 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
77909 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
77910 (ulong)atomic_long_read(&rsp->expedited_done) +
77911 ULONG_MAX / 8)) {
77912 synchronize_sched();
77913 - atomic_long_inc(&rsp->expedited_wrap);
77914 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
77915 return;
77916 }
77917
77918 @@ -2375,7 +2375,7 @@ void synchronize_sched_expedited(void)
77919 * Take a ticket. Note that atomic_inc_return() implies a
77920 * full memory barrier.
77921 */
77922 - snap = atomic_long_inc_return(&rsp->expedited_start);
77923 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
77924 firstsnap = snap;
77925 get_online_cpus();
77926 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
77927 @@ -2388,14 +2388,14 @@ void synchronize_sched_expedited(void)
77928 synchronize_sched_expedited_cpu_stop,
77929 NULL) == -EAGAIN) {
77930 put_online_cpus();
77931 - atomic_long_inc(&rsp->expedited_tryfail);
77932 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
77933
77934 /* Check to see if someone else did our work for us. */
77935 s = atomic_long_read(&rsp->expedited_done);
77936 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77937 /* ensure test happens before caller kfree */
77938 smp_mb__before_atomic_inc(); /* ^^^ */
77939 - atomic_long_inc(&rsp->expedited_workdone1);
77940 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
77941 return;
77942 }
77943
77944 @@ -2404,7 +2404,7 @@ void synchronize_sched_expedited(void)
77945 udelay(trycount * num_online_cpus());
77946 } else {
77947 wait_rcu_gp(call_rcu_sched);
77948 - atomic_long_inc(&rsp->expedited_normal);
77949 + atomic_long_inc_unchecked(&rsp->expedited_normal);
77950 return;
77951 }
77952
77953 @@ -2413,7 +2413,7 @@ void synchronize_sched_expedited(void)
77954 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77955 /* ensure test happens before caller kfree */
77956 smp_mb__before_atomic_inc(); /* ^^^ */
77957 - atomic_long_inc(&rsp->expedited_workdone2);
77958 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
77959 return;
77960 }
77961
77962 @@ -2425,10 +2425,10 @@ void synchronize_sched_expedited(void)
77963 * period works for us.
77964 */
77965 get_online_cpus();
77966 - snap = atomic_long_read(&rsp->expedited_start);
77967 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
77968 smp_mb(); /* ensure read is before try_stop_cpus(). */
77969 }
77970 - atomic_long_inc(&rsp->expedited_stoppedcpus);
77971 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
77972
77973 /*
77974 * Everyone up to our most recent fetch is covered by our grace
77975 @@ -2437,16 +2437,16 @@ void synchronize_sched_expedited(void)
77976 * than we did already did their update.
77977 */
77978 do {
77979 - atomic_long_inc(&rsp->expedited_done_tries);
77980 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
77981 s = atomic_long_read(&rsp->expedited_done);
77982 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
77983 /* ensure test happens before caller kfree */
77984 smp_mb__before_atomic_inc(); /* ^^^ */
77985 - atomic_long_inc(&rsp->expedited_done_lost);
77986 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
77987 break;
77988 }
77989 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
77990 - atomic_long_inc(&rsp->expedited_done_exit);
77991 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
77992
77993 put_online_cpus();
77994 }
77995 @@ -2620,7 +2620,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77996 * ACCESS_ONCE() to prevent the compiler from speculating
77997 * the increment to precede the early-exit check.
77998 */
77999 - ACCESS_ONCE(rsp->n_barrier_done)++;
78000 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
78001 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
78002 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
78003 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
78004 @@ -2670,7 +2670,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
78005
78006 /* Increment ->n_barrier_done to prevent duplicate work. */
78007 smp_mb(); /* Keep increment after above mechanism. */
78008 - ACCESS_ONCE(rsp->n_barrier_done)++;
78009 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
78010 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
78011 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
78012 smp_mb(); /* Keep increment before caller's subsequent code. */
78013 @@ -2715,10 +2715,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
78014 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
78015 init_callback_list(rdp);
78016 rdp->qlen_lazy = 0;
78017 - ACCESS_ONCE(rdp->qlen) = 0;
78018 + ACCESS_ONCE_RW(rdp->qlen) = 0;
78019 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
78020 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
78021 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
78022 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
78023 #ifdef CONFIG_RCU_USER_QS
78024 WARN_ON_ONCE(rdp->dynticks->in_user);
78025 #endif
78026 @@ -2754,8 +2754,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
78027 rdp->blimit = blimit;
78028 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
78029 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
78030 - atomic_set(&rdp->dynticks->dynticks,
78031 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
78032 + atomic_set_unchecked(&rdp->dynticks->dynticks,
78033 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
78034 rcu_prepare_for_idle_init(cpu);
78035 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
78036
78037 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
78038 index 4b69291..704c92e 100644
78039 --- a/kernel/rcutree.h
78040 +++ b/kernel/rcutree.h
78041 @@ -86,7 +86,7 @@ struct rcu_dynticks {
78042 long long dynticks_nesting; /* Track irq/process nesting level. */
78043 /* Process level is worth LLONG_MAX/2. */
78044 int dynticks_nmi_nesting; /* Track NMI nesting level. */
78045 - atomic_t dynticks; /* Even value for idle, else odd. */
78046 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
78047 #ifdef CONFIG_RCU_FAST_NO_HZ
78048 int dyntick_drain; /* Prepare-for-idle state variable. */
78049 unsigned long dyntick_holdoff;
78050 @@ -423,17 +423,17 @@ struct rcu_state {
78051 /* _rcu_barrier(). */
78052 /* End of fields guarded by barrier_mutex. */
78053
78054 - atomic_long_t expedited_start; /* Starting ticket. */
78055 - atomic_long_t expedited_done; /* Done ticket. */
78056 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
78057 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
78058 - atomic_long_t expedited_workdone1; /* # done by others #1. */
78059 - atomic_long_t expedited_workdone2; /* # done by others #2. */
78060 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
78061 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
78062 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
78063 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
78064 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
78065 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
78066 + atomic_long_t expedited_done; /* Done ticket. */
78067 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
78068 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
78069 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
78070 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
78071 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
78072 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
78073 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
78074 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
78075 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
78076
78077 unsigned long jiffies_force_qs; /* Time at which to invoke */
78078 /* force_quiescent_state(). */
78079 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
78080 index c1cc7e1..f62e436 100644
78081 --- a/kernel/rcutree_plugin.h
78082 +++ b/kernel/rcutree_plugin.h
78083 @@ -892,7 +892,7 @@ void synchronize_rcu_expedited(void)
78084
78085 /* Clean up and exit. */
78086 smp_mb(); /* ensure expedited GP seen before counter increment. */
78087 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
78088 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
78089 unlock_mb_ret:
78090 mutex_unlock(&sync_rcu_preempt_exp_mutex);
78091 mb_ret:
78092 @@ -1440,7 +1440,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
78093 free_cpumask_var(cm);
78094 }
78095
78096 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
78097 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
78098 .store = &rcu_cpu_kthread_task,
78099 .thread_should_run = rcu_cpu_kthread_should_run,
78100 .thread_fn = rcu_cpu_kthread,
78101 @@ -2072,7 +2072,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
78102 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
78103 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d %s\n",
78104 cpu, ticks_value, ticks_title,
78105 - atomic_read(&rdtp->dynticks) & 0xfff,
78106 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
78107 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
78108 fast_no_hz);
78109 }
78110 @@ -2192,7 +2192,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
78111
78112 /* Enqueue the callback on the nocb list and update counts. */
78113 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
78114 - ACCESS_ONCE(*old_rhpp) = rhp;
78115 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
78116 atomic_long_add(rhcount, &rdp->nocb_q_count);
78117 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
78118
78119 @@ -2384,12 +2384,12 @@ static int rcu_nocb_kthread(void *arg)
78120 * Extract queued callbacks, update counts, and wait
78121 * for a grace period to elapse.
78122 */
78123 - ACCESS_ONCE(rdp->nocb_head) = NULL;
78124 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
78125 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
78126 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
78127 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
78128 - ACCESS_ONCE(rdp->nocb_p_count) += c;
78129 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
78130 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
78131 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
78132 wait_rcu_gp(rdp->rsp->call_remote);
78133
78134 /* Each pass through the following loop invokes a callback. */
78135 @@ -2411,8 +2411,8 @@ static int rcu_nocb_kthread(void *arg)
78136 list = next;
78137 }
78138 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
78139 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
78140 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
78141 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
78142 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
78143 rdp->n_nocbs_invoked += c;
78144 }
78145 return 0;
78146 @@ -2438,7 +2438,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
78147 rdp = per_cpu_ptr(rsp->rda, cpu);
78148 t = kthread_run(rcu_nocb_kthread, rdp, "rcuo%d", cpu);
78149 BUG_ON(IS_ERR(t));
78150 - ACCESS_ONCE(rdp->nocb_kthread) = t;
78151 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
78152 }
78153 }
78154
78155 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
78156 index 0d095dc..1985b19 100644
78157 --- a/kernel/rcutree_trace.c
78158 +++ b/kernel/rcutree_trace.c
78159 @@ -123,7 +123,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
78160 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
78161 rdp->passed_quiesce, rdp->qs_pending);
78162 seq_printf(m, " dt=%d/%llx/%d df=%lu",
78163 - atomic_read(&rdp->dynticks->dynticks),
78164 + atomic_read_unchecked(&rdp->dynticks->dynticks),
78165 rdp->dynticks->dynticks_nesting,
78166 rdp->dynticks->dynticks_nmi_nesting,
78167 rdp->dynticks_fqs);
78168 @@ -184,17 +184,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
78169 struct rcu_state *rsp = (struct rcu_state *)m->private;
78170
78171 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",
78172 - atomic_long_read(&rsp->expedited_start),
78173 + atomic_long_read_unchecked(&rsp->expedited_start),
78174 atomic_long_read(&rsp->expedited_done),
78175 - atomic_long_read(&rsp->expedited_wrap),
78176 - atomic_long_read(&rsp->expedited_tryfail),
78177 - atomic_long_read(&rsp->expedited_workdone1),
78178 - atomic_long_read(&rsp->expedited_workdone2),
78179 - atomic_long_read(&rsp->expedited_normal),
78180 - atomic_long_read(&rsp->expedited_stoppedcpus),
78181 - atomic_long_read(&rsp->expedited_done_tries),
78182 - atomic_long_read(&rsp->expedited_done_lost),
78183 - atomic_long_read(&rsp->expedited_done_exit));
78184 + atomic_long_read_unchecked(&rsp->expedited_wrap),
78185 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
78186 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
78187 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
78188 + atomic_long_read_unchecked(&rsp->expedited_normal),
78189 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
78190 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
78191 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
78192 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
78193 return 0;
78194 }
78195
78196 diff --git a/kernel/resource.c b/kernel/resource.c
78197 index 73f35d4..4684fc4 100644
78198 --- a/kernel/resource.c
78199 +++ b/kernel/resource.c
78200 @@ -143,8 +143,18 @@ static const struct file_operations proc_iomem_operations = {
78201
78202 static int __init ioresources_init(void)
78203 {
78204 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78205 +#ifdef CONFIG_GRKERNSEC_PROC_USER
78206 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
78207 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
78208 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
78209 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
78210 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
78211 +#endif
78212 +#else
78213 proc_create("ioports", 0, NULL, &proc_ioports_operations);
78214 proc_create("iomem", 0, NULL, &proc_iomem_operations);
78215 +#endif
78216 return 0;
78217 }
78218 __initcall(ioresources_init);
78219 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
78220 index 98ec494..4241d6d 100644
78221 --- a/kernel/rtmutex-tester.c
78222 +++ b/kernel/rtmutex-tester.c
78223 @@ -20,7 +20,7 @@
78224 #define MAX_RT_TEST_MUTEXES 8
78225
78226 static spinlock_t rttest_lock;
78227 -static atomic_t rttest_event;
78228 +static atomic_unchecked_t rttest_event;
78229
78230 struct test_thread_data {
78231 int opcode;
78232 @@ -61,7 +61,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78233
78234 case RTTEST_LOCKCONT:
78235 td->mutexes[td->opdata] = 1;
78236 - td->event = atomic_add_return(1, &rttest_event);
78237 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78238 return 0;
78239
78240 case RTTEST_RESET:
78241 @@ -74,7 +74,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78242 return 0;
78243
78244 case RTTEST_RESETEVENT:
78245 - atomic_set(&rttest_event, 0);
78246 + atomic_set_unchecked(&rttest_event, 0);
78247 return 0;
78248
78249 default:
78250 @@ -91,9 +91,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78251 return ret;
78252
78253 td->mutexes[id] = 1;
78254 - td->event = atomic_add_return(1, &rttest_event);
78255 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78256 rt_mutex_lock(&mutexes[id]);
78257 - td->event = atomic_add_return(1, &rttest_event);
78258 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78259 td->mutexes[id] = 4;
78260 return 0;
78261
78262 @@ -104,9 +104,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78263 return ret;
78264
78265 td->mutexes[id] = 1;
78266 - td->event = atomic_add_return(1, &rttest_event);
78267 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78268 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
78269 - td->event = atomic_add_return(1, &rttest_event);
78270 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78271 td->mutexes[id] = ret ? 0 : 4;
78272 return ret ? -EINTR : 0;
78273
78274 @@ -115,9 +115,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78275 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
78276 return ret;
78277
78278 - td->event = atomic_add_return(1, &rttest_event);
78279 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78280 rt_mutex_unlock(&mutexes[id]);
78281 - td->event = atomic_add_return(1, &rttest_event);
78282 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78283 td->mutexes[id] = 0;
78284 return 0;
78285
78286 @@ -164,7 +164,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78287 break;
78288
78289 td->mutexes[dat] = 2;
78290 - td->event = atomic_add_return(1, &rttest_event);
78291 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78292 break;
78293
78294 default:
78295 @@ -184,7 +184,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78296 return;
78297
78298 td->mutexes[dat] = 3;
78299 - td->event = atomic_add_return(1, &rttest_event);
78300 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78301 break;
78302
78303 case RTTEST_LOCKNOWAIT:
78304 @@ -196,7 +196,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78305 return;
78306
78307 td->mutexes[dat] = 1;
78308 - td->event = atomic_add_return(1, &rttest_event);
78309 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78310 return;
78311
78312 default:
78313 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
78314 index 0984a21..939f183 100644
78315 --- a/kernel/sched/auto_group.c
78316 +++ b/kernel/sched/auto_group.c
78317 @@ -11,7 +11,7 @@
78318
78319 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
78320 static struct autogroup autogroup_default;
78321 -static atomic_t autogroup_seq_nr;
78322 +static atomic_unchecked_t autogroup_seq_nr;
78323
78324 void __init autogroup_init(struct task_struct *init_task)
78325 {
78326 @@ -78,7 +78,7 @@ static inline struct autogroup *autogroup_create(void)
78327
78328 kref_init(&ag->kref);
78329 init_rwsem(&ag->lock);
78330 - ag->id = atomic_inc_return(&autogroup_seq_nr);
78331 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
78332 ag->tg = tg;
78333 #ifdef CONFIG_RT_GROUP_SCHED
78334 /*
78335 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
78336 index 26058d0..e315889 100644
78337 --- a/kernel/sched/core.c
78338 +++ b/kernel/sched/core.c
78339 @@ -3367,7 +3367,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
78340 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78341 * positive (at least 1, or number of jiffies left till timeout) if completed.
78342 */
78343 -long __sched
78344 +long __sched __intentional_overflow(-1)
78345 wait_for_completion_interruptible_timeout(struct completion *x,
78346 unsigned long timeout)
78347 {
78348 @@ -3384,7 +3384,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
78349 *
78350 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
78351 */
78352 -int __sched wait_for_completion_killable(struct completion *x)
78353 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
78354 {
78355 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
78356 if (t == -ERESTARTSYS)
78357 @@ -3405,7 +3405,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
78358 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78359 * positive (at least 1, or number of jiffies left till timeout) if completed.
78360 */
78361 -long __sched
78362 +long __sched __intentional_overflow(-1)
78363 wait_for_completion_killable_timeout(struct completion *x,
78364 unsigned long timeout)
78365 {
78366 @@ -3631,6 +3631,8 @@ int can_nice(const struct task_struct *p, const int nice)
78367 /* convert nice value [19,-20] to rlimit style value [1,40] */
78368 int nice_rlim = 20 - nice;
78369
78370 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
78371 +
78372 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
78373 capable(CAP_SYS_NICE));
78374 }
78375 @@ -3664,7 +3666,8 @@ SYSCALL_DEFINE1(nice, int, increment)
78376 if (nice > 19)
78377 nice = 19;
78378
78379 - if (increment < 0 && !can_nice(current, nice))
78380 + if (increment < 0 && (!can_nice(current, nice) ||
78381 + gr_handle_chroot_nice()))
78382 return -EPERM;
78383
78384 retval = security_task_setnice(current, nice);
78385 @@ -3818,6 +3821,7 @@ recheck:
78386 unsigned long rlim_rtprio =
78387 task_rlimit(p, RLIMIT_RTPRIO);
78388
78389 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
78390 /* can't set/change the rt policy */
78391 if (policy != p->policy && !rlim_rtprio)
78392 return -EPERM;
78393 @@ -4901,7 +4905,7 @@ static void migrate_tasks(unsigned int dead_cpu)
78394
78395 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
78396
78397 -static struct ctl_table sd_ctl_dir[] = {
78398 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
78399 {
78400 .procname = "sched_domain",
78401 .mode = 0555,
78402 @@ -4918,17 +4922,17 @@ static struct ctl_table sd_ctl_root[] = {
78403 {}
78404 };
78405
78406 -static struct ctl_table *sd_alloc_ctl_entry(int n)
78407 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
78408 {
78409 - struct ctl_table *entry =
78410 + ctl_table_no_const *entry =
78411 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
78412
78413 return entry;
78414 }
78415
78416 -static void sd_free_ctl_entry(struct ctl_table **tablep)
78417 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
78418 {
78419 - struct ctl_table *entry;
78420 + ctl_table_no_const *entry;
78421
78422 /*
78423 * In the intermediate directories, both the child directory and
78424 @@ -4936,22 +4940,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
78425 * will always be set. In the lowest directory the names are
78426 * static strings and all have proc handlers.
78427 */
78428 - for (entry = *tablep; entry->mode; entry++) {
78429 - if (entry->child)
78430 - sd_free_ctl_entry(&entry->child);
78431 + for (entry = tablep; entry->mode; entry++) {
78432 + if (entry->child) {
78433 + sd_free_ctl_entry(entry->child);
78434 + pax_open_kernel();
78435 + entry->child = NULL;
78436 + pax_close_kernel();
78437 + }
78438 if (entry->proc_handler == NULL)
78439 kfree(entry->procname);
78440 }
78441
78442 - kfree(*tablep);
78443 - *tablep = NULL;
78444 + kfree(tablep);
78445 }
78446
78447 static int min_load_idx = 0;
78448 static int max_load_idx = CPU_LOAD_IDX_MAX;
78449
78450 static void
78451 -set_table_entry(struct ctl_table *entry,
78452 +set_table_entry(ctl_table_no_const *entry,
78453 const char *procname, void *data, int maxlen,
78454 umode_t mode, proc_handler *proc_handler,
78455 bool load_idx)
78456 @@ -4971,7 +4978,7 @@ set_table_entry(struct ctl_table *entry,
78457 static struct ctl_table *
78458 sd_alloc_ctl_domain_table(struct sched_domain *sd)
78459 {
78460 - struct ctl_table *table = sd_alloc_ctl_entry(13);
78461 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
78462
78463 if (table == NULL)
78464 return NULL;
78465 @@ -5006,9 +5013,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
78466 return table;
78467 }
78468
78469 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
78470 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
78471 {
78472 - struct ctl_table *entry, *table;
78473 + ctl_table_no_const *entry, *table;
78474 struct sched_domain *sd;
78475 int domain_num = 0, i;
78476 char buf[32];
78477 @@ -5035,11 +5042,13 @@ static struct ctl_table_header *sd_sysctl_header;
78478 static void register_sched_domain_sysctl(void)
78479 {
78480 int i, cpu_num = num_possible_cpus();
78481 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
78482 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
78483 char buf[32];
78484
78485 WARN_ON(sd_ctl_dir[0].child);
78486 + pax_open_kernel();
78487 sd_ctl_dir[0].child = entry;
78488 + pax_close_kernel();
78489
78490 if (entry == NULL)
78491 return;
78492 @@ -5062,8 +5071,12 @@ static void unregister_sched_domain_sysctl(void)
78493 if (sd_sysctl_header)
78494 unregister_sysctl_table(sd_sysctl_header);
78495 sd_sysctl_header = NULL;
78496 - if (sd_ctl_dir[0].child)
78497 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
78498 + if (sd_ctl_dir[0].child) {
78499 + sd_free_ctl_entry(sd_ctl_dir[0].child);
78500 + pax_open_kernel();
78501 + sd_ctl_dir[0].child = NULL;
78502 + pax_close_kernel();
78503 + }
78504 }
78505 #else
78506 static void register_sched_domain_sysctl(void)
78507 @@ -5162,7 +5175,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
78508 * happens before everything else. This has to be lower priority than
78509 * the notifier in the perf_event subsystem, though.
78510 */
78511 -static struct notifier_block __cpuinitdata migration_notifier = {
78512 +static struct notifier_block migration_notifier = {
78513 .notifier_call = migration_call,
78514 .priority = CPU_PRI_MIGRATION,
78515 };
78516 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
78517 index 81fa536..6ccf96a 100644
78518 --- a/kernel/sched/fair.c
78519 +++ b/kernel/sched/fair.c
78520 @@ -830,7 +830,7 @@ void task_numa_fault(int node, int pages, bool migrated)
78521
78522 static void reset_ptenuma_scan(struct task_struct *p)
78523 {
78524 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
78525 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
78526 p->mm->numa_scan_offset = 0;
78527 }
78528
78529 @@ -3254,25 +3254,18 @@ find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
78530 */
78531 static int select_idle_sibling(struct task_struct *p, int target)
78532 {
78533 - int cpu = smp_processor_id();
78534 - int prev_cpu = task_cpu(p);
78535 struct sched_domain *sd;
78536 struct sched_group *sg;
78537 - int i;
78538 + int i = task_cpu(p);
78539
78540 - /*
78541 - * If the task is going to be woken-up on this cpu and if it is
78542 - * already idle, then it is the right target.
78543 - */
78544 - if (target == cpu && idle_cpu(cpu))
78545 - return cpu;
78546 + if (idle_cpu(target))
78547 + return target;
78548
78549 /*
78550 - * If the task is going to be woken-up on the cpu where it previously
78551 - * ran and if it is currently idle, then it the right target.
78552 + * If the prevous cpu is cache affine and idle, don't be stupid.
78553 */
78554 - if (target == prev_cpu && idle_cpu(prev_cpu))
78555 - return prev_cpu;
78556 + if (i != target && cpus_share_cache(i, target) && idle_cpu(i))
78557 + return i;
78558
78559 /*
78560 * Otherwise, iterate the domains and find an elegible idle cpu.
78561 @@ -3286,7 +3279,7 @@ static int select_idle_sibling(struct task_struct *p, int target)
78562 goto next;
78563
78564 for_each_cpu(i, sched_group_cpus(sg)) {
78565 - if (!idle_cpu(i))
78566 + if (i == target || !idle_cpu(i))
78567 goto next;
78568 }
78569
78570 @@ -5663,7 +5656,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
78571 * run_rebalance_domains is triggered when needed from the scheduler tick.
78572 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
78573 */
78574 -static void run_rebalance_domains(struct softirq_action *h)
78575 +static void run_rebalance_domains(void)
78576 {
78577 int this_cpu = smp_processor_id();
78578 struct rq *this_rq = cpu_rq(this_cpu);
78579 diff --git a/kernel/signal.c b/kernel/signal.c
78580 index dec9c30..d1da15b 100644
78581 --- a/kernel/signal.c
78582 +++ b/kernel/signal.c
78583 @@ -50,12 +50,12 @@ static struct kmem_cache *sigqueue_cachep;
78584
78585 int print_fatal_signals __read_mostly;
78586
78587 -static void __user *sig_handler(struct task_struct *t, int sig)
78588 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
78589 {
78590 return t->sighand->action[sig - 1].sa.sa_handler;
78591 }
78592
78593 -static int sig_handler_ignored(void __user *handler, int sig)
78594 +static int sig_handler_ignored(__sighandler_t handler, int sig)
78595 {
78596 /* Is it explicitly or implicitly ignored? */
78597 return handler == SIG_IGN ||
78598 @@ -64,7 +64,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
78599
78600 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
78601 {
78602 - void __user *handler;
78603 + __sighandler_t handler;
78604
78605 handler = sig_handler(t, sig);
78606
78607 @@ -368,6 +368,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
78608 atomic_inc(&user->sigpending);
78609 rcu_read_unlock();
78610
78611 + if (!override_rlimit)
78612 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
78613 +
78614 if (override_rlimit ||
78615 atomic_read(&user->sigpending) <=
78616 task_rlimit(t, RLIMIT_SIGPENDING)) {
78617 @@ -495,7 +498,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
78618
78619 int unhandled_signal(struct task_struct *tsk, int sig)
78620 {
78621 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
78622 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
78623 if (is_global_init(tsk))
78624 return 1;
78625 if (handler != SIG_IGN && handler != SIG_DFL)
78626 @@ -815,6 +818,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
78627 }
78628 }
78629
78630 + /* allow glibc communication via tgkill to other threads in our
78631 + thread group */
78632 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
78633 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
78634 + && gr_handle_signal(t, sig))
78635 + return -EPERM;
78636 +
78637 return security_task_kill(t, info, sig, 0);
78638 }
78639
78640 @@ -1197,7 +1207,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78641 return send_signal(sig, info, p, 1);
78642 }
78643
78644 -static int
78645 +int
78646 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78647 {
78648 return send_signal(sig, info, t, 0);
78649 @@ -1234,6 +1244,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78650 unsigned long int flags;
78651 int ret, blocked, ignored;
78652 struct k_sigaction *action;
78653 + int is_unhandled = 0;
78654
78655 spin_lock_irqsave(&t->sighand->siglock, flags);
78656 action = &t->sighand->action[sig-1];
78657 @@ -1248,9 +1259,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78658 }
78659 if (action->sa.sa_handler == SIG_DFL)
78660 t->signal->flags &= ~SIGNAL_UNKILLABLE;
78661 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
78662 + is_unhandled = 1;
78663 ret = specific_send_sig_info(sig, info, t);
78664 spin_unlock_irqrestore(&t->sighand->siglock, flags);
78665
78666 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
78667 + normal operation */
78668 + if (is_unhandled) {
78669 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
78670 + gr_handle_crash(t, sig);
78671 + }
78672 +
78673 return ret;
78674 }
78675
78676 @@ -1317,8 +1337,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78677 ret = check_kill_permission(sig, info, p);
78678 rcu_read_unlock();
78679
78680 - if (!ret && sig)
78681 + if (!ret && sig) {
78682 ret = do_send_sig_info(sig, info, p, true);
78683 + if (!ret)
78684 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
78685 + }
78686
78687 return ret;
78688 }
78689 @@ -2855,7 +2878,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
78690 int error = -ESRCH;
78691
78692 rcu_read_lock();
78693 - p = find_task_by_vpid(pid);
78694 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
78695 + /* allow glibc communication via tgkill to other threads in our
78696 + thread group */
78697 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
78698 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
78699 + p = find_task_by_vpid_unrestricted(pid);
78700 + else
78701 +#endif
78702 + p = find_task_by_vpid(pid);
78703 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
78704 error = check_kill_permission(sig, info, p);
78705 /*
78706 @@ -3138,8 +3169,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
78707 }
78708 seg = get_fs();
78709 set_fs(KERNEL_DS);
78710 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
78711 - (stack_t __force __user *) &uoss,
78712 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
78713 + (stack_t __force_user *) &uoss,
78714 compat_user_stack_pointer());
78715 set_fs(seg);
78716 if (ret >= 0 && uoss_ptr) {
78717 diff --git a/kernel/smp.c b/kernel/smp.c
78718 index 69f38bd..77bbf12 100644
78719 --- a/kernel/smp.c
78720 +++ b/kernel/smp.c
78721 @@ -77,7 +77,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
78722 return NOTIFY_OK;
78723 }
78724
78725 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
78726 +static struct notifier_block hotplug_cfd_notifier = {
78727 .notifier_call = hotplug_cfd,
78728 };
78729
78730 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
78731 index d6c5fc0..530560c 100644
78732 --- a/kernel/smpboot.c
78733 +++ b/kernel/smpboot.c
78734 @@ -275,7 +275,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
78735 }
78736 smpboot_unpark_thread(plug_thread, cpu);
78737 }
78738 - list_add(&plug_thread->list, &hotplug_threads);
78739 + pax_list_add(&plug_thread->list, &hotplug_threads);
78740 out:
78741 mutex_unlock(&smpboot_threads_lock);
78742 return ret;
78743 @@ -292,7 +292,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
78744 {
78745 get_online_cpus();
78746 mutex_lock(&smpboot_threads_lock);
78747 - list_del(&plug_thread->list);
78748 + pax_list_del(&plug_thread->list);
78749 smpboot_destroy_threads(plug_thread);
78750 mutex_unlock(&smpboot_threads_lock);
78751 put_online_cpus();
78752 diff --git a/kernel/softirq.c b/kernel/softirq.c
78753 index ed567ba..e71dabf 100644
78754 --- a/kernel/softirq.c
78755 +++ b/kernel/softirq.c
78756 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
78757 EXPORT_SYMBOL(irq_stat);
78758 #endif
78759
78760 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
78761 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
78762
78763 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
78764
78765 -char *softirq_to_name[NR_SOFTIRQS] = {
78766 +const char * const softirq_to_name[NR_SOFTIRQS] = {
78767 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
78768 "TASKLET", "SCHED", "HRTIMER", "RCU"
78769 };
78770 @@ -244,7 +244,7 @@ restart:
78771 kstat_incr_softirqs_this_cpu(vec_nr);
78772
78773 trace_softirq_entry(vec_nr);
78774 - h->action(h);
78775 + h->action();
78776 trace_softirq_exit(vec_nr);
78777 if (unlikely(prev_count != preempt_count())) {
78778 printk(KERN_ERR "huh, entered softirq %u %s %p"
78779 @@ -391,7 +391,7 @@ void __raise_softirq_irqoff(unsigned int nr)
78780 or_softirq_pending(1UL << nr);
78781 }
78782
78783 -void open_softirq(int nr, void (*action)(struct softirq_action *))
78784 +void __init open_softirq(int nr, void (*action)(void))
78785 {
78786 softirq_vec[nr].action = action;
78787 }
78788 @@ -447,7 +447,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
78789
78790 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
78791
78792 -static void tasklet_action(struct softirq_action *a)
78793 +static void tasklet_action(void)
78794 {
78795 struct tasklet_struct *list;
78796
78797 @@ -482,7 +482,7 @@ static void tasklet_action(struct softirq_action *a)
78798 }
78799 }
78800
78801 -static void tasklet_hi_action(struct softirq_action *a)
78802 +static void tasklet_hi_action(void)
78803 {
78804 struct tasklet_struct *list;
78805
78806 @@ -718,7 +718,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
78807 return NOTIFY_OK;
78808 }
78809
78810 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
78811 +static struct notifier_block remote_softirq_cpu_notifier = {
78812 .notifier_call = remote_softirq_cpu_notify,
78813 };
78814
78815 @@ -835,11 +835,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
78816 return NOTIFY_OK;
78817 }
78818
78819 -static struct notifier_block __cpuinitdata cpu_nfb = {
78820 +static struct notifier_block cpu_nfb = {
78821 .notifier_call = cpu_callback
78822 };
78823
78824 -static struct smp_hotplug_thread softirq_threads = {
78825 +static struct smp_hotplug_thread softirq_threads __read_only = {
78826 .store = &ksoftirqd,
78827 .thread_should_run = ksoftirqd_should_run,
78828 .thread_fn = run_ksoftirqd,
78829 diff --git a/kernel/srcu.c b/kernel/srcu.c
78830 index 2b85982..d52ab26 100644
78831 --- a/kernel/srcu.c
78832 +++ b/kernel/srcu.c
78833 @@ -305,9 +305,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
78834 preempt_disable();
78835 idx = rcu_dereference_index_check(sp->completed,
78836 rcu_read_lock_sched_held()) & 0x1;
78837 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78838 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78839 smp_mb(); /* B */ /* Avoid leaking the critical section. */
78840 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78841 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78842 preempt_enable();
78843 return idx;
78844 }
78845 @@ -323,7 +323,7 @@ void __srcu_read_unlock(struct srcu_struct *sp, int idx)
78846 {
78847 preempt_disable();
78848 smp_mb(); /* C */ /* Avoid leaking the critical section. */
78849 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
78850 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
78851 preempt_enable();
78852 }
78853 EXPORT_SYMBOL_GPL(__srcu_read_unlock);
78854 diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
78855 index 2f194e9..2c05ea9 100644
78856 --- a/kernel/stop_machine.c
78857 +++ b/kernel/stop_machine.c
78858 @@ -362,7 +362,7 @@ static int __cpuinit cpu_stop_cpu_callback(struct notifier_block *nfb,
78859 * cpu notifiers. It currently shares the same priority as sched
78860 * migration_notifier.
78861 */
78862 -static struct notifier_block __cpuinitdata cpu_stop_cpu_notifier = {
78863 +static struct notifier_block cpu_stop_cpu_notifier = {
78864 .notifier_call = cpu_stop_cpu_callback,
78865 .priority = 10,
78866 };
78867 diff --git a/kernel/sys.c b/kernel/sys.c
78868 index 265b376..4e42ef5 100644
78869 --- a/kernel/sys.c
78870 +++ b/kernel/sys.c
78871 @@ -157,6 +157,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
78872 error = -EACCES;
78873 goto out;
78874 }
78875 +
78876 + if (gr_handle_chroot_setpriority(p, niceval)) {
78877 + error = -EACCES;
78878 + goto out;
78879 + }
78880 +
78881 no_nice = security_task_setnice(p, niceval);
78882 if (no_nice) {
78883 error = no_nice;
78884 @@ -595,6 +601,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
78885 goto error;
78886 }
78887
78888 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
78889 + goto error;
78890 +
78891 if (rgid != (gid_t) -1 ||
78892 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
78893 new->sgid = new->egid;
78894 @@ -630,6 +639,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
78895 old = current_cred();
78896
78897 retval = -EPERM;
78898 +
78899 + if (gr_check_group_change(kgid, kgid, kgid))
78900 + goto error;
78901 +
78902 if (nsown_capable(CAP_SETGID))
78903 new->gid = new->egid = new->sgid = new->fsgid = kgid;
78904 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
78905 @@ -647,7 +660,7 @@ error:
78906 /*
78907 * change the user struct in a credentials set to match the new UID
78908 */
78909 -static int set_user(struct cred *new)
78910 +int set_user(struct cred *new)
78911 {
78912 struct user_struct *new_user;
78913
78914 @@ -727,6 +740,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
78915 goto error;
78916 }
78917
78918 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
78919 + goto error;
78920 +
78921 if (!uid_eq(new->uid, old->uid)) {
78922 retval = set_user(new);
78923 if (retval < 0)
78924 @@ -777,6 +793,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
78925 old = current_cred();
78926
78927 retval = -EPERM;
78928 +
78929 + if (gr_check_crash_uid(kuid))
78930 + goto error;
78931 + if (gr_check_user_change(kuid, kuid, kuid))
78932 + goto error;
78933 +
78934 if (nsown_capable(CAP_SETUID)) {
78935 new->suid = new->uid = kuid;
78936 if (!uid_eq(kuid, old->uid)) {
78937 @@ -846,6 +868,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
78938 goto error;
78939 }
78940
78941 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
78942 + goto error;
78943 +
78944 if (ruid != (uid_t) -1) {
78945 new->uid = kruid;
78946 if (!uid_eq(kruid, old->uid)) {
78947 @@ -928,6 +953,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
78948 goto error;
78949 }
78950
78951 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
78952 + goto error;
78953 +
78954 if (rgid != (gid_t) -1)
78955 new->gid = krgid;
78956 if (egid != (gid_t) -1)
78957 @@ -981,6 +1009,9 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
78958 if (!uid_valid(kuid))
78959 return old_fsuid;
78960
78961 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
78962 + goto error;
78963 +
78964 new = prepare_creds();
78965 if (!new)
78966 return old_fsuid;
78967 @@ -995,6 +1026,7 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
78968 }
78969 }
78970
78971 +error:
78972 abort_creds(new);
78973 return old_fsuid;
78974
78975 @@ -1027,12 +1059,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
78976 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
78977 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
78978 nsown_capable(CAP_SETGID)) {
78979 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
78980 + goto error;
78981 +
78982 if (!gid_eq(kgid, old->fsgid)) {
78983 new->fsgid = kgid;
78984 goto change_okay;
78985 }
78986 }
78987
78988 +error:
78989 abort_creds(new);
78990 return old_fsgid;
78991
78992 @@ -1340,19 +1376,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
78993 return -EFAULT;
78994
78995 down_read(&uts_sem);
78996 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
78997 + error = __copy_to_user(name->sysname, &utsname()->sysname,
78998 __OLD_UTS_LEN);
78999 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
79000 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
79001 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
79002 __OLD_UTS_LEN);
79003 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
79004 - error |= __copy_to_user(&name->release, &utsname()->release,
79005 + error |= __copy_to_user(name->release, &utsname()->release,
79006 __OLD_UTS_LEN);
79007 error |= __put_user(0, name->release + __OLD_UTS_LEN);
79008 - error |= __copy_to_user(&name->version, &utsname()->version,
79009 + error |= __copy_to_user(name->version, &utsname()->version,
79010 __OLD_UTS_LEN);
79011 error |= __put_user(0, name->version + __OLD_UTS_LEN);
79012 - error |= __copy_to_user(&name->machine, &utsname()->machine,
79013 + error |= __copy_to_user(name->machine, &utsname()->machine,
79014 __OLD_UTS_LEN);
79015 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
79016 up_read(&uts_sem);
79017 @@ -2026,7 +2062,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
79018 error = get_dumpable(me->mm);
79019 break;
79020 case PR_SET_DUMPABLE:
79021 - if (arg2 < 0 || arg2 > 1) {
79022 + if (arg2 > 1) {
79023 error = -EINVAL;
79024 break;
79025 }
79026 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
79027 index c88878d..e4fa5d1 100644
79028 --- a/kernel/sysctl.c
79029 +++ b/kernel/sysctl.c
79030 @@ -92,7 +92,6 @@
79031
79032
79033 #if defined(CONFIG_SYSCTL)
79034 -
79035 /* External variables not in a header file. */
79036 extern int sysctl_overcommit_memory;
79037 extern int sysctl_overcommit_ratio;
79038 @@ -172,10 +171,8 @@ static int proc_taint(struct ctl_table *table, int write,
79039 void __user *buffer, size_t *lenp, loff_t *ppos);
79040 #endif
79041
79042 -#ifdef CONFIG_PRINTK
79043 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79044 void __user *buffer, size_t *lenp, loff_t *ppos);
79045 -#endif
79046
79047 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
79048 void __user *buffer, size_t *lenp, loff_t *ppos);
79049 @@ -206,6 +203,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
79050
79051 #endif
79052
79053 +extern struct ctl_table grsecurity_table[];
79054 +
79055 static struct ctl_table kern_table[];
79056 static struct ctl_table vm_table[];
79057 static struct ctl_table fs_table[];
79058 @@ -220,6 +219,20 @@ extern struct ctl_table epoll_table[];
79059 int sysctl_legacy_va_layout;
79060 #endif
79061
79062 +#ifdef CONFIG_PAX_SOFTMODE
79063 +static ctl_table pax_table[] = {
79064 + {
79065 + .procname = "softmode",
79066 + .data = &pax_softmode,
79067 + .maxlen = sizeof(unsigned int),
79068 + .mode = 0600,
79069 + .proc_handler = &proc_dointvec,
79070 + },
79071 +
79072 + { }
79073 +};
79074 +#endif
79075 +
79076 /* The default sysctl tables: */
79077
79078 static struct ctl_table sysctl_base_table[] = {
79079 @@ -268,6 +281,22 @@ static int max_extfrag_threshold = 1000;
79080 #endif
79081
79082 static struct ctl_table kern_table[] = {
79083 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
79084 + {
79085 + .procname = "grsecurity",
79086 + .mode = 0500,
79087 + .child = grsecurity_table,
79088 + },
79089 +#endif
79090 +
79091 +#ifdef CONFIG_PAX_SOFTMODE
79092 + {
79093 + .procname = "pax",
79094 + .mode = 0500,
79095 + .child = pax_table,
79096 + },
79097 +#endif
79098 +
79099 {
79100 .procname = "sched_child_runs_first",
79101 .data = &sysctl_sched_child_runs_first,
79102 @@ -593,7 +622,7 @@ static struct ctl_table kern_table[] = {
79103 .data = &modprobe_path,
79104 .maxlen = KMOD_PATH_LEN,
79105 .mode = 0644,
79106 - .proc_handler = proc_dostring,
79107 + .proc_handler = proc_dostring_modpriv,
79108 },
79109 {
79110 .procname = "modules_disabled",
79111 @@ -760,16 +789,20 @@ static struct ctl_table kern_table[] = {
79112 .extra1 = &zero,
79113 .extra2 = &one,
79114 },
79115 +#endif
79116 {
79117 .procname = "kptr_restrict",
79118 .data = &kptr_restrict,
79119 .maxlen = sizeof(int),
79120 .mode = 0644,
79121 .proc_handler = proc_dointvec_minmax_sysadmin,
79122 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79123 + .extra1 = &two,
79124 +#else
79125 .extra1 = &zero,
79126 +#endif
79127 .extra2 = &two,
79128 },
79129 -#endif
79130 {
79131 .procname = "ngroups_max",
79132 .data = &ngroups_max,
79133 @@ -1266,6 +1299,13 @@ static struct ctl_table vm_table[] = {
79134 .proc_handler = proc_dointvec_minmax,
79135 .extra1 = &zero,
79136 },
79137 + {
79138 + .procname = "heap_stack_gap",
79139 + .data = &sysctl_heap_stack_gap,
79140 + .maxlen = sizeof(sysctl_heap_stack_gap),
79141 + .mode = 0644,
79142 + .proc_handler = proc_doulongvec_minmax,
79143 + },
79144 #else
79145 {
79146 .procname = "nr_trim_pages",
79147 @@ -1716,6 +1756,16 @@ int proc_dostring(struct ctl_table *table, int write,
79148 buffer, lenp, ppos);
79149 }
79150
79151 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79152 + void __user *buffer, size_t *lenp, loff_t *ppos)
79153 +{
79154 + if (write && !capable(CAP_SYS_MODULE))
79155 + return -EPERM;
79156 +
79157 + return _proc_do_string(table->data, table->maxlen, write,
79158 + buffer, lenp, ppos);
79159 +}
79160 +
79161 static size_t proc_skip_spaces(char **buf)
79162 {
79163 size_t ret;
79164 @@ -1821,6 +1871,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
79165 len = strlen(tmp);
79166 if (len > *size)
79167 len = *size;
79168 + if (len > sizeof(tmp))
79169 + len = sizeof(tmp);
79170 if (copy_to_user(*buf, tmp, len))
79171 return -EFAULT;
79172 *size -= len;
79173 @@ -1985,7 +2037,7 @@ int proc_dointvec(struct ctl_table *table, int write,
79174 static int proc_taint(struct ctl_table *table, int write,
79175 void __user *buffer, size_t *lenp, loff_t *ppos)
79176 {
79177 - struct ctl_table t;
79178 + ctl_table_no_const t;
79179 unsigned long tmptaint = get_taint();
79180 int err;
79181
79182 @@ -2013,7 +2065,6 @@ static int proc_taint(struct ctl_table *table, int write,
79183 return err;
79184 }
79185
79186 -#ifdef CONFIG_PRINTK
79187 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79188 void __user *buffer, size_t *lenp, loff_t *ppos)
79189 {
79190 @@ -2022,7 +2073,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79191
79192 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
79193 }
79194 -#endif
79195
79196 struct do_proc_dointvec_minmax_conv_param {
79197 int *min;
79198 @@ -2169,8 +2219,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
79199 *i = val;
79200 } else {
79201 val = convdiv * (*i) / convmul;
79202 - if (!first)
79203 + if (!first) {
79204 err = proc_put_char(&buffer, &left, '\t');
79205 + if (err)
79206 + break;
79207 + }
79208 err = proc_put_long(&buffer, &left, val, false);
79209 if (err)
79210 break;
79211 @@ -2562,6 +2615,12 @@ int proc_dostring(struct ctl_table *table, int write,
79212 return -ENOSYS;
79213 }
79214
79215 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79216 + void __user *buffer, size_t *lenp, loff_t *ppos)
79217 +{
79218 + return -ENOSYS;
79219 +}
79220 +
79221 int proc_dointvec(struct ctl_table *table, int write,
79222 void __user *buffer, size_t *lenp, loff_t *ppos)
79223 {
79224 @@ -2618,5 +2677,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
79225 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
79226 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
79227 EXPORT_SYMBOL(proc_dostring);
79228 +EXPORT_SYMBOL(proc_dostring_modpriv);
79229 EXPORT_SYMBOL(proc_doulongvec_minmax);
79230 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
79231 diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
79232 index 0ddf3a0..a199f50 100644
79233 --- a/kernel/sysctl_binary.c
79234 +++ b/kernel/sysctl_binary.c
79235 @@ -989,7 +989,7 @@ static ssize_t bin_intvec(struct file *file,
79236 int i;
79237
79238 set_fs(KERNEL_DS);
79239 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
79240 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
79241 set_fs(old_fs);
79242 if (result < 0)
79243 goto out_kfree;
79244 @@ -1034,7 +1034,7 @@ static ssize_t bin_intvec(struct file *file,
79245 }
79246
79247 set_fs(KERNEL_DS);
79248 - result = vfs_write(file, buffer, str - buffer, &pos);
79249 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
79250 set_fs(old_fs);
79251 if (result < 0)
79252 goto out_kfree;
79253 @@ -1067,7 +1067,7 @@ static ssize_t bin_ulongvec(struct file *file,
79254 int i;
79255
79256 set_fs(KERNEL_DS);
79257 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
79258 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
79259 set_fs(old_fs);
79260 if (result < 0)
79261 goto out_kfree;
79262 @@ -1112,7 +1112,7 @@ static ssize_t bin_ulongvec(struct file *file,
79263 }
79264
79265 set_fs(KERNEL_DS);
79266 - result = vfs_write(file, buffer, str - buffer, &pos);
79267 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
79268 set_fs(old_fs);
79269 if (result < 0)
79270 goto out_kfree;
79271 @@ -1138,7 +1138,7 @@ static ssize_t bin_uuid(struct file *file,
79272 int i;
79273
79274 set_fs(KERNEL_DS);
79275 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
79276 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
79277 set_fs(old_fs);
79278 if (result < 0)
79279 goto out;
79280 @@ -1185,7 +1185,7 @@ static ssize_t bin_dn_node_address(struct file *file,
79281 __le16 dnaddr;
79282
79283 set_fs(KERNEL_DS);
79284 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
79285 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
79286 set_fs(old_fs);
79287 if (result < 0)
79288 goto out;
79289 @@ -1234,7 +1234,7 @@ static ssize_t bin_dn_node_address(struct file *file,
79290 le16_to_cpu(dnaddr) & 0x3ff);
79291
79292 set_fs(KERNEL_DS);
79293 - result = vfs_write(file, buf, len, &pos);
79294 + result = vfs_write(file, (const char __force_user *)buf, len, &pos);
79295 set_fs(old_fs);
79296 if (result < 0)
79297 goto out;
79298 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
79299 index 145bb4d..b2aa969 100644
79300 --- a/kernel/taskstats.c
79301 +++ b/kernel/taskstats.c
79302 @@ -28,9 +28,12 @@
79303 #include <linux/fs.h>
79304 #include <linux/file.h>
79305 #include <linux/pid_namespace.h>
79306 +#include <linux/grsecurity.h>
79307 #include <net/genetlink.h>
79308 #include <linux/atomic.h>
79309
79310 +extern int gr_is_taskstats_denied(int pid);
79311 +
79312 /*
79313 * Maximum length of a cpumask that can be specified in
79314 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
79315 @@ -570,6 +573,9 @@ err:
79316
79317 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
79318 {
79319 + if (gr_is_taskstats_denied(current->pid))
79320 + return -EACCES;
79321 +
79322 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
79323 return cmd_attr_register_cpumask(info);
79324 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
79325 diff --git a/kernel/time.c b/kernel/time.c
79326 index d226c6a..2f0d217 100644
79327 --- a/kernel/time.c
79328 +++ b/kernel/time.c
79329 @@ -163,6 +163,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
79330 return error;
79331
79332 if (tz) {
79333 + /* we log in do_settimeofday called below, so don't log twice
79334 + */
79335 + if (!tv)
79336 + gr_log_timechange();
79337 +
79338 sys_tz = *tz;
79339 update_vsyscall_tz();
79340 if (firsttime) {
79341 @@ -493,7 +498,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
79342 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
79343 * value to a scaled second value.
79344 */
79345 -unsigned long
79346 +unsigned long __intentional_overflow(-1)
79347 timespec_to_jiffies(const struct timespec *value)
79348 {
79349 unsigned long sec = value->tv_sec;
79350 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
79351 index f11d83b..d016d91 100644
79352 --- a/kernel/time/alarmtimer.c
79353 +++ b/kernel/time/alarmtimer.c
79354 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
79355 struct platform_device *pdev;
79356 int error = 0;
79357 int i;
79358 - struct k_clock alarm_clock = {
79359 + static struct k_clock alarm_clock = {
79360 .clock_getres = alarm_clock_getres,
79361 .clock_get = alarm_clock_get,
79362 .timer_create = alarm_timer_create,
79363 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
79364 index a13987a..36cd791 100644
79365 --- a/kernel/time/tick-broadcast.c
79366 +++ b/kernel/time/tick-broadcast.c
79367 @@ -116,7 +116,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
79368 * then clear the broadcast bit.
79369 */
79370 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
79371 - int cpu = smp_processor_id();
79372 + cpu = smp_processor_id();
79373
79374 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
79375 tick_broadcast_clear_oneshot(cpu);
79376 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
79377 index cbc6acb..3a77191 100644
79378 --- a/kernel/time/timekeeping.c
79379 +++ b/kernel/time/timekeeping.c
79380 @@ -15,6 +15,7 @@
79381 #include <linux/init.h>
79382 #include <linux/mm.h>
79383 #include <linux/sched.h>
79384 +#include <linux/grsecurity.h>
79385 #include <linux/syscore_ops.h>
79386 #include <linux/clocksource.h>
79387 #include <linux/jiffies.h>
79388 @@ -412,6 +413,8 @@ int do_settimeofday(const struct timespec *tv)
79389 if (!timespec_valid_strict(tv))
79390 return -EINVAL;
79391
79392 + gr_log_timechange();
79393 +
79394 write_seqlock_irqsave(&tk->lock, flags);
79395
79396 timekeeping_forward_now(tk);
79397 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
79398 index af5a7e9..715611a 100644
79399 --- a/kernel/time/timer_list.c
79400 +++ b/kernel/time/timer_list.c
79401 @@ -38,12 +38,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
79402
79403 static void print_name_offset(struct seq_file *m, void *sym)
79404 {
79405 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79406 + SEQ_printf(m, "<%p>", NULL);
79407 +#else
79408 char symname[KSYM_NAME_LEN];
79409
79410 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
79411 SEQ_printf(m, "<%pK>", sym);
79412 else
79413 SEQ_printf(m, "%s", symname);
79414 +#endif
79415 }
79416
79417 static void
79418 @@ -112,7 +116,11 @@ next_one:
79419 static void
79420 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
79421 {
79422 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79423 + SEQ_printf(m, " .base: %p\n", NULL);
79424 +#else
79425 SEQ_printf(m, " .base: %pK\n", base);
79426 +#endif
79427 SEQ_printf(m, " .index: %d\n",
79428 base->index);
79429 SEQ_printf(m, " .resolution: %Lu nsecs\n",
79430 @@ -293,7 +301,11 @@ static int __init init_timer_list_procfs(void)
79431 {
79432 struct proc_dir_entry *pe;
79433
79434 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79435 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
79436 +#else
79437 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
79438 +#endif
79439 if (!pe)
79440 return -ENOMEM;
79441 return 0;
79442 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
79443 index 0b537f2..40d6c20 100644
79444 --- a/kernel/time/timer_stats.c
79445 +++ b/kernel/time/timer_stats.c
79446 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
79447 static unsigned long nr_entries;
79448 static struct entry entries[MAX_ENTRIES];
79449
79450 -static atomic_t overflow_count;
79451 +static atomic_unchecked_t overflow_count;
79452
79453 /*
79454 * The entries are in a hash-table, for fast lookup:
79455 @@ -140,7 +140,7 @@ static void reset_entries(void)
79456 nr_entries = 0;
79457 memset(entries, 0, sizeof(entries));
79458 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
79459 - atomic_set(&overflow_count, 0);
79460 + atomic_set_unchecked(&overflow_count, 0);
79461 }
79462
79463 static struct entry *alloc_entry(void)
79464 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79465 if (likely(entry))
79466 entry->count++;
79467 else
79468 - atomic_inc(&overflow_count);
79469 + atomic_inc_unchecked(&overflow_count);
79470
79471 out_unlock:
79472 raw_spin_unlock_irqrestore(lock, flags);
79473 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79474
79475 static void print_name_offset(struct seq_file *m, unsigned long addr)
79476 {
79477 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79478 + seq_printf(m, "<%p>", NULL);
79479 +#else
79480 char symname[KSYM_NAME_LEN];
79481
79482 if (lookup_symbol_name(addr, symname) < 0)
79483 - seq_printf(m, "<%p>", (void *)addr);
79484 + seq_printf(m, "<%pK>", (void *)addr);
79485 else
79486 seq_printf(m, "%s", symname);
79487 +#endif
79488 }
79489
79490 static int tstats_show(struct seq_file *m, void *v)
79491 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
79492
79493 seq_puts(m, "Timer Stats Version: v0.2\n");
79494 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
79495 - if (atomic_read(&overflow_count))
79496 + if (atomic_read_unchecked(&overflow_count))
79497 seq_printf(m, "Overflow: %d entries\n",
79498 - atomic_read(&overflow_count));
79499 + atomic_read_unchecked(&overflow_count));
79500
79501 for (i = 0; i < nr_entries; i++) {
79502 entry = entries + i;
79503 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
79504 {
79505 struct proc_dir_entry *pe;
79506
79507 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79508 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
79509 +#else
79510 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
79511 +#endif
79512 if (!pe)
79513 return -ENOMEM;
79514 return 0;
79515 diff --git a/kernel/timer.c b/kernel/timer.c
79516 index 367d008..5dee98f 100644
79517 --- a/kernel/timer.c
79518 +++ b/kernel/timer.c
79519 @@ -1363,7 +1363,7 @@ void update_process_times(int user_tick)
79520 /*
79521 * This function runs timers and the timer-tq in bottom half context.
79522 */
79523 -static void run_timer_softirq(struct softirq_action *h)
79524 +static void run_timer_softirq(void)
79525 {
79526 struct tvec_base *base = __this_cpu_read(tvec_bases);
79527
79528 @@ -1481,7 +1481,7 @@ static void process_timeout(unsigned long __data)
79529 *
79530 * In all cases the return value is guaranteed to be non-negative.
79531 */
79532 -signed long __sched schedule_timeout(signed long timeout)
79533 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
79534 {
79535 struct timer_list timer;
79536 unsigned long expire;
79537 @@ -1772,7 +1772,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
79538 return NOTIFY_OK;
79539 }
79540
79541 -static struct notifier_block __cpuinitdata timers_nb = {
79542 +static struct notifier_block timers_nb = {
79543 .notifier_call = timer_cpu_notify,
79544 };
79545
79546 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
79547 index c0bd030..62a1927 100644
79548 --- a/kernel/trace/blktrace.c
79549 +++ b/kernel/trace/blktrace.c
79550 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
79551 struct blk_trace *bt = filp->private_data;
79552 char buf[16];
79553
79554 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
79555 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
79556
79557 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
79558 }
79559 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
79560 return 1;
79561
79562 bt = buf->chan->private_data;
79563 - atomic_inc(&bt->dropped);
79564 + atomic_inc_unchecked(&bt->dropped);
79565 return 0;
79566 }
79567
79568 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
79569
79570 bt->dir = dir;
79571 bt->dev = dev;
79572 - atomic_set(&bt->dropped, 0);
79573 + atomic_set_unchecked(&bt->dropped, 0);
79574
79575 ret = -EIO;
79576 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
79577 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
79578 index b27052c..d99d82a 100644
79579 --- a/kernel/trace/ftrace.c
79580 +++ b/kernel/trace/ftrace.c
79581 @@ -668,7 +668,6 @@ int ftrace_profile_pages_init(struct ftrace_profile_stat *stat)
79582 free_page(tmp);
79583 }
79584
79585 - free_page((unsigned long)stat->pages);
79586 stat->pages = NULL;
79587 stat->start = NULL;
79588
79589 @@ -1874,12 +1873,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
79590 if (unlikely(ftrace_disabled))
79591 return 0;
79592
79593 + ret = ftrace_arch_code_modify_prepare();
79594 + FTRACE_WARN_ON(ret);
79595 + if (ret)
79596 + return 0;
79597 +
79598 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
79599 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
79600 if (ret) {
79601 ftrace_bug(ret, ip);
79602 - return 0;
79603 }
79604 - return 1;
79605 + return ret ? 0 : 1;
79606 }
79607
79608 /*
79609 @@ -2965,7 +2969,7 @@ static void ftrace_free_entry_rcu(struct rcu_head *rhp)
79610
79611 int
79612 register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
79613 - void *data)
79614 + void *data)
79615 {
79616 struct ftrace_func_probe *entry;
79617 struct ftrace_page *pg;
79618 @@ -3832,8 +3836,10 @@ static int ftrace_process_locs(struct module *mod,
79619 if (!count)
79620 return 0;
79621
79622 + pax_open_kernel();
79623 sort(start, count, sizeof(*start),
79624 ftrace_cmp_ips, ftrace_swap_ips);
79625 + pax_close_kernel();
79626
79627 start_pg = ftrace_allocate_pages(count);
79628 if (!start_pg)
79629 @@ -4559,8 +4565,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
79630 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
79631
79632 static int ftrace_graph_active;
79633 -static struct notifier_block ftrace_suspend_notifier;
79634 -
79635 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
79636 {
79637 return 0;
79638 @@ -4704,6 +4708,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
79639 return NOTIFY_DONE;
79640 }
79641
79642 +static struct notifier_block ftrace_suspend_notifier = {
79643 + .notifier_call = ftrace_suspend_notifier_call
79644 +};
79645 +
79646 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79647 trace_func_graph_ent_t entryfunc)
79648 {
79649 @@ -4717,7 +4725,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79650 goto out;
79651 }
79652
79653 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
79654 register_pm_notifier(&ftrace_suspend_notifier);
79655
79656 ftrace_graph_active++;
79657 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
79658 index ce8514f..8233573 100644
79659 --- a/kernel/trace/ring_buffer.c
79660 +++ b/kernel/trace/ring_buffer.c
79661 @@ -346,9 +346,9 @@ struct buffer_data_page {
79662 */
79663 struct buffer_page {
79664 struct list_head list; /* list of buffer pages */
79665 - local_t write; /* index for next write */
79666 + local_unchecked_t write; /* index for next write */
79667 unsigned read; /* index for next read */
79668 - local_t entries; /* entries on this page */
79669 + local_unchecked_t entries; /* entries on this page */
79670 unsigned long real_end; /* real end of data */
79671 struct buffer_data_page *page; /* Actual data page */
79672 };
79673 @@ -461,8 +461,8 @@ struct ring_buffer_per_cpu {
79674 unsigned long last_overrun;
79675 local_t entries_bytes;
79676 local_t entries;
79677 - local_t overrun;
79678 - local_t commit_overrun;
79679 + local_unchecked_t overrun;
79680 + local_unchecked_t commit_overrun;
79681 local_t dropped_events;
79682 local_t committing;
79683 local_t commits;
79684 @@ -861,8 +861,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79685 *
79686 * We add a counter to the write field to denote this.
79687 */
79688 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
79689 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
79690 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
79691 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
79692
79693 /*
79694 * Just make sure we have seen our old_write and synchronize
79695 @@ -890,8 +890,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79696 * cmpxchg to only update if an interrupt did not already
79697 * do it for us. If the cmpxchg fails, we don't care.
79698 */
79699 - (void)local_cmpxchg(&next_page->write, old_write, val);
79700 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
79701 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
79702 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
79703
79704 /*
79705 * No need to worry about races with clearing out the commit.
79706 @@ -1250,12 +1250,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
79707
79708 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
79709 {
79710 - return local_read(&bpage->entries) & RB_WRITE_MASK;
79711 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
79712 }
79713
79714 static inline unsigned long rb_page_write(struct buffer_page *bpage)
79715 {
79716 - return local_read(&bpage->write) & RB_WRITE_MASK;
79717 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
79718 }
79719
79720 static int
79721 @@ -1350,7 +1350,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
79722 * bytes consumed in ring buffer from here.
79723 * Increment overrun to account for the lost events.
79724 */
79725 - local_add(page_entries, &cpu_buffer->overrun);
79726 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
79727 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79728 }
79729
79730 @@ -1906,7 +1906,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
79731 * it is our responsibility to update
79732 * the counters.
79733 */
79734 - local_add(entries, &cpu_buffer->overrun);
79735 + local_add_unchecked(entries, &cpu_buffer->overrun);
79736 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79737
79738 /*
79739 @@ -2056,7 +2056,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79740 if (tail == BUF_PAGE_SIZE)
79741 tail_page->real_end = 0;
79742
79743 - local_sub(length, &tail_page->write);
79744 + local_sub_unchecked(length, &tail_page->write);
79745 return;
79746 }
79747
79748 @@ -2091,7 +2091,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79749 rb_event_set_padding(event);
79750
79751 /* Set the write back to the previous setting */
79752 - local_sub(length, &tail_page->write);
79753 + local_sub_unchecked(length, &tail_page->write);
79754 return;
79755 }
79756
79757 @@ -2103,7 +2103,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79758
79759 /* Set write to end of buffer */
79760 length = (tail + length) - BUF_PAGE_SIZE;
79761 - local_sub(length, &tail_page->write);
79762 + local_sub_unchecked(length, &tail_page->write);
79763 }
79764
79765 /*
79766 @@ -2129,7 +2129,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79767 * about it.
79768 */
79769 if (unlikely(next_page == commit_page)) {
79770 - local_inc(&cpu_buffer->commit_overrun);
79771 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79772 goto out_reset;
79773 }
79774
79775 @@ -2185,7 +2185,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79776 cpu_buffer->tail_page) &&
79777 (cpu_buffer->commit_page ==
79778 cpu_buffer->reader_page))) {
79779 - local_inc(&cpu_buffer->commit_overrun);
79780 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79781 goto out_reset;
79782 }
79783 }
79784 @@ -2233,7 +2233,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79785 length += RB_LEN_TIME_EXTEND;
79786
79787 tail_page = cpu_buffer->tail_page;
79788 - write = local_add_return(length, &tail_page->write);
79789 + write = local_add_return_unchecked(length, &tail_page->write);
79790
79791 /* set write to only the index of the write */
79792 write &= RB_WRITE_MASK;
79793 @@ -2250,7 +2250,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79794 kmemcheck_annotate_bitfield(event, bitfield);
79795 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
79796
79797 - local_inc(&tail_page->entries);
79798 + local_inc_unchecked(&tail_page->entries);
79799
79800 /*
79801 * If this is the first commit on the page, then update
79802 @@ -2283,7 +2283,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79803
79804 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
79805 unsigned long write_mask =
79806 - local_read(&bpage->write) & ~RB_WRITE_MASK;
79807 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
79808 unsigned long event_length = rb_event_length(event);
79809 /*
79810 * This is on the tail page. It is possible that
79811 @@ -2293,7 +2293,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79812 */
79813 old_index += write_mask;
79814 new_index += write_mask;
79815 - index = local_cmpxchg(&bpage->write, old_index, new_index);
79816 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
79817 if (index == old_index) {
79818 /* update counters */
79819 local_sub(event_length, &cpu_buffer->entries_bytes);
79820 @@ -2632,7 +2632,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79821
79822 /* Do the likely case first */
79823 if (likely(bpage->page == (void *)addr)) {
79824 - local_dec(&bpage->entries);
79825 + local_dec_unchecked(&bpage->entries);
79826 return;
79827 }
79828
79829 @@ -2644,7 +2644,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79830 start = bpage;
79831 do {
79832 if (bpage->page == (void *)addr) {
79833 - local_dec(&bpage->entries);
79834 + local_dec_unchecked(&bpage->entries);
79835 return;
79836 }
79837 rb_inc_page(cpu_buffer, &bpage);
79838 @@ -2926,7 +2926,7 @@ static inline unsigned long
79839 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
79840 {
79841 return local_read(&cpu_buffer->entries) -
79842 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
79843 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
79844 }
79845
79846 /**
79847 @@ -3015,7 +3015,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
79848 return 0;
79849
79850 cpu_buffer = buffer->buffers[cpu];
79851 - ret = local_read(&cpu_buffer->overrun);
79852 + ret = local_read_unchecked(&cpu_buffer->overrun);
79853
79854 return ret;
79855 }
79856 @@ -3038,7 +3038,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
79857 return 0;
79858
79859 cpu_buffer = buffer->buffers[cpu];
79860 - ret = local_read(&cpu_buffer->commit_overrun);
79861 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
79862
79863 return ret;
79864 }
79865 @@ -3105,7 +3105,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
79866 /* if you care about this being correct, lock the buffer */
79867 for_each_buffer_cpu(buffer, cpu) {
79868 cpu_buffer = buffer->buffers[cpu];
79869 - overruns += local_read(&cpu_buffer->overrun);
79870 + overruns += local_read_unchecked(&cpu_buffer->overrun);
79871 }
79872
79873 return overruns;
79874 @@ -3281,8 +3281,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79875 /*
79876 * Reset the reader page to size zero.
79877 */
79878 - local_set(&cpu_buffer->reader_page->write, 0);
79879 - local_set(&cpu_buffer->reader_page->entries, 0);
79880 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79881 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79882 local_set(&cpu_buffer->reader_page->page->commit, 0);
79883 cpu_buffer->reader_page->real_end = 0;
79884
79885 @@ -3316,7 +3316,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79886 * want to compare with the last_overrun.
79887 */
79888 smp_mb();
79889 - overwrite = local_read(&(cpu_buffer->overrun));
79890 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
79891
79892 /*
79893 * Here's the tricky part.
79894 @@ -3886,8 +3886,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79895
79896 cpu_buffer->head_page
79897 = list_entry(cpu_buffer->pages, struct buffer_page, list);
79898 - local_set(&cpu_buffer->head_page->write, 0);
79899 - local_set(&cpu_buffer->head_page->entries, 0);
79900 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
79901 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
79902 local_set(&cpu_buffer->head_page->page->commit, 0);
79903
79904 cpu_buffer->head_page->read = 0;
79905 @@ -3897,14 +3897,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79906
79907 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
79908 INIT_LIST_HEAD(&cpu_buffer->new_pages);
79909 - local_set(&cpu_buffer->reader_page->write, 0);
79910 - local_set(&cpu_buffer->reader_page->entries, 0);
79911 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79912 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79913 local_set(&cpu_buffer->reader_page->page->commit, 0);
79914 cpu_buffer->reader_page->read = 0;
79915
79916 local_set(&cpu_buffer->entries_bytes, 0);
79917 - local_set(&cpu_buffer->overrun, 0);
79918 - local_set(&cpu_buffer->commit_overrun, 0);
79919 + local_set_unchecked(&cpu_buffer->overrun, 0);
79920 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
79921 local_set(&cpu_buffer->dropped_events, 0);
79922 local_set(&cpu_buffer->entries, 0);
79923 local_set(&cpu_buffer->committing, 0);
79924 @@ -4308,8 +4308,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
79925 rb_init_page(bpage);
79926 bpage = reader->page;
79927 reader->page = *data_page;
79928 - local_set(&reader->write, 0);
79929 - local_set(&reader->entries, 0);
79930 + local_set_unchecked(&reader->write, 0);
79931 + local_set_unchecked(&reader->entries, 0);
79932 reader->read = 0;
79933 *data_page = bpage;
79934
79935 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
79936 index fe1d581..43a0f38 100644
79937 --- a/kernel/trace/trace.c
79938 +++ b/kernel/trace/trace.c
79939 @@ -4494,10 +4494,9 @@ static const struct file_operations tracing_dyn_info_fops = {
79940 };
79941 #endif
79942
79943 -static struct dentry *d_tracer;
79944 -
79945 struct dentry *tracing_init_dentry(void)
79946 {
79947 + static struct dentry *d_tracer;
79948 static int once;
79949
79950 if (d_tracer)
79951 @@ -4517,10 +4516,9 @@ struct dentry *tracing_init_dentry(void)
79952 return d_tracer;
79953 }
79954
79955 -static struct dentry *d_percpu;
79956 -
79957 struct dentry *tracing_dentry_percpu(void)
79958 {
79959 + static struct dentry *d_percpu;
79960 static int once;
79961 struct dentry *d_tracer;
79962
79963 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
79964 index 880073d..42db7c3 100644
79965 --- a/kernel/trace/trace_events.c
79966 +++ b/kernel/trace/trace_events.c
79967 @@ -1330,10 +1330,6 @@ static LIST_HEAD(ftrace_module_file_list);
79968 struct ftrace_module_file_ops {
79969 struct list_head list;
79970 struct module *mod;
79971 - struct file_operations id;
79972 - struct file_operations enable;
79973 - struct file_operations format;
79974 - struct file_operations filter;
79975 };
79976
79977 static struct ftrace_module_file_ops *
79978 @@ -1354,17 +1350,12 @@ trace_create_file_ops(struct module *mod)
79979
79980 file_ops->mod = mod;
79981
79982 - file_ops->id = ftrace_event_id_fops;
79983 - file_ops->id.owner = mod;
79984 -
79985 - file_ops->enable = ftrace_enable_fops;
79986 - file_ops->enable.owner = mod;
79987 -
79988 - file_ops->filter = ftrace_event_filter_fops;
79989 - file_ops->filter.owner = mod;
79990 -
79991 - file_ops->format = ftrace_event_format_fops;
79992 - file_ops->format.owner = mod;
79993 + pax_open_kernel();
79994 + mod->trace_id.owner = mod;
79995 + mod->trace_enable.owner = mod;
79996 + mod->trace_filter.owner = mod;
79997 + mod->trace_format.owner = mod;
79998 + pax_close_kernel();
79999
80000 list_add(&file_ops->list, &ftrace_module_file_list);
80001
80002 @@ -1388,8 +1379,8 @@ static void trace_module_add_events(struct module *mod)
80003
80004 for_each_event(call, start, end) {
80005 __trace_add_event_call(*call, mod,
80006 - &file_ops->id, &file_ops->enable,
80007 - &file_ops->filter, &file_ops->format);
80008 + &mod->trace_id, &mod->trace_enable,
80009 + &mod->trace_filter, &mod->trace_format);
80010 }
80011 }
80012
80013 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
80014 index fd3c8aa..5f324a6 100644
80015 --- a/kernel/trace/trace_mmiotrace.c
80016 +++ b/kernel/trace/trace_mmiotrace.c
80017 @@ -24,7 +24,7 @@ struct header_iter {
80018 static struct trace_array *mmio_trace_array;
80019 static bool overrun_detected;
80020 static unsigned long prev_overruns;
80021 -static atomic_t dropped_count;
80022 +static atomic_unchecked_t dropped_count;
80023
80024 static void mmio_reset_data(struct trace_array *tr)
80025 {
80026 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
80027
80028 static unsigned long count_overruns(struct trace_iterator *iter)
80029 {
80030 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
80031 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
80032 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
80033
80034 if (over > prev_overruns)
80035 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
80036 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
80037 sizeof(*entry), 0, pc);
80038 if (!event) {
80039 - atomic_inc(&dropped_count);
80040 + atomic_inc_unchecked(&dropped_count);
80041 return;
80042 }
80043 entry = ring_buffer_event_data(event);
80044 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
80045 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
80046 sizeof(*entry), 0, pc);
80047 if (!event) {
80048 - atomic_inc(&dropped_count);
80049 + atomic_inc_unchecked(&dropped_count);
80050 return;
80051 }
80052 entry = ring_buffer_event_data(event);
80053 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
80054 index 194d796..76edb8f 100644
80055 --- a/kernel/trace/trace_output.c
80056 +++ b/kernel/trace/trace_output.c
80057 @@ -278,7 +278,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
80058
80059 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
80060 if (!IS_ERR(p)) {
80061 - p = mangle_path(s->buffer + s->len, p, "\n");
80062 + p = mangle_path(s->buffer + s->len, p, "\n\\");
80063 if (p) {
80064 s->len = p - s->buffer;
80065 return 1;
80066 @@ -852,14 +852,16 @@ int register_ftrace_event(struct trace_event *event)
80067 goto out;
80068 }
80069
80070 + pax_open_kernel();
80071 if (event->funcs->trace == NULL)
80072 - event->funcs->trace = trace_nop_print;
80073 + *(void **)&event->funcs->trace = trace_nop_print;
80074 if (event->funcs->raw == NULL)
80075 - event->funcs->raw = trace_nop_print;
80076 + *(void **)&event->funcs->raw = trace_nop_print;
80077 if (event->funcs->hex == NULL)
80078 - event->funcs->hex = trace_nop_print;
80079 + *(void **)&event->funcs->hex = trace_nop_print;
80080 if (event->funcs->binary == NULL)
80081 - event->funcs->binary = trace_nop_print;
80082 + *(void **)&event->funcs->binary = trace_nop_print;
80083 + pax_close_kernel();
80084
80085 key = event->type & (EVENT_HASHSIZE - 1);
80086
80087 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
80088 index 42ca822..cdcacc6 100644
80089 --- a/kernel/trace/trace_stack.c
80090 +++ b/kernel/trace/trace_stack.c
80091 @@ -52,7 +52,7 @@ static inline void check_stack(void)
80092 return;
80093
80094 /* we do not handle interrupt stacks yet */
80095 - if (!object_is_on_stack(&this_size))
80096 + if (!object_starts_on_stack(&this_size))
80097 return;
80098
80099 local_irq_save(flags);
80100 diff --git a/kernel/user.c b/kernel/user.c
80101 index 7f6ff2b..1ac8f18 100644
80102 --- a/kernel/user.c
80103 +++ b/kernel/user.c
80104 @@ -47,9 +47,7 @@ struct user_namespace init_user_ns = {
80105 .count = 4294967295U,
80106 },
80107 },
80108 - .kref = {
80109 - .refcount = ATOMIC_INIT(3),
80110 - },
80111 + .count = ATOMIC_INIT(3),
80112 .owner = GLOBAL_ROOT_UID,
80113 .group = GLOBAL_ROOT_GID,
80114 .proc_inum = PROC_USER_INIT_INO,
80115 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
80116 index f45e128..a5a5fb6 100644
80117 --- a/kernel/user_namespace.c
80118 +++ b/kernel/user_namespace.c
80119 @@ -88,7 +88,7 @@ int create_user_ns(struct cred *new)
80120 return ret;
80121 }
80122
80123 - kref_init(&ns->kref);
80124 + atomic_set(&ns->count, 1);
80125 /* Leave the new->user_ns reference with the new user namespace. */
80126 ns->parent = parent_ns;
80127 ns->owner = owner;
80128 @@ -116,15 +116,16 @@ int unshare_userns(unsigned long unshare_flags, struct cred **new_cred)
80129 return create_user_ns(cred);
80130 }
80131
80132 -void free_user_ns(struct kref *kref)
80133 +void free_user_ns(struct user_namespace *ns)
80134 {
80135 - struct user_namespace *parent, *ns =
80136 - container_of(kref, struct user_namespace, kref);
80137 + struct user_namespace *parent;
80138
80139 - parent = ns->parent;
80140 - proc_free_inum(ns->proc_inum);
80141 - kmem_cache_free(user_ns_cachep, ns);
80142 - put_user_ns(parent);
80143 + do {
80144 + parent = ns->parent;
80145 + proc_free_inum(ns->proc_inum);
80146 + kmem_cache_free(user_ns_cachep, ns);
80147 + ns = parent;
80148 + } while (atomic_dec_and_test(&parent->count));
80149 }
80150 EXPORT_SYMBOL(free_user_ns);
80151
80152 @@ -815,7 +816,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
80153 if (atomic_read(&current->mm->mm_users) > 1)
80154 return -EINVAL;
80155
80156 - if (current->fs->users != 1)
80157 + if (atomic_read(&current->fs->users) != 1)
80158 return -EINVAL;
80159
80160 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
80161 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
80162 index 63da38c..639904e 100644
80163 --- a/kernel/utsname_sysctl.c
80164 +++ b/kernel/utsname_sysctl.c
80165 @@ -46,7 +46,7 @@ static void put_uts(ctl_table *table, int write, void *which)
80166 static int proc_do_uts_string(ctl_table *table, int write,
80167 void __user *buffer, size_t *lenp, loff_t *ppos)
80168 {
80169 - struct ctl_table uts_table;
80170 + ctl_table_no_const uts_table;
80171 int r;
80172 memcpy(&uts_table, table, sizeof(uts_table));
80173 uts_table.data = get_uts(table, write);
80174 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
80175 index 75a2ab3..5961da7 100644
80176 --- a/kernel/watchdog.c
80177 +++ b/kernel/watchdog.c
80178 @@ -527,7 +527,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
80179 }
80180 #endif /* CONFIG_SYSCTL */
80181
80182 -static struct smp_hotplug_thread watchdog_threads = {
80183 +static struct smp_hotplug_thread watchdog_threads __read_only = {
80184 .store = &softlockup_watchdog,
80185 .thread_should_run = watchdog_should_run,
80186 .thread_fn = watchdog,
80187 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
80188 index 67604e5..fe94fb1 100644
80189 --- a/lib/Kconfig.debug
80190 +++ b/lib/Kconfig.debug
80191 @@ -550,7 +550,7 @@ config DEBUG_MUTEXES
80192
80193 config DEBUG_LOCK_ALLOC
80194 bool "Lock debugging: detect incorrect freeing of live locks"
80195 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80196 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80197 select DEBUG_SPINLOCK
80198 select DEBUG_MUTEXES
80199 select LOCKDEP
80200 @@ -564,7 +564,7 @@ config DEBUG_LOCK_ALLOC
80201
80202 config PROVE_LOCKING
80203 bool "Lock debugging: prove locking correctness"
80204 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80205 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80206 select LOCKDEP
80207 select DEBUG_SPINLOCK
80208 select DEBUG_MUTEXES
80209 @@ -670,7 +670,7 @@ config LOCKDEP
80210
80211 config LOCK_STAT
80212 bool "Lock usage statistics"
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 LOCKDEP
80216 select DEBUG_SPINLOCK
80217 select DEBUG_MUTEXES
80218 @@ -1278,6 +1278,7 @@ config LATENCYTOP
80219 depends on DEBUG_KERNEL
80220 depends on STACKTRACE_SUPPORT
80221 depends on PROC_FS
80222 + depends on !GRKERNSEC_HIDESYM
80223 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
80224 select KALLSYMS
80225 select KALLSYMS_ALL
80226 @@ -1306,7 +1307,7 @@ config INTERVAL_TREE_TEST
80227
80228 config PROVIDE_OHCI1394_DMA_INIT
80229 bool "Remote debugging over FireWire early on boot"
80230 - depends on PCI && X86
80231 + depends on PCI && X86 && !GRKERNSEC
80232 help
80233 If you want to debug problems which hang or crash the kernel early
80234 on boot and the crashing machine has a FireWire port, you can use
80235 @@ -1335,7 +1336,7 @@ config PROVIDE_OHCI1394_DMA_INIT
80236
80237 config FIREWIRE_OHCI_REMOTE_DMA
80238 bool "Remote debugging over FireWire with firewire-ohci"
80239 - depends on FIREWIRE_OHCI
80240 + depends on FIREWIRE_OHCI && !GRKERNSEC
80241 help
80242 This option lets you use the FireWire bus for remote debugging
80243 with help of the firewire-ohci driver. It enables unfiltered
80244 diff --git a/lib/Makefile b/lib/Makefile
80245 index 02ed6c0..bd243da 100644
80246 --- a/lib/Makefile
80247 +++ b/lib/Makefile
80248 @@ -47,7 +47,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
80249
80250 obj-$(CONFIG_BTREE) += btree.o
80251 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
80252 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
80253 +obj-y += list_debug.o
80254 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
80255
80256 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
80257 diff --git a/lib/bitmap.c b/lib/bitmap.c
80258 index 06f7e4f..f3cf2b0 100644
80259 --- a/lib/bitmap.c
80260 +++ b/lib/bitmap.c
80261 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
80262 {
80263 int c, old_c, totaldigits, ndigits, nchunks, nbits;
80264 u32 chunk;
80265 - const char __user __force *ubuf = (const char __user __force *)buf;
80266 + const char __user *ubuf = (const char __force_user *)buf;
80267
80268 bitmap_zero(maskp, nmaskbits);
80269
80270 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
80271 {
80272 if (!access_ok(VERIFY_READ, ubuf, ulen))
80273 return -EFAULT;
80274 - return __bitmap_parse((const char __force *)ubuf,
80275 + return __bitmap_parse((const char __force_kernel *)ubuf,
80276 ulen, 1, maskp, nmaskbits);
80277
80278 }
80279 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
80280 {
80281 unsigned a, b;
80282 int c, old_c, totaldigits;
80283 - const char __user __force *ubuf = (const char __user __force *)buf;
80284 + const char __user *ubuf = (const char __force_user *)buf;
80285 int exp_digit, in_range;
80286
80287 totaldigits = c = 0;
80288 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
80289 {
80290 if (!access_ok(VERIFY_READ, ubuf, ulen))
80291 return -EFAULT;
80292 - return __bitmap_parselist((const char __force *)ubuf,
80293 + return __bitmap_parselist((const char __force_kernel *)ubuf,
80294 ulen, 1, maskp, nmaskbits);
80295 }
80296 EXPORT_SYMBOL(bitmap_parselist_user);
80297 diff --git a/lib/bug.c b/lib/bug.c
80298 index d0cdf14..4d07bd2 100644
80299 --- a/lib/bug.c
80300 +++ b/lib/bug.c
80301 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
80302 return BUG_TRAP_TYPE_NONE;
80303
80304 bug = find_bug(bugaddr);
80305 + if (!bug)
80306 + return BUG_TRAP_TYPE_NONE;
80307
80308 file = NULL;
80309 line = 0;
80310 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
80311 index d11808c..dc2d6f8 100644
80312 --- a/lib/debugobjects.c
80313 +++ b/lib/debugobjects.c
80314 @@ -287,7 +287,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
80315 if (limit > 4)
80316 return;
80317
80318 - is_on_stack = object_is_on_stack(addr);
80319 + is_on_stack = object_starts_on_stack(addr);
80320 if (is_on_stack == onstack)
80321 return;
80322
80323 diff --git a/lib/devres.c b/lib/devres.c
80324 index 80b9c76..9e32279 100644
80325 --- a/lib/devres.c
80326 +++ b/lib/devres.c
80327 @@ -80,7 +80,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
80328 void devm_iounmap(struct device *dev, void __iomem *addr)
80329 {
80330 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
80331 - (void *)addr));
80332 + (void __force *)addr));
80333 iounmap(addr);
80334 }
80335 EXPORT_SYMBOL(devm_iounmap);
80336 @@ -192,7 +192,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
80337 {
80338 ioport_unmap(addr);
80339 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
80340 - devm_ioport_map_match, (void *)addr));
80341 + devm_ioport_map_match, (void __force *)addr));
80342 }
80343 EXPORT_SYMBOL(devm_ioport_unmap);
80344
80345 diff --git a/lib/div64.c b/lib/div64.c
80346 index a163b6c..9618fa5 100644
80347 --- a/lib/div64.c
80348 +++ b/lib/div64.c
80349 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
80350 EXPORT_SYMBOL(__div64_32);
80351
80352 #ifndef div_s64_rem
80353 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80354 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80355 {
80356 u64 quotient;
80357
80358 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
80359 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
80360 */
80361 #ifndef div64_u64
80362 -u64 div64_u64(u64 dividend, u64 divisor)
80363 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
80364 {
80365 u32 high = divisor >> 32;
80366 u64 quot;
80367 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
80368 index 5e396ac..58d5de1 100644
80369 --- a/lib/dma-debug.c
80370 +++ b/lib/dma-debug.c
80371 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
80372
80373 void dma_debug_add_bus(struct bus_type *bus)
80374 {
80375 - struct notifier_block *nb;
80376 + notifier_block_no_const *nb;
80377
80378 if (global_disable)
80379 return;
80380 @@ -942,7 +942,7 @@ out:
80381
80382 static void check_for_stack(struct device *dev, void *addr)
80383 {
80384 - if (object_is_on_stack(addr))
80385 + if (object_starts_on_stack(addr))
80386 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
80387 "stack [addr=%p]\n", addr);
80388 }
80389 diff --git a/lib/inflate.c b/lib/inflate.c
80390 index 013a761..c28f3fc 100644
80391 --- a/lib/inflate.c
80392 +++ b/lib/inflate.c
80393 @@ -269,7 +269,7 @@ static void free(void *where)
80394 malloc_ptr = free_mem_ptr;
80395 }
80396 #else
80397 -#define malloc(a) kmalloc(a, GFP_KERNEL)
80398 +#define malloc(a) kmalloc((a), GFP_KERNEL)
80399 #define free(a) kfree(a)
80400 #endif
80401
80402 diff --git a/lib/ioremap.c b/lib/ioremap.c
80403 index 0c9216c..863bd89 100644
80404 --- a/lib/ioremap.c
80405 +++ b/lib/ioremap.c
80406 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
80407 unsigned long next;
80408
80409 phys_addr -= addr;
80410 - pmd = pmd_alloc(&init_mm, pud, addr);
80411 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
80412 if (!pmd)
80413 return -ENOMEM;
80414 do {
80415 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
80416 unsigned long next;
80417
80418 phys_addr -= addr;
80419 - pud = pud_alloc(&init_mm, pgd, addr);
80420 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
80421 if (!pud)
80422 return -ENOMEM;
80423 do {
80424 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
80425 index bd2bea9..6b3c95e 100644
80426 --- a/lib/is_single_threaded.c
80427 +++ b/lib/is_single_threaded.c
80428 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
80429 struct task_struct *p, *t;
80430 bool ret;
80431
80432 + if (!mm)
80433 + return true;
80434 +
80435 if (atomic_read(&task->signal->live) != 1)
80436 return false;
80437
80438 diff --git a/lib/kobject.c b/lib/kobject.c
80439 index e07ee1f..998489d 100644
80440 --- a/lib/kobject.c
80441 +++ b/lib/kobject.c
80442 @@ -852,9 +852,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
80443
80444
80445 static DEFINE_SPINLOCK(kobj_ns_type_lock);
80446 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
80447 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
80448
80449 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80450 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80451 {
80452 enum kobj_ns_type type = ops->type;
80453 int error;
80454 diff --git a/lib/list_debug.c b/lib/list_debug.c
80455 index c24c2f7..06e070b 100644
80456 --- a/lib/list_debug.c
80457 +++ b/lib/list_debug.c
80458 @@ -11,7 +11,9 @@
80459 #include <linux/bug.h>
80460 #include <linux/kernel.h>
80461 #include <linux/rculist.h>
80462 +#include <linux/mm.h>
80463
80464 +#ifdef CONFIG_DEBUG_LIST
80465 /*
80466 * Insert a new entry between two known consecutive entries.
80467 *
80468 @@ -19,21 +21,32 @@
80469 * the prev/next entries already!
80470 */
80471
80472 -void __list_add(struct list_head *new,
80473 - struct list_head *prev,
80474 - struct list_head *next)
80475 +static bool __list_add_debug(struct list_head *new,
80476 + struct list_head *prev,
80477 + struct list_head *next)
80478 {
80479 - WARN(next->prev != prev,
80480 + if (WARN(next->prev != prev,
80481 "list_add corruption. next->prev should be "
80482 "prev (%p), but was %p. (next=%p).\n",
80483 - prev, next->prev, next);
80484 - WARN(prev->next != next,
80485 + prev, next->prev, next) ||
80486 + WARN(prev->next != next,
80487 "list_add corruption. prev->next should be "
80488 "next (%p), but was %p. (prev=%p).\n",
80489 - next, prev->next, prev);
80490 - WARN(new == prev || new == next,
80491 - "list_add double add: new=%p, prev=%p, next=%p.\n",
80492 - new, prev, next);
80493 + next, prev->next, prev) ||
80494 + WARN(new == prev || new == next,
80495 + "list_add double add: new=%p, prev=%p, next=%p.\n",
80496 + new, prev, next))
80497 + return false;
80498 + return true;
80499 +}
80500 +
80501 +void __list_add(struct list_head *new,
80502 + struct list_head *prev,
80503 + struct list_head *next)
80504 +{
80505 + if (!__list_add_debug(new, prev, next))
80506 + return;
80507 +
80508 next->prev = new;
80509 new->next = next;
80510 new->prev = prev;
80511 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
80512 }
80513 EXPORT_SYMBOL(__list_add);
80514
80515 -void __list_del_entry(struct list_head *entry)
80516 +static bool __list_del_entry_debug(struct list_head *entry)
80517 {
80518 struct list_head *prev, *next;
80519
80520 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
80521 WARN(next->prev != entry,
80522 "list_del corruption. next->prev should be %p, "
80523 "but was %p\n", entry, next->prev))
80524 + return false;
80525 + return true;
80526 +}
80527 +
80528 +void __list_del_entry(struct list_head *entry)
80529 +{
80530 + if (!__list_del_entry_debug(entry))
80531 return;
80532
80533 - __list_del(prev, next);
80534 + __list_del(entry->prev, entry->next);
80535 }
80536 EXPORT_SYMBOL(__list_del_entry);
80537
80538 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
80539 void __list_add_rcu(struct list_head *new,
80540 struct list_head *prev, struct list_head *next)
80541 {
80542 - WARN(next->prev != prev,
80543 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
80544 - prev, next->prev, next);
80545 - WARN(prev->next != next,
80546 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
80547 - next, prev->next, prev);
80548 + if (!__list_add_debug(new, prev, next))
80549 + return;
80550 +
80551 new->next = next;
80552 new->prev = prev;
80553 rcu_assign_pointer(list_next_rcu(prev), new);
80554 next->prev = new;
80555 }
80556 EXPORT_SYMBOL(__list_add_rcu);
80557 +#endif
80558 +
80559 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
80560 +{
80561 +#ifdef CONFIG_DEBUG_LIST
80562 + if (!__list_add_debug(new, prev, next))
80563 + return;
80564 +#endif
80565 +
80566 + pax_open_kernel();
80567 + next->prev = new;
80568 + new->next = next;
80569 + new->prev = prev;
80570 + prev->next = new;
80571 + pax_close_kernel();
80572 +}
80573 +EXPORT_SYMBOL(__pax_list_add);
80574 +
80575 +void pax_list_del(struct list_head *entry)
80576 +{
80577 +#ifdef CONFIG_DEBUG_LIST
80578 + if (!__list_del_entry_debug(entry))
80579 + return;
80580 +#endif
80581 +
80582 + pax_open_kernel();
80583 + __list_del(entry->prev, entry->next);
80584 + entry->next = LIST_POISON1;
80585 + entry->prev = LIST_POISON2;
80586 + pax_close_kernel();
80587 +}
80588 +EXPORT_SYMBOL(pax_list_del);
80589 +
80590 +void pax_list_del_init(struct list_head *entry)
80591 +{
80592 + pax_open_kernel();
80593 + __list_del(entry->prev, entry->next);
80594 + INIT_LIST_HEAD(entry);
80595 + pax_close_kernel();
80596 +}
80597 +EXPORT_SYMBOL(pax_list_del_init);
80598 +
80599 +void __pax_list_add_rcu(struct list_head *new,
80600 + struct list_head *prev, struct list_head *next)
80601 +{
80602 +#ifdef CONFIG_DEBUG_LIST
80603 + if (!__list_add_debug(new, prev, next))
80604 + return;
80605 +#endif
80606 +
80607 + pax_open_kernel();
80608 + new->next = next;
80609 + new->prev = prev;
80610 + rcu_assign_pointer(list_next_rcu(prev), new);
80611 + next->prev = new;
80612 + pax_close_kernel();
80613 +}
80614 +EXPORT_SYMBOL(__pax_list_add_rcu);
80615 +
80616 +void pax_list_del_rcu(struct list_head *entry)
80617 +{
80618 +#ifdef CONFIG_DEBUG_LIST
80619 + if (!__list_del_entry_debug(entry))
80620 + return;
80621 +#endif
80622 +
80623 + pax_open_kernel();
80624 + __list_del(entry->prev, entry->next);
80625 + entry->next = LIST_POISON1;
80626 + entry->prev = LIST_POISON2;
80627 + pax_close_kernel();
80628 +}
80629 +EXPORT_SYMBOL(pax_list_del_rcu);
80630 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
80631 index e796429..6e38f9f 100644
80632 --- a/lib/radix-tree.c
80633 +++ b/lib/radix-tree.c
80634 @@ -92,7 +92,7 @@ struct radix_tree_preload {
80635 int nr;
80636 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
80637 };
80638 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
80639 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
80640
80641 static inline void *ptr_to_indirect(void *ptr)
80642 {
80643 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
80644 index bb2b201..46abaf9 100644
80645 --- a/lib/strncpy_from_user.c
80646 +++ b/lib/strncpy_from_user.c
80647 @@ -21,7 +21,7 @@
80648 */
80649 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
80650 {
80651 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80652 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80653 long res = 0;
80654
80655 /*
80656 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
80657 index a28df52..3d55877 100644
80658 --- a/lib/strnlen_user.c
80659 +++ b/lib/strnlen_user.c
80660 @@ -26,7 +26,7 @@
80661 */
80662 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
80663 {
80664 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80665 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80666 long align, res = 0;
80667 unsigned long c;
80668
80669 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
80670 index 196b069..358f342 100644
80671 --- a/lib/swiotlb.c
80672 +++ b/lib/swiotlb.c
80673 @@ -642,7 +642,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
80674
80675 void
80676 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
80677 - dma_addr_t dev_addr)
80678 + dma_addr_t dev_addr, struct dma_attrs *attrs)
80679 {
80680 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
80681
80682 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
80683 index fab33a9..3b5fe68 100644
80684 --- a/lib/vsprintf.c
80685 +++ b/lib/vsprintf.c
80686 @@ -16,6 +16,9 @@
80687 * - scnprintf and vscnprintf
80688 */
80689
80690 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80691 +#define __INCLUDED_BY_HIDESYM 1
80692 +#endif
80693 #include <stdarg.h>
80694 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
80695 #include <linux/types.h>
80696 @@ -541,7 +544,7 @@ char *symbol_string(char *buf, char *end, void *ptr,
80697 char sym[KSYM_SYMBOL_LEN];
80698 if (ext == 'B')
80699 sprint_backtrace(sym, value);
80700 - else if (ext != 'f' && ext != 's')
80701 + else if (ext != 'f' && ext != 's' && ext != 'a')
80702 sprint_symbol(sym, value);
80703 else
80704 sprint_symbol_no_offset(sym, value);
80705 @@ -974,7 +977,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
80706 return number(buf, end, *(const netdev_features_t *)addr, spec);
80707 }
80708
80709 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80710 +int kptr_restrict __read_mostly = 2;
80711 +#else
80712 int kptr_restrict __read_mostly;
80713 +#endif
80714
80715 /*
80716 * Show a '%p' thing. A kernel extension is that the '%p' is followed
80717 @@ -988,6 +995,8 @@ int kptr_restrict __read_mostly;
80718 * - 'S' For symbolic direct pointers with offset
80719 * - 's' For symbolic direct pointers without offset
80720 * - 'B' For backtraced symbolic direct pointers with offset
80721 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
80722 + * - 'a' For symbolic direct pointers without offset approved for use with GRKERNSEC_HIDESYM
80723 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
80724 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
80725 * - 'M' For a 6-byte MAC address, it prints the address in the
80726 @@ -1043,12 +1052,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80727
80728 if (!ptr && *fmt != 'K') {
80729 /*
80730 - * Print (null) with the same width as a pointer so it makes
80731 + * Print (nil) with the same width as a pointer so it makes
80732 * tabular output look nice.
80733 */
80734 if (spec.field_width == -1)
80735 spec.field_width = default_width;
80736 - return string(buf, end, "(null)", spec);
80737 + return string(buf, end, "(nil)", spec);
80738 }
80739
80740 switch (*fmt) {
80741 @@ -1058,6 +1067,13 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80742 /* Fallthrough */
80743 case 'S':
80744 case 's':
80745 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80746 + break;
80747 +#else
80748 + return symbol_string(buf, end, ptr, spec, *fmt);
80749 +#endif
80750 + case 'A':
80751 + case 'a':
80752 case 'B':
80753 return symbol_string(buf, end, ptr, spec, *fmt);
80754 case 'R':
80755 @@ -1098,6 +1114,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80756 va_end(va);
80757 return buf;
80758 }
80759 + case 'P':
80760 + break;
80761 case 'K':
80762 /*
80763 * %pK cannot be used in IRQ context because its test
80764 @@ -1121,6 +1139,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80765 }
80766 break;
80767 }
80768 +
80769 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80770 + /* 'P' = approved pointers to copy to userland,
80771 + as in the /proc/kallsyms case, as we make it display nothing
80772 + for non-root users, and the real contents for root users
80773 + Also ignore 'K' pointers, since we force their NULLing for non-root users
80774 + above
80775 + */
80776 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
80777 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
80778 + dump_stack();
80779 + ptr = NULL;
80780 + }
80781 +#endif
80782 +
80783 spec.flags |= SMALL;
80784 if (spec.field_width == -1) {
80785 spec.field_width = default_width;
80786 @@ -1842,11 +1875,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80787 typeof(type) value; \
80788 if (sizeof(type) == 8) { \
80789 args = PTR_ALIGN(args, sizeof(u32)); \
80790 - *(u32 *)&value = *(u32 *)args; \
80791 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
80792 + *(u32 *)&value = *(const u32 *)args; \
80793 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
80794 } else { \
80795 args = PTR_ALIGN(args, sizeof(type)); \
80796 - value = *(typeof(type) *)args; \
80797 + value = *(const typeof(type) *)args; \
80798 } \
80799 args += sizeof(type); \
80800 value; \
80801 @@ -1909,7 +1942,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80802 case FORMAT_TYPE_STR: {
80803 const char *str_arg = args;
80804 args += strlen(str_arg) + 1;
80805 - str = string(str, end, (char *)str_arg, spec);
80806 + str = string(str, end, str_arg, spec);
80807 break;
80808 }
80809
80810 diff --git a/localversion-grsec b/localversion-grsec
80811 new file mode 100644
80812 index 0000000..7cd6065
80813 --- /dev/null
80814 +++ b/localversion-grsec
80815 @@ -0,0 +1 @@
80816 +-grsec
80817 diff --git a/mm/Kconfig b/mm/Kconfig
80818 index 278e3ab..87c384d 100644
80819 --- a/mm/Kconfig
80820 +++ b/mm/Kconfig
80821 @@ -286,10 +286,10 @@ config KSM
80822 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
80823
80824 config DEFAULT_MMAP_MIN_ADDR
80825 - int "Low address space to protect from user allocation"
80826 + int "Low address space to protect from user allocation"
80827 depends on MMU
80828 - default 4096
80829 - help
80830 + default 65536
80831 + help
80832 This is the portion of low virtual memory which should be protected
80833 from userspace allocation. Keeping a user from writing to low pages
80834 can help reduce the impact of kernel NULL pointer bugs.
80835 @@ -320,7 +320,7 @@ config MEMORY_FAILURE
80836
80837 config HWPOISON_INJECT
80838 tristate "HWPoison pages injector"
80839 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
80840 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
80841 select PROC_PAGE_MONITOR
80842
80843 config NOMMU_INITIAL_TRIM_EXCESS
80844 diff --git a/mm/filemap.c b/mm/filemap.c
80845 index 83efee7..3f99381 100644
80846 --- a/mm/filemap.c
80847 +++ b/mm/filemap.c
80848 @@ -1747,7 +1747,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
80849 struct address_space *mapping = file->f_mapping;
80850
80851 if (!mapping->a_ops->readpage)
80852 - return -ENOEXEC;
80853 + return -ENODEV;
80854 file_accessed(file);
80855 vma->vm_ops = &generic_file_vm_ops;
80856 return 0;
80857 @@ -2087,6 +2087,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
80858 *pos = i_size_read(inode);
80859
80860 if (limit != RLIM_INFINITY) {
80861 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
80862 if (*pos >= limit) {
80863 send_sig(SIGXFSZ, current, 0);
80864 return -EFBIG;
80865 diff --git a/mm/fremap.c b/mm/fremap.c
80866 index a0aaf0e..20325c3 100644
80867 --- a/mm/fremap.c
80868 +++ b/mm/fremap.c
80869 @@ -157,6 +157,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
80870 retry:
80871 vma = find_vma(mm, start);
80872
80873 +#ifdef CONFIG_PAX_SEGMEXEC
80874 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
80875 + goto out;
80876 +#endif
80877 +
80878 /*
80879 * Make sure the vma is shared, that it supports prefaulting,
80880 * and that the remapped range is valid and fully within
80881 diff --git a/mm/highmem.c b/mm/highmem.c
80882 index b32b70c..e512eb0 100644
80883 --- a/mm/highmem.c
80884 +++ b/mm/highmem.c
80885 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
80886 * So no dangers, even with speculative execution.
80887 */
80888 page = pte_page(pkmap_page_table[i]);
80889 + pax_open_kernel();
80890 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
80891 -
80892 + pax_close_kernel();
80893 set_page_address(page, NULL);
80894 need_flush = 1;
80895 }
80896 @@ -198,9 +199,11 @@ start:
80897 }
80898 }
80899 vaddr = PKMAP_ADDR(last_pkmap_nr);
80900 +
80901 + pax_open_kernel();
80902 set_pte_at(&init_mm, vaddr,
80903 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
80904 -
80905 + pax_close_kernel();
80906 pkmap_count[last_pkmap_nr] = 1;
80907 set_page_address(page, (void *)vaddr);
80908
80909 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
80910 index d7cec92..b05cc33 100644
80911 --- a/mm/hugetlb.c
80912 +++ b/mm/hugetlb.c
80913 @@ -2008,15 +2008,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
80914 struct hstate *h = &default_hstate;
80915 unsigned long tmp;
80916 int ret;
80917 + ctl_table_no_const hugetlb_table;
80918
80919 tmp = h->max_huge_pages;
80920
80921 if (write && h->order >= MAX_ORDER)
80922 return -EINVAL;
80923
80924 - table->data = &tmp;
80925 - table->maxlen = sizeof(unsigned long);
80926 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80927 + hugetlb_table = *table;
80928 + hugetlb_table.data = &tmp;
80929 + hugetlb_table.maxlen = sizeof(unsigned long);
80930 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80931 if (ret)
80932 goto out;
80933
80934 @@ -2073,15 +2075,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
80935 struct hstate *h = &default_hstate;
80936 unsigned long tmp;
80937 int ret;
80938 + ctl_table_no_const hugetlb_table;
80939
80940 tmp = h->nr_overcommit_huge_pages;
80941
80942 if (write && h->order >= MAX_ORDER)
80943 return -EINVAL;
80944
80945 - table->data = &tmp;
80946 - table->maxlen = sizeof(unsigned long);
80947 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80948 + hugetlb_table = *table;
80949 + hugetlb_table.data = &tmp;
80950 + hugetlb_table.maxlen = sizeof(unsigned long);
80951 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80952 if (ret)
80953 goto out;
80954
80955 @@ -2515,6 +2519,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
80956 return 1;
80957 }
80958
80959 +#ifdef CONFIG_PAX_SEGMEXEC
80960 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
80961 +{
80962 + struct mm_struct *mm = vma->vm_mm;
80963 + struct vm_area_struct *vma_m;
80964 + unsigned long address_m;
80965 + pte_t *ptep_m;
80966 +
80967 + vma_m = pax_find_mirror_vma(vma);
80968 + if (!vma_m)
80969 + return;
80970 +
80971 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80972 + address_m = address + SEGMEXEC_TASK_SIZE;
80973 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
80974 + get_page(page_m);
80975 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
80976 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
80977 +}
80978 +#endif
80979 +
80980 /*
80981 * Hugetlb_cow() should be called with page lock of the original hugepage held.
80982 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
80983 @@ -2633,6 +2658,11 @@ retry_avoidcopy:
80984 make_huge_pte(vma, new_page, 1));
80985 page_remove_rmap(old_page);
80986 hugepage_add_new_anon_rmap(new_page, vma, address);
80987 +
80988 +#ifdef CONFIG_PAX_SEGMEXEC
80989 + pax_mirror_huge_pte(vma, address, new_page);
80990 +#endif
80991 +
80992 /* Make the old page be freed below */
80993 new_page = old_page;
80994 }
80995 @@ -2792,6 +2822,10 @@ retry:
80996 && (vma->vm_flags & VM_SHARED)));
80997 set_huge_pte_at(mm, address, ptep, new_pte);
80998
80999 +#ifdef CONFIG_PAX_SEGMEXEC
81000 + pax_mirror_huge_pte(vma, address, page);
81001 +#endif
81002 +
81003 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
81004 /* Optimization, do the COW without a second fault */
81005 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
81006 @@ -2821,6 +2855,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81007 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
81008 struct hstate *h = hstate_vma(vma);
81009
81010 +#ifdef CONFIG_PAX_SEGMEXEC
81011 + struct vm_area_struct *vma_m;
81012 +#endif
81013 +
81014 address &= huge_page_mask(h);
81015
81016 ptep = huge_pte_offset(mm, address);
81017 @@ -2834,6 +2872,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81018 VM_FAULT_SET_HINDEX(hstate_index(h));
81019 }
81020
81021 +#ifdef CONFIG_PAX_SEGMEXEC
81022 + vma_m = pax_find_mirror_vma(vma);
81023 + if (vma_m) {
81024 + unsigned long address_m;
81025 +
81026 + if (vma->vm_start > vma_m->vm_start) {
81027 + address_m = address;
81028 + address -= SEGMEXEC_TASK_SIZE;
81029 + vma = vma_m;
81030 + h = hstate_vma(vma);
81031 + } else
81032 + address_m = address + SEGMEXEC_TASK_SIZE;
81033 +
81034 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
81035 + return VM_FAULT_OOM;
81036 + address_m &= HPAGE_MASK;
81037 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
81038 + }
81039 +#endif
81040 +
81041 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
81042 if (!ptep)
81043 return VM_FAULT_OOM;
81044 diff --git a/mm/internal.h b/mm/internal.h
81045 index 9ba2110..eaf0674 100644
81046 --- a/mm/internal.h
81047 +++ b/mm/internal.h
81048 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
81049 * in mm/page_alloc.c
81050 */
81051 extern void __free_pages_bootmem(struct page *page, unsigned int order);
81052 +extern void free_compound_page(struct page *page);
81053 extern void prep_compound_page(struct page *page, unsigned long order);
81054 #ifdef CONFIG_MEMORY_FAILURE
81055 extern bool is_free_buddy_page(struct page *page);
81056 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
81057 index 752a705..6c3102e 100644
81058 --- a/mm/kmemleak.c
81059 +++ b/mm/kmemleak.c
81060 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
81061
81062 for (i = 0; i < object->trace_len; i++) {
81063 void *ptr = (void *)object->trace[i];
81064 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
81065 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
81066 }
81067 }
81068
81069 @@ -1853,7 +1853,7 @@ static int __init kmemleak_late_init(void)
81070 return -ENOMEM;
81071 }
81072
81073 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
81074 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
81075 &kmemleak_fops);
81076 if (!dentry)
81077 pr_warning("Failed to create the debugfs kmemleak file\n");
81078 diff --git a/mm/maccess.c b/mm/maccess.c
81079 index d53adf9..03a24bf 100644
81080 --- a/mm/maccess.c
81081 +++ b/mm/maccess.c
81082 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
81083 set_fs(KERNEL_DS);
81084 pagefault_disable();
81085 ret = __copy_from_user_inatomic(dst,
81086 - (__force const void __user *)src, size);
81087 + (const void __force_user *)src, size);
81088 pagefault_enable();
81089 set_fs(old_fs);
81090
81091 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
81092
81093 set_fs(KERNEL_DS);
81094 pagefault_disable();
81095 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
81096 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
81097 pagefault_enable();
81098 set_fs(old_fs);
81099
81100 diff --git a/mm/madvise.c b/mm/madvise.c
81101 index 03dfa5c..b032917 100644
81102 --- a/mm/madvise.c
81103 +++ b/mm/madvise.c
81104 @@ -48,6 +48,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
81105 pgoff_t pgoff;
81106 unsigned long new_flags = vma->vm_flags;
81107
81108 +#ifdef CONFIG_PAX_SEGMEXEC
81109 + struct vm_area_struct *vma_m;
81110 +#endif
81111 +
81112 switch (behavior) {
81113 case MADV_NORMAL:
81114 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
81115 @@ -123,6 +127,13 @@ success:
81116 /*
81117 * vm_flags is protected by the mmap_sem held in write mode.
81118 */
81119 +
81120 +#ifdef CONFIG_PAX_SEGMEXEC
81121 + vma_m = pax_find_mirror_vma(vma);
81122 + if (vma_m)
81123 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
81124 +#endif
81125 +
81126 vma->vm_flags = new_flags;
81127
81128 out:
81129 @@ -181,6 +192,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
81130 struct vm_area_struct ** prev,
81131 unsigned long start, unsigned long end)
81132 {
81133 +
81134 +#ifdef CONFIG_PAX_SEGMEXEC
81135 + struct vm_area_struct *vma_m;
81136 +#endif
81137 +
81138 *prev = vma;
81139 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
81140 return -EINVAL;
81141 @@ -193,6 +209,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
81142 zap_page_range(vma, start, end - start, &details);
81143 } else
81144 zap_page_range(vma, start, end - start, NULL);
81145 +
81146 +#ifdef CONFIG_PAX_SEGMEXEC
81147 + vma_m = pax_find_mirror_vma(vma);
81148 + if (vma_m) {
81149 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
81150 + struct zap_details details = {
81151 + .nonlinear_vma = vma_m,
81152 + .last_index = ULONG_MAX,
81153 + };
81154 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
81155 + } else
81156 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
81157 + }
81158 +#endif
81159 +
81160 return 0;
81161 }
81162
81163 @@ -397,6 +428,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
81164 if (end < start)
81165 goto out;
81166
81167 +#ifdef CONFIG_PAX_SEGMEXEC
81168 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
81169 + if (end > SEGMEXEC_TASK_SIZE)
81170 + goto out;
81171 + } else
81172 +#endif
81173 +
81174 + if (end > TASK_SIZE)
81175 + goto out;
81176 +
81177 error = 0;
81178 if (end == start)
81179 goto out;
81180 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
81181 index c6e4dd3..1f41988 100644
81182 --- a/mm/memory-failure.c
81183 +++ b/mm/memory-failure.c
81184 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
81185
81186 int sysctl_memory_failure_recovery __read_mostly = 1;
81187
81188 -atomic_long_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
81189 +atomic_long_unchecked_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
81190
81191 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
81192
81193 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
81194 pfn, t->comm, t->pid);
81195 si.si_signo = SIGBUS;
81196 si.si_errno = 0;
81197 - si.si_addr = (void *)addr;
81198 + si.si_addr = (void __user *)addr;
81199 #ifdef __ARCH_SI_TRAPNO
81200 si.si_trapno = trapno;
81201 #endif
81202 @@ -760,7 +760,7 @@ static struct page_state {
81203 unsigned long res;
81204 char *msg;
81205 int (*action)(struct page *p, unsigned long pfn);
81206 -} error_states[] = {
81207 +} __do_const error_states[] = {
81208 { reserved, reserved, "reserved kernel", me_kernel },
81209 /*
81210 * free pages are specially detected outside this table:
81211 @@ -1040,7 +1040,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81212 }
81213
81214 nr_pages = 1 << compound_trans_order(hpage);
81215 - atomic_long_add(nr_pages, &mce_bad_pages);
81216 + atomic_long_add_unchecked(nr_pages, &mce_bad_pages);
81217
81218 /*
81219 * We need/can do nothing about count=0 pages.
81220 @@ -1070,7 +1070,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81221 if (!PageHWPoison(hpage)
81222 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
81223 || (p != hpage && TestSetPageHWPoison(hpage))) {
81224 - atomic_long_sub(nr_pages, &mce_bad_pages);
81225 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81226 return 0;
81227 }
81228 set_page_hwpoison_huge_page(hpage);
81229 @@ -1128,7 +1128,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81230 }
81231 if (hwpoison_filter(p)) {
81232 if (TestClearPageHWPoison(p))
81233 - atomic_long_sub(nr_pages, &mce_bad_pages);
81234 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81235 unlock_page(hpage);
81236 put_page(hpage);
81237 return 0;
81238 @@ -1323,7 +1323,7 @@ int unpoison_memory(unsigned long pfn)
81239 return 0;
81240 }
81241 if (TestClearPageHWPoison(p))
81242 - atomic_long_sub(nr_pages, &mce_bad_pages);
81243 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81244 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
81245 return 0;
81246 }
81247 @@ -1337,7 +1337,7 @@ int unpoison_memory(unsigned long pfn)
81248 */
81249 if (TestClearPageHWPoison(page)) {
81250 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
81251 - atomic_long_sub(nr_pages, &mce_bad_pages);
81252 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81253 freeit = 1;
81254 if (PageHuge(page))
81255 clear_page_hwpoison_huge_page(page);
81256 @@ -1442,7 +1442,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
81257 }
81258 done:
81259 if (!PageHWPoison(hpage))
81260 - atomic_long_add(1 << compound_trans_order(hpage),
81261 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
81262 &mce_bad_pages);
81263 set_page_hwpoison_huge_page(hpage);
81264 dequeue_hwpoisoned_huge_page(hpage);
81265 @@ -1583,7 +1583,7 @@ int soft_offline_page(struct page *page, int flags)
81266 return ret;
81267
81268 done:
81269 - atomic_long_add(1, &mce_bad_pages);
81270 + atomic_long_add_unchecked(1, &mce_bad_pages);
81271 SetPageHWPoison(page);
81272 /* keep elevated page count for bad page */
81273 return ret;
81274 diff --git a/mm/memory.c b/mm/memory.c
81275 index bb1369f..b9631d2 100644
81276 --- a/mm/memory.c
81277 +++ b/mm/memory.c
81278 @@ -433,6 +433,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81279 free_pte_range(tlb, pmd, addr);
81280 } while (pmd++, addr = next, addr != end);
81281
81282 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
81283 start &= PUD_MASK;
81284 if (start < floor)
81285 return;
81286 @@ -447,6 +448,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81287 pmd = pmd_offset(pud, start);
81288 pud_clear(pud);
81289 pmd_free_tlb(tlb, pmd, start);
81290 +#endif
81291 +
81292 }
81293
81294 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81295 @@ -466,6 +469,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81296 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
81297 } while (pud++, addr = next, addr != end);
81298
81299 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
81300 start &= PGDIR_MASK;
81301 if (start < floor)
81302 return;
81303 @@ -480,6 +484,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81304 pud = pud_offset(pgd, start);
81305 pgd_clear(pgd);
81306 pud_free_tlb(tlb, pud, start);
81307 +#endif
81308 +
81309 }
81310
81311 /*
81312 @@ -1618,12 +1624,6 @@ no_page_table:
81313 return page;
81314 }
81315
81316 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
81317 -{
81318 - return stack_guard_page_start(vma, addr) ||
81319 - stack_guard_page_end(vma, addr+PAGE_SIZE);
81320 -}
81321 -
81322 /**
81323 * __get_user_pages() - pin user pages in memory
81324 * @tsk: task_struct of target task
81325 @@ -1709,10 +1709,10 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81326
81327 i = 0;
81328
81329 - do {
81330 + while (nr_pages) {
81331 struct vm_area_struct *vma;
81332
81333 - vma = find_extend_vma(mm, start);
81334 + vma = find_vma(mm, start);
81335 if (!vma && in_gate_area(mm, start)) {
81336 unsigned long pg = start & PAGE_MASK;
81337 pgd_t *pgd;
81338 @@ -1760,7 +1760,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81339 goto next_page;
81340 }
81341
81342 - if (!vma ||
81343 + if (!vma || start < vma->vm_start ||
81344 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
81345 !(vm_flags & vma->vm_flags))
81346 return i ? : -EFAULT;
81347 @@ -1787,11 +1787,6 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81348 int ret;
81349 unsigned int fault_flags = 0;
81350
81351 - /* For mlock, just skip the stack guard page. */
81352 - if (foll_flags & FOLL_MLOCK) {
81353 - if (stack_guard_page(vma, start))
81354 - goto next_page;
81355 - }
81356 if (foll_flags & FOLL_WRITE)
81357 fault_flags |= FAULT_FLAG_WRITE;
81358 if (nonblocking)
81359 @@ -1865,7 +1860,7 @@ next_page:
81360 start += PAGE_SIZE;
81361 nr_pages--;
81362 } while (nr_pages && start < vma->vm_end);
81363 - } while (nr_pages);
81364 + }
81365 return i;
81366 }
81367 EXPORT_SYMBOL(__get_user_pages);
81368 @@ -2072,6 +2067,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
81369 page_add_file_rmap(page);
81370 set_pte_at(mm, addr, pte, mk_pte(page, prot));
81371
81372 +#ifdef CONFIG_PAX_SEGMEXEC
81373 + pax_mirror_file_pte(vma, addr, page, ptl);
81374 +#endif
81375 +
81376 retval = 0;
81377 pte_unmap_unlock(pte, ptl);
81378 return retval;
81379 @@ -2116,9 +2115,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
81380 if (!page_count(page))
81381 return -EINVAL;
81382 if (!(vma->vm_flags & VM_MIXEDMAP)) {
81383 +
81384 +#ifdef CONFIG_PAX_SEGMEXEC
81385 + struct vm_area_struct *vma_m;
81386 +#endif
81387 +
81388 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
81389 BUG_ON(vma->vm_flags & VM_PFNMAP);
81390 vma->vm_flags |= VM_MIXEDMAP;
81391 +
81392 +#ifdef CONFIG_PAX_SEGMEXEC
81393 + vma_m = pax_find_mirror_vma(vma);
81394 + if (vma_m)
81395 + vma_m->vm_flags |= VM_MIXEDMAP;
81396 +#endif
81397 +
81398 }
81399 return insert_page(vma, addr, page, vma->vm_page_prot);
81400 }
81401 @@ -2201,6 +2212,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
81402 unsigned long pfn)
81403 {
81404 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
81405 + BUG_ON(vma->vm_mirror);
81406
81407 if (addr < vma->vm_start || addr >= vma->vm_end)
81408 return -EFAULT;
81409 @@ -2401,7 +2413,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
81410
81411 BUG_ON(pud_huge(*pud));
81412
81413 - pmd = pmd_alloc(mm, pud, addr);
81414 + pmd = (mm == &init_mm) ?
81415 + pmd_alloc_kernel(mm, pud, addr) :
81416 + pmd_alloc(mm, pud, addr);
81417 if (!pmd)
81418 return -ENOMEM;
81419 do {
81420 @@ -2421,7 +2435,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
81421 unsigned long next;
81422 int err;
81423
81424 - pud = pud_alloc(mm, pgd, addr);
81425 + pud = (mm == &init_mm) ?
81426 + pud_alloc_kernel(mm, pgd, addr) :
81427 + pud_alloc(mm, pgd, addr);
81428 if (!pud)
81429 return -ENOMEM;
81430 do {
81431 @@ -2509,6 +2525,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
81432 copy_user_highpage(dst, src, va, vma);
81433 }
81434
81435 +#ifdef CONFIG_PAX_SEGMEXEC
81436 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
81437 +{
81438 + struct mm_struct *mm = vma->vm_mm;
81439 + spinlock_t *ptl;
81440 + pte_t *pte, entry;
81441 +
81442 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
81443 + entry = *pte;
81444 + if (!pte_present(entry)) {
81445 + if (!pte_none(entry)) {
81446 + BUG_ON(pte_file(entry));
81447 + free_swap_and_cache(pte_to_swp_entry(entry));
81448 + pte_clear_not_present_full(mm, address, pte, 0);
81449 + }
81450 + } else {
81451 + struct page *page;
81452 +
81453 + flush_cache_page(vma, address, pte_pfn(entry));
81454 + entry = ptep_clear_flush(vma, address, pte);
81455 + BUG_ON(pte_dirty(entry));
81456 + page = vm_normal_page(vma, address, entry);
81457 + if (page) {
81458 + update_hiwater_rss(mm);
81459 + if (PageAnon(page))
81460 + dec_mm_counter_fast(mm, MM_ANONPAGES);
81461 + else
81462 + dec_mm_counter_fast(mm, MM_FILEPAGES);
81463 + page_remove_rmap(page);
81464 + page_cache_release(page);
81465 + }
81466 + }
81467 + pte_unmap_unlock(pte, ptl);
81468 +}
81469 +
81470 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
81471 + *
81472 + * the ptl of the lower mapped page is held on entry and is not released on exit
81473 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
81474 + */
81475 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81476 +{
81477 + struct mm_struct *mm = vma->vm_mm;
81478 + unsigned long address_m;
81479 + spinlock_t *ptl_m;
81480 + struct vm_area_struct *vma_m;
81481 + pmd_t *pmd_m;
81482 + pte_t *pte_m, entry_m;
81483 +
81484 + BUG_ON(!page_m || !PageAnon(page_m));
81485 +
81486 + vma_m = pax_find_mirror_vma(vma);
81487 + if (!vma_m)
81488 + return;
81489 +
81490 + BUG_ON(!PageLocked(page_m));
81491 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81492 + address_m = address + SEGMEXEC_TASK_SIZE;
81493 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81494 + pte_m = pte_offset_map(pmd_m, address_m);
81495 + ptl_m = pte_lockptr(mm, pmd_m);
81496 + if (ptl != ptl_m) {
81497 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81498 + if (!pte_none(*pte_m))
81499 + goto out;
81500 + }
81501 +
81502 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81503 + page_cache_get(page_m);
81504 + page_add_anon_rmap(page_m, vma_m, address_m);
81505 + inc_mm_counter_fast(mm, MM_ANONPAGES);
81506 + set_pte_at(mm, address_m, pte_m, entry_m);
81507 + update_mmu_cache(vma_m, address_m, entry_m);
81508 +out:
81509 + if (ptl != ptl_m)
81510 + spin_unlock(ptl_m);
81511 + pte_unmap(pte_m);
81512 + unlock_page(page_m);
81513 +}
81514 +
81515 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81516 +{
81517 + struct mm_struct *mm = vma->vm_mm;
81518 + unsigned long address_m;
81519 + spinlock_t *ptl_m;
81520 + struct vm_area_struct *vma_m;
81521 + pmd_t *pmd_m;
81522 + pte_t *pte_m, entry_m;
81523 +
81524 + BUG_ON(!page_m || PageAnon(page_m));
81525 +
81526 + vma_m = pax_find_mirror_vma(vma);
81527 + if (!vma_m)
81528 + return;
81529 +
81530 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81531 + address_m = address + SEGMEXEC_TASK_SIZE;
81532 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81533 + pte_m = pte_offset_map(pmd_m, address_m);
81534 + ptl_m = pte_lockptr(mm, pmd_m);
81535 + if (ptl != ptl_m) {
81536 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81537 + if (!pte_none(*pte_m))
81538 + goto out;
81539 + }
81540 +
81541 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81542 + page_cache_get(page_m);
81543 + page_add_file_rmap(page_m);
81544 + inc_mm_counter_fast(mm, MM_FILEPAGES);
81545 + set_pte_at(mm, address_m, pte_m, entry_m);
81546 + update_mmu_cache(vma_m, address_m, entry_m);
81547 +out:
81548 + if (ptl != ptl_m)
81549 + spin_unlock(ptl_m);
81550 + pte_unmap(pte_m);
81551 +}
81552 +
81553 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
81554 +{
81555 + struct mm_struct *mm = vma->vm_mm;
81556 + unsigned long address_m;
81557 + spinlock_t *ptl_m;
81558 + struct vm_area_struct *vma_m;
81559 + pmd_t *pmd_m;
81560 + pte_t *pte_m, entry_m;
81561 +
81562 + vma_m = pax_find_mirror_vma(vma);
81563 + if (!vma_m)
81564 + return;
81565 +
81566 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81567 + address_m = address + SEGMEXEC_TASK_SIZE;
81568 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81569 + pte_m = pte_offset_map(pmd_m, address_m);
81570 + ptl_m = pte_lockptr(mm, pmd_m);
81571 + if (ptl != ptl_m) {
81572 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81573 + if (!pte_none(*pte_m))
81574 + goto out;
81575 + }
81576 +
81577 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
81578 + set_pte_at(mm, address_m, pte_m, entry_m);
81579 +out:
81580 + if (ptl != ptl_m)
81581 + spin_unlock(ptl_m);
81582 + pte_unmap(pte_m);
81583 +}
81584 +
81585 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
81586 +{
81587 + struct page *page_m;
81588 + pte_t entry;
81589 +
81590 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
81591 + goto out;
81592 +
81593 + entry = *pte;
81594 + page_m = vm_normal_page(vma, address, entry);
81595 + if (!page_m)
81596 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
81597 + else if (PageAnon(page_m)) {
81598 + if (pax_find_mirror_vma(vma)) {
81599 + pte_unmap_unlock(pte, ptl);
81600 + lock_page(page_m);
81601 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
81602 + if (pte_same(entry, *pte))
81603 + pax_mirror_anon_pte(vma, address, page_m, ptl);
81604 + else
81605 + unlock_page(page_m);
81606 + }
81607 + } else
81608 + pax_mirror_file_pte(vma, address, page_m, ptl);
81609 +
81610 +out:
81611 + pte_unmap_unlock(pte, ptl);
81612 +}
81613 +#endif
81614 +
81615 /*
81616 * This routine handles present pages, when users try to write
81617 * to a shared page. It is done by copying the page to a new address
81618 @@ -2725,6 +2921,12 @@ gotten:
81619 */
81620 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81621 if (likely(pte_same(*page_table, orig_pte))) {
81622 +
81623 +#ifdef CONFIG_PAX_SEGMEXEC
81624 + if (pax_find_mirror_vma(vma))
81625 + BUG_ON(!trylock_page(new_page));
81626 +#endif
81627 +
81628 if (old_page) {
81629 if (!PageAnon(old_page)) {
81630 dec_mm_counter_fast(mm, MM_FILEPAGES);
81631 @@ -2776,6 +2978,10 @@ gotten:
81632 page_remove_rmap(old_page);
81633 }
81634
81635 +#ifdef CONFIG_PAX_SEGMEXEC
81636 + pax_mirror_anon_pte(vma, address, new_page, ptl);
81637 +#endif
81638 +
81639 /* Free the old page.. */
81640 new_page = old_page;
81641 ret |= VM_FAULT_WRITE;
81642 @@ -3051,6 +3257,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81643 swap_free(entry);
81644 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
81645 try_to_free_swap(page);
81646 +
81647 +#ifdef CONFIG_PAX_SEGMEXEC
81648 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
81649 +#endif
81650 +
81651 unlock_page(page);
81652 if (swapcache) {
81653 /*
81654 @@ -3074,6 +3285,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81655
81656 /* No need to invalidate - it was non-present before */
81657 update_mmu_cache(vma, address, page_table);
81658 +
81659 +#ifdef CONFIG_PAX_SEGMEXEC
81660 + pax_mirror_anon_pte(vma, address, page, ptl);
81661 +#endif
81662 +
81663 unlock:
81664 pte_unmap_unlock(page_table, ptl);
81665 out:
81666 @@ -3093,40 +3309,6 @@ out_release:
81667 }
81668
81669 /*
81670 - * This is like a special single-page "expand_{down|up}wards()",
81671 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
81672 - * doesn't hit another vma.
81673 - */
81674 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
81675 -{
81676 - address &= PAGE_MASK;
81677 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
81678 - struct vm_area_struct *prev = vma->vm_prev;
81679 -
81680 - /*
81681 - * Is there a mapping abutting this one below?
81682 - *
81683 - * That's only ok if it's the same stack mapping
81684 - * that has gotten split..
81685 - */
81686 - if (prev && prev->vm_end == address)
81687 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
81688 -
81689 - expand_downwards(vma, address - PAGE_SIZE);
81690 - }
81691 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
81692 - struct vm_area_struct *next = vma->vm_next;
81693 -
81694 - /* As VM_GROWSDOWN but s/below/above/ */
81695 - if (next && next->vm_start == address + PAGE_SIZE)
81696 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
81697 -
81698 - expand_upwards(vma, address + PAGE_SIZE);
81699 - }
81700 - return 0;
81701 -}
81702 -
81703 -/*
81704 * We enter with non-exclusive mmap_sem (to exclude vma changes,
81705 * but allow concurrent faults), and pte mapped but not yet locked.
81706 * We return with mmap_sem still held, but pte unmapped and unlocked.
81707 @@ -3135,27 +3317,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81708 unsigned long address, pte_t *page_table, pmd_t *pmd,
81709 unsigned int flags)
81710 {
81711 - struct page *page;
81712 + struct page *page = NULL;
81713 spinlock_t *ptl;
81714 pte_t entry;
81715
81716 - pte_unmap(page_table);
81717 -
81718 - /* Check if we need to add a guard page to the stack */
81719 - if (check_stack_guard_page(vma, address) < 0)
81720 - return VM_FAULT_SIGBUS;
81721 -
81722 - /* Use the zero-page for reads */
81723 if (!(flags & FAULT_FLAG_WRITE)) {
81724 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
81725 vma->vm_page_prot));
81726 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81727 + ptl = pte_lockptr(mm, pmd);
81728 + spin_lock(ptl);
81729 if (!pte_none(*page_table))
81730 goto unlock;
81731 goto setpte;
81732 }
81733
81734 /* Allocate our own private page. */
81735 + pte_unmap(page_table);
81736 +
81737 if (unlikely(anon_vma_prepare(vma)))
81738 goto oom;
81739 page = alloc_zeroed_user_highpage_movable(vma, address);
81740 @@ -3174,6 +3352,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81741 if (!pte_none(*page_table))
81742 goto release;
81743
81744 +#ifdef CONFIG_PAX_SEGMEXEC
81745 + if (pax_find_mirror_vma(vma))
81746 + BUG_ON(!trylock_page(page));
81747 +#endif
81748 +
81749 inc_mm_counter_fast(mm, MM_ANONPAGES);
81750 page_add_new_anon_rmap(page, vma, address);
81751 setpte:
81752 @@ -3181,6 +3364,12 @@ setpte:
81753
81754 /* No need to invalidate - it was non-present before */
81755 update_mmu_cache(vma, address, page_table);
81756 +
81757 +#ifdef CONFIG_PAX_SEGMEXEC
81758 + if (page)
81759 + pax_mirror_anon_pte(vma, address, page, ptl);
81760 +#endif
81761 +
81762 unlock:
81763 pte_unmap_unlock(page_table, ptl);
81764 return 0;
81765 @@ -3324,6 +3513,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81766 */
81767 /* Only go through if we didn't race with anybody else... */
81768 if (likely(pte_same(*page_table, orig_pte))) {
81769 +
81770 +#ifdef CONFIG_PAX_SEGMEXEC
81771 + if (anon && pax_find_mirror_vma(vma))
81772 + BUG_ON(!trylock_page(page));
81773 +#endif
81774 +
81775 flush_icache_page(vma, page);
81776 entry = mk_pte(page, vma->vm_page_prot);
81777 if (flags & FAULT_FLAG_WRITE)
81778 @@ -3343,6 +3538,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81779
81780 /* no need to invalidate: a not-present page won't be cached */
81781 update_mmu_cache(vma, address, page_table);
81782 +
81783 +#ifdef CONFIG_PAX_SEGMEXEC
81784 + if (anon)
81785 + pax_mirror_anon_pte(vma, address, page, ptl);
81786 + else
81787 + pax_mirror_file_pte(vma, address, page, ptl);
81788 +#endif
81789 +
81790 } else {
81791 if (cow_page)
81792 mem_cgroup_uncharge_page(cow_page);
81793 @@ -3664,6 +3867,12 @@ int handle_pte_fault(struct mm_struct *mm,
81794 if (flags & FAULT_FLAG_WRITE)
81795 flush_tlb_fix_spurious_fault(vma, address);
81796 }
81797 +
81798 +#ifdef CONFIG_PAX_SEGMEXEC
81799 + pax_mirror_pte(vma, address, pte, pmd, ptl);
81800 + return 0;
81801 +#endif
81802 +
81803 unlock:
81804 pte_unmap_unlock(pte, ptl);
81805 return 0;
81806 @@ -3680,6 +3889,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81807 pmd_t *pmd;
81808 pte_t *pte;
81809
81810 +#ifdef CONFIG_PAX_SEGMEXEC
81811 + struct vm_area_struct *vma_m;
81812 +#endif
81813 +
81814 __set_current_state(TASK_RUNNING);
81815
81816 count_vm_event(PGFAULT);
81817 @@ -3691,6 +3904,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81818 if (unlikely(is_vm_hugetlb_page(vma)))
81819 return hugetlb_fault(mm, vma, address, flags);
81820
81821 +#ifdef CONFIG_PAX_SEGMEXEC
81822 + vma_m = pax_find_mirror_vma(vma);
81823 + if (vma_m) {
81824 + unsigned long address_m;
81825 + pgd_t *pgd_m;
81826 + pud_t *pud_m;
81827 + pmd_t *pmd_m;
81828 +
81829 + if (vma->vm_start > vma_m->vm_start) {
81830 + address_m = address;
81831 + address -= SEGMEXEC_TASK_SIZE;
81832 + vma = vma_m;
81833 + } else
81834 + address_m = address + SEGMEXEC_TASK_SIZE;
81835 +
81836 + pgd_m = pgd_offset(mm, address_m);
81837 + pud_m = pud_alloc(mm, pgd_m, address_m);
81838 + if (!pud_m)
81839 + return VM_FAULT_OOM;
81840 + pmd_m = pmd_alloc(mm, pud_m, address_m);
81841 + if (!pmd_m)
81842 + return VM_FAULT_OOM;
81843 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
81844 + return VM_FAULT_OOM;
81845 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
81846 + }
81847 +#endif
81848 +
81849 retry:
81850 pgd = pgd_offset(mm, address);
81851 pud = pud_alloc(mm, pgd, address);
81852 @@ -3789,6 +4030,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81853 spin_unlock(&mm->page_table_lock);
81854 return 0;
81855 }
81856 +
81857 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81858 +{
81859 + pud_t *new = pud_alloc_one(mm, address);
81860 + if (!new)
81861 + return -ENOMEM;
81862 +
81863 + smp_wmb(); /* See comment in __pte_alloc */
81864 +
81865 + spin_lock(&mm->page_table_lock);
81866 + if (pgd_present(*pgd)) /* Another has populated it */
81867 + pud_free(mm, new);
81868 + else
81869 + pgd_populate_kernel(mm, pgd, new);
81870 + spin_unlock(&mm->page_table_lock);
81871 + return 0;
81872 +}
81873 #endif /* __PAGETABLE_PUD_FOLDED */
81874
81875 #ifndef __PAGETABLE_PMD_FOLDED
81876 @@ -3819,11 +4077,35 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
81877 spin_unlock(&mm->page_table_lock);
81878 return 0;
81879 }
81880 +
81881 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
81882 +{
81883 + pmd_t *new = pmd_alloc_one(mm, address);
81884 + if (!new)
81885 + return -ENOMEM;
81886 +
81887 + smp_wmb(); /* See comment in __pte_alloc */
81888 +
81889 + spin_lock(&mm->page_table_lock);
81890 +#ifndef __ARCH_HAS_4LEVEL_HACK
81891 + if (pud_present(*pud)) /* Another has populated it */
81892 + pmd_free(mm, new);
81893 + else
81894 + pud_populate_kernel(mm, pud, new);
81895 +#else
81896 + if (pgd_present(*pud)) /* Another has populated it */
81897 + pmd_free(mm, new);
81898 + else
81899 + pgd_populate_kernel(mm, pud, new);
81900 +#endif /* __ARCH_HAS_4LEVEL_HACK */
81901 + spin_unlock(&mm->page_table_lock);
81902 + return 0;
81903 +}
81904 #endif /* __PAGETABLE_PMD_FOLDED */
81905
81906 -int make_pages_present(unsigned long addr, unsigned long end)
81907 +ssize_t make_pages_present(unsigned long addr, unsigned long end)
81908 {
81909 - int ret, len, write;
81910 + ssize_t ret, len, write;
81911 struct vm_area_struct * vma;
81912
81913 vma = find_vma(current->mm, addr);
81914 @@ -3856,7 +4138,7 @@ static int __init gate_vma_init(void)
81915 gate_vma.vm_start = FIXADDR_USER_START;
81916 gate_vma.vm_end = FIXADDR_USER_END;
81917 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
81918 - gate_vma.vm_page_prot = __P101;
81919 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
81920
81921 return 0;
81922 }
81923 @@ -3990,8 +4272,8 @@ out:
81924 return ret;
81925 }
81926
81927 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81928 - void *buf, int len, int write)
81929 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81930 + void *buf, size_t len, int write)
81931 {
81932 resource_size_t phys_addr;
81933 unsigned long prot = 0;
81934 @@ -4016,8 +4298,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81935 * Access another process' address space as given in mm. If non-NULL, use the
81936 * given task for page fault accounting.
81937 */
81938 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81939 - unsigned long addr, void *buf, int len, int write)
81940 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81941 + unsigned long addr, void *buf, size_t len, int write)
81942 {
81943 struct vm_area_struct *vma;
81944 void *old_buf = buf;
81945 @@ -4025,7 +4307,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81946 down_read(&mm->mmap_sem);
81947 /* ignore errors, just check how much was successfully transferred */
81948 while (len) {
81949 - int bytes, ret, offset;
81950 + ssize_t bytes, ret, offset;
81951 void *maddr;
81952 struct page *page = NULL;
81953
81954 @@ -4084,8 +4366,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81955 *
81956 * The caller must hold a reference on @mm.
81957 */
81958 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81959 - void *buf, int len, int write)
81960 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
81961 + void *buf, size_t len, int write)
81962 {
81963 return __access_remote_vm(NULL, mm, addr, buf, len, write);
81964 }
81965 @@ -4095,11 +4377,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81966 * Source/target buffer must be kernel space,
81967 * Do not walk the page table directly, use get_user_pages
81968 */
81969 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
81970 - void *buf, int len, int write)
81971 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
81972 + void *buf, size_t len, int write)
81973 {
81974 struct mm_struct *mm;
81975 - int ret;
81976 + ssize_t ret;
81977
81978 mm = get_task_mm(tsk);
81979 if (!mm)
81980 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
81981 index 3df6d12..a11056a 100644
81982 --- a/mm/mempolicy.c
81983 +++ b/mm/mempolicy.c
81984 @@ -721,6 +721,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
81985 unsigned long vmstart;
81986 unsigned long vmend;
81987
81988 +#ifdef CONFIG_PAX_SEGMEXEC
81989 + struct vm_area_struct *vma_m;
81990 +#endif
81991 +
81992 vma = find_vma(mm, start);
81993 if (!vma || vma->vm_start > start)
81994 return -EFAULT;
81995 @@ -757,9 +761,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
81996 if (err)
81997 goto out;
81998 }
81999 +
82000 err = vma_replace_policy(vma, new_pol);
82001 if (err)
82002 goto out;
82003 +
82004 +#ifdef CONFIG_PAX_SEGMEXEC
82005 + vma_m = pax_find_mirror_vma(vma);
82006 + if (vma_m) {
82007 + err = vma_replace_policy(vma_m, new_pol);
82008 + if (err)
82009 + goto out;
82010 + }
82011 +#endif
82012 +
82013 }
82014
82015 out:
82016 @@ -1216,6 +1231,17 @@ static long do_mbind(unsigned long start, unsigned long len,
82017
82018 if (end < start)
82019 return -EINVAL;
82020 +
82021 +#ifdef CONFIG_PAX_SEGMEXEC
82022 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
82023 + if (end > SEGMEXEC_TASK_SIZE)
82024 + return -EINVAL;
82025 + } else
82026 +#endif
82027 +
82028 + if (end > TASK_SIZE)
82029 + return -EINVAL;
82030 +
82031 if (end == start)
82032 return 0;
82033
82034 @@ -1445,8 +1471,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
82035 */
82036 tcred = __task_cred(task);
82037 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
82038 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
82039 - !capable(CAP_SYS_NICE)) {
82040 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
82041 rcu_read_unlock();
82042 err = -EPERM;
82043 goto out_put;
82044 @@ -1477,6 +1502,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
82045 goto out;
82046 }
82047
82048 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82049 + if (mm != current->mm &&
82050 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
82051 + mmput(mm);
82052 + err = -EPERM;
82053 + goto out;
82054 + }
82055 +#endif
82056 +
82057 err = do_migrate_pages(mm, old, new,
82058 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
82059
82060 diff --git a/mm/migrate.c b/mm/migrate.c
82061 index 2fd8b4a..d70358f 100644
82062 --- a/mm/migrate.c
82063 +++ b/mm/migrate.c
82064 @@ -1401,8 +1401,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
82065 */
82066 tcred = __task_cred(task);
82067 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
82068 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
82069 - !capable(CAP_SYS_NICE)) {
82070 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
82071 rcu_read_unlock();
82072 err = -EPERM;
82073 goto out;
82074 diff --git a/mm/mlock.c b/mm/mlock.c
82075 index c9bd528..da8d069 100644
82076 --- a/mm/mlock.c
82077 +++ b/mm/mlock.c
82078 @@ -13,6 +13,7 @@
82079 #include <linux/pagemap.h>
82080 #include <linux/mempolicy.h>
82081 #include <linux/syscalls.h>
82082 +#include <linux/security.h>
82083 #include <linux/sched.h>
82084 #include <linux/export.h>
82085 #include <linux/rmap.h>
82086 @@ -369,7 +370,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
82087 {
82088 unsigned long nstart, end, tmp;
82089 struct vm_area_struct * vma, * prev;
82090 - int error;
82091 + int error = 0;
82092
82093 VM_BUG_ON(start & ~PAGE_MASK);
82094 VM_BUG_ON(len != PAGE_ALIGN(len));
82095 @@ -378,6 +379,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
82096 return -EINVAL;
82097 if (end == start)
82098 return 0;
82099 + if (end > TASK_SIZE)
82100 + return -EINVAL;
82101 +
82102 vma = find_vma(current->mm, start);
82103 if (!vma || vma->vm_start > start)
82104 return -ENOMEM;
82105 @@ -389,6 +393,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
82106 for (nstart = start ; ; ) {
82107 vm_flags_t newflags;
82108
82109 +#ifdef CONFIG_PAX_SEGMEXEC
82110 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
82111 + break;
82112 +#endif
82113 +
82114 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
82115
82116 newflags = vma->vm_flags | VM_LOCKED;
82117 @@ -494,6 +503,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
82118 lock_limit >>= PAGE_SHIFT;
82119
82120 /* check against resource limits */
82121 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
82122 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
82123 error = do_mlock(start, len, 1);
82124 up_write(&current->mm->mmap_sem);
82125 @@ -528,6 +538,12 @@ static int do_mlockall(int flags)
82126 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
82127 vm_flags_t newflags;
82128
82129 +#ifdef CONFIG_PAX_SEGMEXEC
82130 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
82131 + break;
82132 +#endif
82133 +
82134 + BUG_ON(vma->vm_end > TASK_SIZE);
82135 newflags = vma->vm_flags | VM_LOCKED;
82136 if (!(flags & MCL_CURRENT))
82137 newflags &= ~VM_LOCKED;
82138 @@ -560,6 +576,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
82139 lock_limit >>= PAGE_SHIFT;
82140
82141 ret = -ENOMEM;
82142 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
82143 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
82144 capable(CAP_IPC_LOCK))
82145 ret = do_mlockall(flags);
82146 diff --git a/mm/mmap.c b/mm/mmap.c
82147 index 8832b87..04240d1 100644
82148 --- a/mm/mmap.c
82149 +++ b/mm/mmap.c
82150 @@ -32,6 +32,7 @@
82151 #include <linux/khugepaged.h>
82152 #include <linux/uprobes.h>
82153 #include <linux/rbtree_augmented.h>
82154 +#include <linux/random.h>
82155
82156 #include <asm/uaccess.h>
82157 #include <asm/cacheflush.h>
82158 @@ -48,6 +49,16 @@
82159 #define arch_rebalance_pgtables(addr, len) (addr)
82160 #endif
82161
82162 +static inline void verify_mm_writelocked(struct mm_struct *mm)
82163 +{
82164 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
82165 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
82166 + up_read(&mm->mmap_sem);
82167 + BUG();
82168 + }
82169 +#endif
82170 +}
82171 +
82172 static void unmap_region(struct mm_struct *mm,
82173 struct vm_area_struct *vma, struct vm_area_struct *prev,
82174 unsigned long start, unsigned long end);
82175 @@ -67,22 +78,32 @@ static void unmap_region(struct mm_struct *mm,
82176 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
82177 *
82178 */
82179 -pgprot_t protection_map[16] = {
82180 +pgprot_t protection_map[16] __read_only = {
82181 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
82182 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
82183 };
82184
82185 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
82186 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
82187 {
82188 - return __pgprot(pgprot_val(protection_map[vm_flags &
82189 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
82190 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
82191 pgprot_val(arch_vm_get_page_prot(vm_flags)));
82192 +
82193 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82194 + if (!(__supported_pte_mask & _PAGE_NX) &&
82195 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
82196 + (vm_flags & (VM_READ | VM_WRITE)))
82197 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
82198 +#endif
82199 +
82200 + return prot;
82201 }
82202 EXPORT_SYMBOL(vm_get_page_prot);
82203
82204 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */
82205 int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
82206 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
82207 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
82208 /*
82209 * Make sure vm_committed_as in one cacheline and not cacheline shared with
82210 * other variables. It can be updated by several CPUs frequently.
82211 @@ -238,6 +259,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
82212 struct vm_area_struct *next = vma->vm_next;
82213
82214 might_sleep();
82215 + BUG_ON(vma->vm_mirror);
82216 if (vma->vm_ops && vma->vm_ops->close)
82217 vma->vm_ops->close(vma);
82218 if (vma->vm_file)
82219 @@ -281,6 +303,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
82220 * not page aligned -Ram Gupta
82221 */
82222 rlim = rlimit(RLIMIT_DATA);
82223 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
82224 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
82225 (mm->end_data - mm->start_data) > rlim)
82226 goto out;
82227 @@ -888,6 +911,12 @@ static int
82228 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
82229 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82230 {
82231 +
82232 +#ifdef CONFIG_PAX_SEGMEXEC
82233 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
82234 + return 0;
82235 +#endif
82236 +
82237 if (is_mergeable_vma(vma, file, vm_flags) &&
82238 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82239 if (vma->vm_pgoff == vm_pgoff)
82240 @@ -907,6 +936,12 @@ static int
82241 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82242 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82243 {
82244 +
82245 +#ifdef CONFIG_PAX_SEGMEXEC
82246 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
82247 + return 0;
82248 +#endif
82249 +
82250 if (is_mergeable_vma(vma, file, vm_flags) &&
82251 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82252 pgoff_t vm_pglen;
82253 @@ -949,13 +984,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82254 struct vm_area_struct *vma_merge(struct mm_struct *mm,
82255 struct vm_area_struct *prev, unsigned long addr,
82256 unsigned long end, unsigned long vm_flags,
82257 - struct anon_vma *anon_vma, struct file *file,
82258 + struct anon_vma *anon_vma, struct file *file,
82259 pgoff_t pgoff, struct mempolicy *policy)
82260 {
82261 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
82262 struct vm_area_struct *area, *next;
82263 int err;
82264
82265 +#ifdef CONFIG_PAX_SEGMEXEC
82266 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
82267 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
82268 +
82269 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
82270 +#endif
82271 +
82272 /*
82273 * We later require that vma->vm_flags == vm_flags,
82274 * so this tests vma->vm_flags & VM_SPECIAL, too.
82275 @@ -971,6 +1013,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82276 if (next && next->vm_end == end) /* cases 6, 7, 8 */
82277 next = next->vm_next;
82278
82279 +#ifdef CONFIG_PAX_SEGMEXEC
82280 + if (prev)
82281 + prev_m = pax_find_mirror_vma(prev);
82282 + if (area)
82283 + area_m = pax_find_mirror_vma(area);
82284 + if (next)
82285 + next_m = pax_find_mirror_vma(next);
82286 +#endif
82287 +
82288 /*
82289 * Can it merge with the predecessor?
82290 */
82291 @@ -990,9 +1041,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82292 /* cases 1, 6 */
82293 err = vma_adjust(prev, prev->vm_start,
82294 next->vm_end, prev->vm_pgoff, NULL);
82295 - } else /* cases 2, 5, 7 */
82296 +
82297 +#ifdef CONFIG_PAX_SEGMEXEC
82298 + if (!err && prev_m)
82299 + err = vma_adjust(prev_m, prev_m->vm_start,
82300 + next_m->vm_end, prev_m->vm_pgoff, NULL);
82301 +#endif
82302 +
82303 + } else { /* cases 2, 5, 7 */
82304 err = vma_adjust(prev, prev->vm_start,
82305 end, prev->vm_pgoff, NULL);
82306 +
82307 +#ifdef CONFIG_PAX_SEGMEXEC
82308 + if (!err && prev_m)
82309 + err = vma_adjust(prev_m, prev_m->vm_start,
82310 + end_m, prev_m->vm_pgoff, NULL);
82311 +#endif
82312 +
82313 + }
82314 if (err)
82315 return NULL;
82316 khugepaged_enter_vma_merge(prev);
82317 @@ -1006,12 +1072,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82318 mpol_equal(policy, vma_policy(next)) &&
82319 can_vma_merge_before(next, vm_flags,
82320 anon_vma, file, pgoff+pglen)) {
82321 - if (prev && addr < prev->vm_end) /* case 4 */
82322 + if (prev && addr < prev->vm_end) { /* case 4 */
82323 err = vma_adjust(prev, prev->vm_start,
82324 addr, prev->vm_pgoff, NULL);
82325 - else /* cases 3, 8 */
82326 +
82327 +#ifdef CONFIG_PAX_SEGMEXEC
82328 + if (!err && prev_m)
82329 + err = vma_adjust(prev_m, prev_m->vm_start,
82330 + addr_m, prev_m->vm_pgoff, NULL);
82331 +#endif
82332 +
82333 + } else { /* cases 3, 8 */
82334 err = vma_adjust(area, addr, next->vm_end,
82335 next->vm_pgoff - pglen, NULL);
82336 +
82337 +#ifdef CONFIG_PAX_SEGMEXEC
82338 + if (!err && area_m)
82339 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
82340 + next_m->vm_pgoff - pglen, NULL);
82341 +#endif
82342 +
82343 + }
82344 if (err)
82345 return NULL;
82346 khugepaged_enter_vma_merge(area);
82347 @@ -1120,8 +1201,10 @@ none:
82348 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82349 struct file *file, long pages)
82350 {
82351 - const unsigned long stack_flags
82352 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
82353 +
82354 +#ifdef CONFIG_PAX_RANDMMAP
82355 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82356 +#endif
82357
82358 mm->total_vm += pages;
82359
82360 @@ -1129,7 +1212,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82361 mm->shared_vm += pages;
82362 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
82363 mm->exec_vm += pages;
82364 - } else if (flags & stack_flags)
82365 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
82366 mm->stack_vm += pages;
82367 }
82368 #endif /* CONFIG_PROC_FS */
82369 @@ -1165,7 +1248,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82370 * (the exception is when the underlying filesystem is noexec
82371 * mounted, in which case we dont add PROT_EXEC.)
82372 */
82373 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
82374 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
82375 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
82376 prot |= PROT_EXEC;
82377
82378 @@ -1191,7 +1274,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82379 /* Obtain the address to map to. we verify (or select) it and ensure
82380 * that it represents a valid section of the address space.
82381 */
82382 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
82383 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
82384 if (addr & ~PAGE_MASK)
82385 return addr;
82386
82387 @@ -1202,6 +1285,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82388 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
82389 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
82390
82391 +#ifdef CONFIG_PAX_MPROTECT
82392 + if (mm->pax_flags & MF_PAX_MPROTECT) {
82393 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
82394 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
82395 + gr_log_rwxmmap(file);
82396 +
82397 +#ifdef CONFIG_PAX_EMUPLT
82398 + vm_flags &= ~VM_EXEC;
82399 +#else
82400 + return -EPERM;
82401 +#endif
82402 +
82403 + }
82404 +
82405 + if (!(vm_flags & VM_EXEC))
82406 + vm_flags &= ~VM_MAYEXEC;
82407 +#else
82408 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
82409 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
82410 +#endif
82411 + else
82412 + vm_flags &= ~VM_MAYWRITE;
82413 + }
82414 +#endif
82415 +
82416 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82417 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
82418 + vm_flags &= ~VM_PAGEEXEC;
82419 +#endif
82420 +
82421 if (flags & MAP_LOCKED)
82422 if (!can_do_mlock())
82423 return -EPERM;
82424 @@ -1213,6 +1326,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82425 locked += mm->locked_vm;
82426 lock_limit = rlimit(RLIMIT_MEMLOCK);
82427 lock_limit >>= PAGE_SHIFT;
82428 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82429 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
82430 return -EAGAIN;
82431 }
82432 @@ -1279,6 +1393,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82433 }
82434 }
82435
82436 + if (!gr_acl_handle_mmap(file, prot))
82437 + return -EACCES;
82438 +
82439 return mmap_region(file, addr, len, flags, vm_flags, pgoff);
82440 }
82441
82442 @@ -1356,7 +1473,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
82443 vm_flags_t vm_flags = vma->vm_flags;
82444
82445 /* If it was private or non-writable, the write bit is already clear */
82446 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
82447 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
82448 return 0;
82449
82450 /* The backer wishes to know when pages are first written to? */
82451 @@ -1405,16 +1522,30 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
82452 unsigned long charged = 0;
82453 struct inode *inode = file ? file->f_path.dentry->d_inode : NULL;
82454
82455 +#ifdef CONFIG_PAX_SEGMEXEC
82456 + struct vm_area_struct *vma_m = NULL;
82457 +#endif
82458 +
82459 + /*
82460 + * mm->mmap_sem is required to protect against another thread
82461 + * changing the mappings in case we sleep.
82462 + */
82463 + verify_mm_writelocked(mm);
82464 +
82465 /* Clear old maps */
82466 error = -ENOMEM;
82467 -munmap_back:
82468 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
82469 if (do_munmap(mm, addr, len))
82470 return -ENOMEM;
82471 - goto munmap_back;
82472 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
82473 }
82474
82475 /* Check against address space limit. */
82476 +
82477 +#ifdef CONFIG_PAX_RANDMMAP
82478 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82479 +#endif
82480 +
82481 if (!may_expand_vm(mm, len >> PAGE_SHIFT))
82482 return -ENOMEM;
82483
82484 @@ -1460,6 +1591,16 @@ munmap_back:
82485 goto unacct_error;
82486 }
82487
82488 +#ifdef CONFIG_PAX_SEGMEXEC
82489 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
82490 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82491 + if (!vma_m) {
82492 + error = -ENOMEM;
82493 + goto free_vma;
82494 + }
82495 + }
82496 +#endif
82497 +
82498 vma->vm_mm = mm;
82499 vma->vm_start = addr;
82500 vma->vm_end = addr + len;
82501 @@ -1484,6 +1625,13 @@ munmap_back:
82502 if (error)
82503 goto unmap_and_free_vma;
82504
82505 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82506 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
82507 + vma->vm_flags |= VM_PAGEEXEC;
82508 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82509 + }
82510 +#endif
82511 +
82512 /* Can addr have changed??
82513 *
82514 * Answer: Yes, several device drivers can do it in their
82515 @@ -1522,6 +1670,11 @@ munmap_back:
82516 vma_link(mm, vma, prev, rb_link, rb_parent);
82517 file = vma->vm_file;
82518
82519 +#ifdef CONFIG_PAX_SEGMEXEC
82520 + if (vma_m)
82521 + BUG_ON(pax_mirror_vma(vma_m, vma));
82522 +#endif
82523 +
82524 /* Once vma denies write, undo our temporary denial count */
82525 if (correct_wcount)
82526 atomic_inc(&inode->i_writecount);
82527 @@ -1529,6 +1682,7 @@ out:
82528 perf_event_mmap(vma);
82529
82530 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
82531 + track_exec_limit(mm, addr, addr + len, vm_flags);
82532 if (vm_flags & VM_LOCKED) {
82533 if (!mlock_vma_pages_range(vma, addr, addr + len))
82534 mm->locked_vm += (len >> PAGE_SHIFT);
82535 @@ -1550,6 +1704,12 @@ unmap_and_free_vma:
82536 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
82537 charged = 0;
82538 free_vma:
82539 +
82540 +#ifdef CONFIG_PAX_SEGMEXEC
82541 + if (vma_m)
82542 + kmem_cache_free(vm_area_cachep, vma_m);
82543 +#endif
82544 +
82545 kmem_cache_free(vm_area_cachep, vma);
82546 unacct_error:
82547 if (charged)
82548 @@ -1557,6 +1717,62 @@ unacct_error:
82549 return error;
82550 }
82551
82552 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
82553 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
82554 +{
82555 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
82556 + return (random32() & 0xFF) << PAGE_SHIFT;
82557 +
82558 + return 0;
82559 +}
82560 +#endif
82561 +
82562 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
82563 +{
82564 + if (!vma) {
82565 +#ifdef CONFIG_STACK_GROWSUP
82566 + if (addr > sysctl_heap_stack_gap)
82567 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
82568 + else
82569 + vma = find_vma(current->mm, 0);
82570 + if (vma && (vma->vm_flags & VM_GROWSUP))
82571 + return false;
82572 +#endif
82573 + return true;
82574 + }
82575 +
82576 + if (addr + len > vma->vm_start)
82577 + return false;
82578 +
82579 + if (vma->vm_flags & VM_GROWSDOWN)
82580 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
82581 +#ifdef CONFIG_STACK_GROWSUP
82582 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
82583 + return addr - vma->vm_prev->vm_end <= sysctl_heap_stack_gap;
82584 +#endif
82585 + else if (offset)
82586 + return offset <= vma->vm_start - addr - len;
82587 +
82588 + return true;
82589 +}
82590 +
82591 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
82592 +{
82593 + if (vma->vm_start < len)
82594 + return -ENOMEM;
82595 +
82596 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
82597 + if (offset <= vma->vm_start - len)
82598 + return vma->vm_start - len - offset;
82599 + else
82600 + return -ENOMEM;
82601 + }
82602 +
82603 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
82604 + return vma->vm_start - len - sysctl_heap_stack_gap;
82605 + return -ENOMEM;
82606 +}
82607 +
82608 unsigned long unmapped_area(struct vm_unmapped_area_info *info)
82609 {
82610 /*
82611 @@ -1776,6 +1992,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82612 struct mm_struct *mm = current->mm;
82613 struct vm_area_struct *vma;
82614 struct vm_unmapped_area_info info;
82615 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82616
82617 if (len > TASK_SIZE)
82618 return -ENOMEM;
82619 @@ -1783,17 +2000,26 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82620 if (flags & MAP_FIXED)
82621 return addr;
82622
82623 +#ifdef CONFIG_PAX_RANDMMAP
82624 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82625 +#endif
82626 +
82627 if (addr) {
82628 addr = PAGE_ALIGN(addr);
82629 vma = find_vma(mm, addr);
82630 - if (TASK_SIZE - len >= addr &&
82631 - (!vma || addr + len <= vma->vm_start))
82632 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82633 return addr;
82634 }
82635
82636 info.flags = 0;
82637 info.length = len;
82638 info.low_limit = TASK_UNMAPPED_BASE;
82639 +
82640 +#ifdef CONFIG_PAX_RANDMMAP
82641 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82642 + info.low_limit += mm->delta_mmap;
82643 +#endif
82644 +
82645 info.high_limit = TASK_SIZE;
82646 info.align_mask = 0;
82647 return vm_unmapped_area(&info);
82648 @@ -1802,10 +2028,16 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82649
82650 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
82651 {
82652 +
82653 +#ifdef CONFIG_PAX_SEGMEXEC
82654 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82655 + return;
82656 +#endif
82657 +
82658 /*
82659 * Is this a new hole at the lowest possible address?
82660 */
82661 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
82662 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
82663 mm->free_area_cache = addr;
82664 }
82665
82666 @@ -1823,6 +2055,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82667 struct mm_struct *mm = current->mm;
82668 unsigned long addr = addr0;
82669 struct vm_unmapped_area_info info;
82670 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82671
82672 /* requested length too big for entire address space */
82673 if (len > TASK_SIZE)
82674 @@ -1831,12 +2064,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82675 if (flags & MAP_FIXED)
82676 return addr;
82677
82678 +#ifdef CONFIG_PAX_RANDMMAP
82679 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82680 +#endif
82681 +
82682 /* requesting a specific address */
82683 if (addr) {
82684 addr = PAGE_ALIGN(addr);
82685 vma = find_vma(mm, addr);
82686 - if (TASK_SIZE - len >= addr &&
82687 - (!vma || addr + len <= vma->vm_start))
82688 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82689 return addr;
82690 }
82691
82692 @@ -1857,6 +2093,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82693 VM_BUG_ON(addr != -ENOMEM);
82694 info.flags = 0;
82695 info.low_limit = TASK_UNMAPPED_BASE;
82696 +
82697 +#ifdef CONFIG_PAX_RANDMMAP
82698 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82699 + info.low_limit += mm->delta_mmap;
82700 +#endif
82701 +
82702 info.high_limit = TASK_SIZE;
82703 addr = vm_unmapped_area(&info);
82704 }
82705 @@ -1867,6 +2109,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82706
82707 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82708 {
82709 +
82710 +#ifdef CONFIG_PAX_SEGMEXEC
82711 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82712 + return;
82713 +#endif
82714 +
82715 /*
82716 * Is this a new hole at the highest possible address?
82717 */
82718 @@ -1874,8 +2122,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82719 mm->free_area_cache = addr;
82720
82721 /* dont allow allocations above current base */
82722 - if (mm->free_area_cache > mm->mmap_base)
82723 + if (mm->free_area_cache > mm->mmap_base) {
82724 mm->free_area_cache = mm->mmap_base;
82725 + mm->cached_hole_size = ~0UL;
82726 + }
82727 }
82728
82729 unsigned long
82730 @@ -1922,7 +2172,7 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
82731
82732 /* Check the cache first. */
82733 /* (Cache hit rate is typically around 35%.) */
82734 - vma = mm->mmap_cache;
82735 + vma = ACCESS_ONCE(mm->mmap_cache);
82736 if (!(vma && vma->vm_end > addr && vma->vm_start <= addr)) {
82737 struct rb_node *rb_node;
82738
82739 @@ -1974,6 +2224,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
82740 return vma;
82741 }
82742
82743 +#ifdef CONFIG_PAX_SEGMEXEC
82744 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
82745 +{
82746 + struct vm_area_struct *vma_m;
82747 +
82748 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
82749 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
82750 + BUG_ON(vma->vm_mirror);
82751 + return NULL;
82752 + }
82753 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
82754 + vma_m = vma->vm_mirror;
82755 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
82756 + BUG_ON(vma->vm_file != vma_m->vm_file);
82757 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
82758 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
82759 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
82760 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
82761 + return vma_m;
82762 +}
82763 +#endif
82764 +
82765 /*
82766 * Verify that the stack growth is acceptable and
82767 * update accounting. This is shared with both the
82768 @@ -1990,6 +2262,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82769 return -ENOMEM;
82770
82771 /* Stack limit test */
82772 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
82773 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
82774 return -ENOMEM;
82775
82776 @@ -2000,6 +2273,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82777 locked = mm->locked_vm + grow;
82778 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
82779 limit >>= PAGE_SHIFT;
82780 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82781 if (locked > limit && !capable(CAP_IPC_LOCK))
82782 return -ENOMEM;
82783 }
82784 @@ -2029,37 +2303,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82785 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
82786 * vma is the last one with address > vma->vm_end. Have to extend vma.
82787 */
82788 +#ifndef CONFIG_IA64
82789 +static
82790 +#endif
82791 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82792 {
82793 int error;
82794 + bool locknext;
82795
82796 if (!(vma->vm_flags & VM_GROWSUP))
82797 return -EFAULT;
82798
82799 + /* Also guard against wrapping around to address 0. */
82800 + if (address < PAGE_ALIGN(address+1))
82801 + address = PAGE_ALIGN(address+1);
82802 + else
82803 + return -ENOMEM;
82804 +
82805 /*
82806 * We must make sure the anon_vma is allocated
82807 * so that the anon_vma locking is not a noop.
82808 */
82809 if (unlikely(anon_vma_prepare(vma)))
82810 return -ENOMEM;
82811 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
82812 + if (locknext && anon_vma_prepare(vma->vm_next))
82813 + return -ENOMEM;
82814 vma_lock_anon_vma(vma);
82815 + if (locknext)
82816 + vma_lock_anon_vma(vma->vm_next);
82817
82818 /*
82819 * vma->vm_start/vm_end cannot change under us because the caller
82820 * is required to hold the mmap_sem in read mode. We need the
82821 - * anon_vma lock to serialize against concurrent expand_stacks.
82822 - * Also guard against wrapping around to address 0.
82823 + * anon_vma locks to serialize against concurrent expand_stacks
82824 + * and expand_upwards.
82825 */
82826 - if (address < PAGE_ALIGN(address+4))
82827 - address = PAGE_ALIGN(address+4);
82828 - else {
82829 - vma_unlock_anon_vma(vma);
82830 - return -ENOMEM;
82831 - }
82832 error = 0;
82833
82834 /* Somebody else might have raced and expanded it already */
82835 - if (address > vma->vm_end) {
82836 + 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)
82837 + error = -ENOMEM;
82838 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
82839 unsigned long size, grow;
82840
82841 size = address - vma->vm_start;
82842 @@ -2094,6 +2379,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82843 }
82844 }
82845 }
82846 + if (locknext)
82847 + vma_unlock_anon_vma(vma->vm_next);
82848 vma_unlock_anon_vma(vma);
82849 khugepaged_enter_vma_merge(vma);
82850 validate_mm(vma->vm_mm);
82851 @@ -2108,6 +2395,8 @@ int expand_downwards(struct vm_area_struct *vma,
82852 unsigned long address)
82853 {
82854 int error;
82855 + bool lockprev = false;
82856 + struct vm_area_struct *prev;
82857
82858 /*
82859 * We must make sure the anon_vma is allocated
82860 @@ -2121,6 +2410,15 @@ int expand_downwards(struct vm_area_struct *vma,
82861 if (error)
82862 return error;
82863
82864 + prev = vma->vm_prev;
82865 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
82866 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
82867 +#endif
82868 + if (lockprev && anon_vma_prepare(prev))
82869 + return -ENOMEM;
82870 + if (lockprev)
82871 + vma_lock_anon_vma(prev);
82872 +
82873 vma_lock_anon_vma(vma);
82874
82875 /*
82876 @@ -2130,9 +2428,17 @@ int expand_downwards(struct vm_area_struct *vma,
82877 */
82878
82879 /* Somebody else might have raced and expanded it already */
82880 - if (address < vma->vm_start) {
82881 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
82882 + error = -ENOMEM;
82883 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
82884 unsigned long size, grow;
82885
82886 +#ifdef CONFIG_PAX_SEGMEXEC
82887 + struct vm_area_struct *vma_m;
82888 +
82889 + vma_m = pax_find_mirror_vma(vma);
82890 +#endif
82891 +
82892 size = vma->vm_end - address;
82893 grow = (vma->vm_start - address) >> PAGE_SHIFT;
82894
82895 @@ -2157,6 +2463,18 @@ int expand_downwards(struct vm_area_struct *vma,
82896 vma->vm_pgoff -= grow;
82897 anon_vma_interval_tree_post_update_vma(vma);
82898 vma_gap_update(vma);
82899 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
82900 +
82901 +#ifdef CONFIG_PAX_SEGMEXEC
82902 + if (vma_m) {
82903 + anon_vma_interval_tree_pre_update_vma(vma_m);
82904 + vma_m->vm_start -= grow << PAGE_SHIFT;
82905 + vma_m->vm_pgoff -= grow;
82906 + anon_vma_interval_tree_post_update_vma(vma_m);
82907 + vma_gap_update(vma_m);
82908 + }
82909 +#endif
82910 +
82911 spin_unlock(&vma->vm_mm->page_table_lock);
82912
82913 perf_event_mmap(vma);
82914 @@ -2263,6 +2581,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
82915 do {
82916 long nrpages = vma_pages(vma);
82917
82918 +#ifdef CONFIG_PAX_SEGMEXEC
82919 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
82920 + vma = remove_vma(vma);
82921 + continue;
82922 + }
82923 +#endif
82924 +
82925 if (vma->vm_flags & VM_ACCOUNT)
82926 nr_accounted += nrpages;
82927 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
82928 @@ -2308,6 +2633,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
82929 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
82930 vma->vm_prev = NULL;
82931 do {
82932 +
82933 +#ifdef CONFIG_PAX_SEGMEXEC
82934 + if (vma->vm_mirror) {
82935 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
82936 + vma->vm_mirror->vm_mirror = NULL;
82937 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
82938 + vma->vm_mirror = NULL;
82939 + }
82940 +#endif
82941 +
82942 vma_rb_erase(vma, &mm->mm_rb);
82943 mm->map_count--;
82944 tail_vma = vma;
82945 @@ -2339,14 +2674,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82946 struct vm_area_struct *new;
82947 int err = -ENOMEM;
82948
82949 +#ifdef CONFIG_PAX_SEGMEXEC
82950 + struct vm_area_struct *vma_m, *new_m = NULL;
82951 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
82952 +#endif
82953 +
82954 if (is_vm_hugetlb_page(vma) && (addr &
82955 ~(huge_page_mask(hstate_vma(vma)))))
82956 return -EINVAL;
82957
82958 +#ifdef CONFIG_PAX_SEGMEXEC
82959 + vma_m = pax_find_mirror_vma(vma);
82960 +#endif
82961 +
82962 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82963 if (!new)
82964 goto out_err;
82965
82966 +#ifdef CONFIG_PAX_SEGMEXEC
82967 + if (vma_m) {
82968 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82969 + if (!new_m) {
82970 + kmem_cache_free(vm_area_cachep, new);
82971 + goto out_err;
82972 + }
82973 + }
82974 +#endif
82975 +
82976 /* most fields are the same, copy all, and then fixup */
82977 *new = *vma;
82978
82979 @@ -2359,6 +2713,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82980 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
82981 }
82982
82983 +#ifdef CONFIG_PAX_SEGMEXEC
82984 + if (vma_m) {
82985 + *new_m = *vma_m;
82986 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
82987 + new_m->vm_mirror = new;
82988 + new->vm_mirror = new_m;
82989 +
82990 + if (new_below)
82991 + new_m->vm_end = addr_m;
82992 + else {
82993 + new_m->vm_start = addr_m;
82994 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
82995 + }
82996 + }
82997 +#endif
82998 +
82999 pol = mpol_dup(vma_policy(vma));
83000 if (IS_ERR(pol)) {
83001 err = PTR_ERR(pol);
83002 @@ -2381,6 +2751,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83003 else
83004 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
83005
83006 +#ifdef CONFIG_PAX_SEGMEXEC
83007 + if (!err && vma_m) {
83008 + if (anon_vma_clone(new_m, vma_m))
83009 + goto out_free_mpol;
83010 +
83011 + mpol_get(pol);
83012 + vma_set_policy(new_m, pol);
83013 +
83014 + if (new_m->vm_file)
83015 + get_file(new_m->vm_file);
83016 +
83017 + if (new_m->vm_ops && new_m->vm_ops->open)
83018 + new_m->vm_ops->open(new_m);
83019 +
83020 + if (new_below)
83021 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
83022 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
83023 + else
83024 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
83025 +
83026 + if (err) {
83027 + if (new_m->vm_ops && new_m->vm_ops->close)
83028 + new_m->vm_ops->close(new_m);
83029 + if (new_m->vm_file)
83030 + fput(new_m->vm_file);
83031 + mpol_put(pol);
83032 + }
83033 + }
83034 +#endif
83035 +
83036 /* Success. */
83037 if (!err)
83038 return 0;
83039 @@ -2390,10 +2790,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83040 new->vm_ops->close(new);
83041 if (new->vm_file)
83042 fput(new->vm_file);
83043 - unlink_anon_vmas(new);
83044 out_free_mpol:
83045 mpol_put(pol);
83046 out_free_vma:
83047 +
83048 +#ifdef CONFIG_PAX_SEGMEXEC
83049 + if (new_m) {
83050 + unlink_anon_vmas(new_m);
83051 + kmem_cache_free(vm_area_cachep, new_m);
83052 + }
83053 +#endif
83054 +
83055 + unlink_anon_vmas(new);
83056 kmem_cache_free(vm_area_cachep, new);
83057 out_err:
83058 return err;
83059 @@ -2406,6 +2814,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83060 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83061 unsigned long addr, int new_below)
83062 {
83063 +
83064 +#ifdef CONFIG_PAX_SEGMEXEC
83065 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
83066 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
83067 + if (mm->map_count >= sysctl_max_map_count-1)
83068 + return -ENOMEM;
83069 + } else
83070 +#endif
83071 +
83072 if (mm->map_count >= sysctl_max_map_count)
83073 return -ENOMEM;
83074
83075 @@ -2417,11 +2834,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83076 * work. This now handles partial unmappings.
83077 * Jeremy Fitzhardinge <jeremy@goop.org>
83078 */
83079 +#ifdef CONFIG_PAX_SEGMEXEC
83080 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83081 {
83082 + int ret = __do_munmap(mm, start, len);
83083 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
83084 + return ret;
83085 +
83086 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
83087 +}
83088 +
83089 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83090 +#else
83091 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83092 +#endif
83093 +{
83094 unsigned long end;
83095 struct vm_area_struct *vma, *prev, *last;
83096
83097 + /*
83098 + * mm->mmap_sem is required to protect against another thread
83099 + * changing the mappings in case we sleep.
83100 + */
83101 + verify_mm_writelocked(mm);
83102 +
83103 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
83104 return -EINVAL;
83105
83106 @@ -2496,6 +2932,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83107 /* Fix up all other VM information */
83108 remove_vma_list(mm, vma);
83109
83110 + track_exec_limit(mm, start, end, 0UL);
83111 +
83112 return 0;
83113 }
83114
83115 @@ -2504,6 +2942,13 @@ int vm_munmap(unsigned long start, size_t len)
83116 int ret;
83117 struct mm_struct *mm = current->mm;
83118
83119 +
83120 +#ifdef CONFIG_PAX_SEGMEXEC
83121 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
83122 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
83123 + return -EINVAL;
83124 +#endif
83125 +
83126 down_write(&mm->mmap_sem);
83127 ret = do_munmap(mm, start, len);
83128 up_write(&mm->mmap_sem);
83129 @@ -2517,16 +2962,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
83130 return vm_munmap(addr, len);
83131 }
83132
83133 -static inline void verify_mm_writelocked(struct mm_struct *mm)
83134 -{
83135 -#ifdef CONFIG_DEBUG_VM
83136 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
83137 - WARN_ON(1);
83138 - up_read(&mm->mmap_sem);
83139 - }
83140 -#endif
83141 -}
83142 -
83143 /*
83144 * this is really a simplified "do_mmap". it only handles
83145 * anonymous maps. eventually we may be able to do some
83146 @@ -2540,6 +2975,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83147 struct rb_node ** rb_link, * rb_parent;
83148 pgoff_t pgoff = addr >> PAGE_SHIFT;
83149 int error;
83150 + unsigned long charged;
83151
83152 len = PAGE_ALIGN(len);
83153 if (!len)
83154 @@ -2547,16 +2983,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83155
83156 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
83157
83158 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
83159 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
83160 + flags &= ~VM_EXEC;
83161 +
83162 +#ifdef CONFIG_PAX_MPROTECT
83163 + if (mm->pax_flags & MF_PAX_MPROTECT)
83164 + flags &= ~VM_MAYEXEC;
83165 +#endif
83166 +
83167 + }
83168 +#endif
83169 +
83170 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
83171 if (error & ~PAGE_MASK)
83172 return error;
83173
83174 + charged = len >> PAGE_SHIFT;
83175 +
83176 /*
83177 * mlock MCL_FUTURE?
83178 */
83179 if (mm->def_flags & VM_LOCKED) {
83180 unsigned long locked, lock_limit;
83181 - locked = len >> PAGE_SHIFT;
83182 + locked = charged;
83183 locked += mm->locked_vm;
83184 lock_limit = rlimit(RLIMIT_MEMLOCK);
83185 lock_limit >>= PAGE_SHIFT;
83186 @@ -2573,21 +3023,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83187 /*
83188 * Clear old maps. this also does some error checking for us
83189 */
83190 - munmap_back:
83191 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
83192 if (do_munmap(mm, addr, len))
83193 return -ENOMEM;
83194 - goto munmap_back;
83195 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
83196 }
83197
83198 /* Check against address space limits *after* clearing old maps... */
83199 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
83200 + if (!may_expand_vm(mm, charged))
83201 return -ENOMEM;
83202
83203 if (mm->map_count > sysctl_max_map_count)
83204 return -ENOMEM;
83205
83206 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
83207 + if (security_vm_enough_memory_mm(mm, charged))
83208 return -ENOMEM;
83209
83210 /* Can we just expand an old private anonymous mapping? */
83211 @@ -2601,7 +3050,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83212 */
83213 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83214 if (!vma) {
83215 - vm_unacct_memory(len >> PAGE_SHIFT);
83216 + vm_unacct_memory(charged);
83217 return -ENOMEM;
83218 }
83219
83220 @@ -2615,11 +3064,12 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83221 vma_link(mm, vma, prev, rb_link, rb_parent);
83222 out:
83223 perf_event_mmap(vma);
83224 - mm->total_vm += len >> PAGE_SHIFT;
83225 + mm->total_vm += charged;
83226 if (flags & VM_LOCKED) {
83227 if (!mlock_vma_pages_range(vma, addr, addr + len))
83228 - mm->locked_vm += (len >> PAGE_SHIFT);
83229 + mm->locked_vm += charged;
83230 }
83231 + track_exec_limit(mm, addr, addr + len, flags);
83232 return addr;
83233 }
83234
83235 @@ -2677,6 +3127,7 @@ void exit_mmap(struct mm_struct *mm)
83236 while (vma) {
83237 if (vma->vm_flags & VM_ACCOUNT)
83238 nr_accounted += vma_pages(vma);
83239 + vma->vm_mirror = NULL;
83240 vma = remove_vma(vma);
83241 }
83242 vm_unacct_memory(nr_accounted);
83243 @@ -2693,6 +3144,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83244 struct vm_area_struct *prev;
83245 struct rb_node **rb_link, *rb_parent;
83246
83247 +#ifdef CONFIG_PAX_SEGMEXEC
83248 + struct vm_area_struct *vma_m = NULL;
83249 +#endif
83250 +
83251 + if (security_mmap_addr(vma->vm_start))
83252 + return -EPERM;
83253 +
83254 /*
83255 * The vm_pgoff of a purely anonymous vma should be irrelevant
83256 * until its first write fault, when page's anon_vma and index
83257 @@ -2716,7 +3174,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83258 security_vm_enough_memory_mm(mm, vma_pages(vma)))
83259 return -ENOMEM;
83260
83261 +#ifdef CONFIG_PAX_SEGMEXEC
83262 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
83263 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83264 + if (!vma_m)
83265 + return -ENOMEM;
83266 + }
83267 +#endif
83268 +
83269 vma_link(mm, vma, prev, rb_link, rb_parent);
83270 +
83271 +#ifdef CONFIG_PAX_SEGMEXEC
83272 + if (vma_m)
83273 + BUG_ON(pax_mirror_vma(vma_m, vma));
83274 +#endif
83275 +
83276 return 0;
83277 }
83278
83279 @@ -2736,6 +3208,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83280 struct mempolicy *pol;
83281 bool faulted_in_anon_vma = true;
83282
83283 + BUG_ON(vma->vm_mirror);
83284 +
83285 /*
83286 * If anonymous vma has not yet been faulted, update new pgoff
83287 * to match new location, to increase its chance of merging.
83288 @@ -2802,6 +3276,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83289 return NULL;
83290 }
83291
83292 +#ifdef CONFIG_PAX_SEGMEXEC
83293 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
83294 +{
83295 + struct vm_area_struct *prev_m;
83296 + struct rb_node **rb_link_m, *rb_parent_m;
83297 + struct mempolicy *pol_m;
83298 +
83299 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
83300 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
83301 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
83302 + *vma_m = *vma;
83303 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
83304 + if (anon_vma_clone(vma_m, vma))
83305 + return -ENOMEM;
83306 + pol_m = vma_policy(vma_m);
83307 + mpol_get(pol_m);
83308 + vma_set_policy(vma_m, pol_m);
83309 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
83310 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
83311 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
83312 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
83313 + if (vma_m->vm_file)
83314 + get_file(vma_m->vm_file);
83315 + if (vma_m->vm_ops && vma_m->vm_ops->open)
83316 + vma_m->vm_ops->open(vma_m);
83317 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
83318 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
83319 + vma_m->vm_mirror = vma;
83320 + vma->vm_mirror = vma_m;
83321 + return 0;
83322 +}
83323 +#endif
83324 +
83325 /*
83326 * Return true if the calling process may expand its vm space by the passed
83327 * number of pages
83328 @@ -2813,6 +3320,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
83329
83330 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
83331
83332 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
83333 if (cur + npages > lim)
83334 return 0;
83335 return 1;
83336 @@ -2883,6 +3391,22 @@ int install_special_mapping(struct mm_struct *mm,
83337 vma->vm_start = addr;
83338 vma->vm_end = addr + len;
83339
83340 +#ifdef CONFIG_PAX_MPROTECT
83341 + if (mm->pax_flags & MF_PAX_MPROTECT) {
83342 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
83343 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
83344 + return -EPERM;
83345 + if (!(vm_flags & VM_EXEC))
83346 + vm_flags &= ~VM_MAYEXEC;
83347 +#else
83348 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
83349 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
83350 +#endif
83351 + else
83352 + vm_flags &= ~VM_MAYWRITE;
83353 + }
83354 +#endif
83355 +
83356 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
83357 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
83358
83359 diff --git a/mm/mprotect.c b/mm/mprotect.c
83360 index 94722a4..9837984 100644
83361 --- a/mm/mprotect.c
83362 +++ b/mm/mprotect.c
83363 @@ -23,10 +23,17 @@
83364 #include <linux/mmu_notifier.h>
83365 #include <linux/migrate.h>
83366 #include <linux/perf_event.h>
83367 +
83368 +#ifdef CONFIG_PAX_MPROTECT
83369 +#include <linux/elf.h>
83370 +#include <linux/binfmts.h>
83371 +#endif
83372 +
83373 #include <asm/uaccess.h>
83374 #include <asm/pgtable.h>
83375 #include <asm/cacheflush.h>
83376 #include <asm/tlbflush.h>
83377 +#include <asm/mmu_context.h>
83378
83379 #ifndef pgprot_modify
83380 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
83381 @@ -233,6 +240,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
83382 return pages;
83383 }
83384
83385 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83386 +/* called while holding the mmap semaphor for writing except stack expansion */
83387 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
83388 +{
83389 + unsigned long oldlimit, newlimit = 0UL;
83390 +
83391 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
83392 + return;
83393 +
83394 + spin_lock(&mm->page_table_lock);
83395 + oldlimit = mm->context.user_cs_limit;
83396 + if ((prot & VM_EXEC) && oldlimit < end)
83397 + /* USER_CS limit moved up */
83398 + newlimit = end;
83399 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
83400 + /* USER_CS limit moved down */
83401 + newlimit = start;
83402 +
83403 + if (newlimit) {
83404 + mm->context.user_cs_limit = newlimit;
83405 +
83406 +#ifdef CONFIG_SMP
83407 + wmb();
83408 + cpus_clear(mm->context.cpu_user_cs_mask);
83409 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
83410 +#endif
83411 +
83412 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
83413 + }
83414 + spin_unlock(&mm->page_table_lock);
83415 + if (newlimit == end) {
83416 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
83417 +
83418 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
83419 + if (is_vm_hugetlb_page(vma))
83420 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
83421 + else
83422 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
83423 + }
83424 +}
83425 +#endif
83426 +
83427 int
83428 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83429 unsigned long start, unsigned long end, unsigned long newflags)
83430 @@ -245,11 +294,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83431 int error;
83432 int dirty_accountable = 0;
83433
83434 +#ifdef CONFIG_PAX_SEGMEXEC
83435 + struct vm_area_struct *vma_m = NULL;
83436 + unsigned long start_m, end_m;
83437 +
83438 + start_m = start + SEGMEXEC_TASK_SIZE;
83439 + end_m = end + SEGMEXEC_TASK_SIZE;
83440 +#endif
83441 +
83442 if (newflags == oldflags) {
83443 *pprev = vma;
83444 return 0;
83445 }
83446
83447 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
83448 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
83449 +
83450 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
83451 + return -ENOMEM;
83452 +
83453 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
83454 + return -ENOMEM;
83455 + }
83456 +
83457 /*
83458 * If we make a private mapping writable we increase our commit;
83459 * but (without finer accounting) cannot reduce our commit if we
83460 @@ -266,6 +333,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83461 }
83462 }
83463
83464 +#ifdef CONFIG_PAX_SEGMEXEC
83465 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
83466 + if (start != vma->vm_start) {
83467 + error = split_vma(mm, vma, start, 1);
83468 + if (error)
83469 + goto fail;
83470 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
83471 + *pprev = (*pprev)->vm_next;
83472 + }
83473 +
83474 + if (end != vma->vm_end) {
83475 + error = split_vma(mm, vma, end, 0);
83476 + if (error)
83477 + goto fail;
83478 + }
83479 +
83480 + if (pax_find_mirror_vma(vma)) {
83481 + error = __do_munmap(mm, start_m, end_m - start_m);
83482 + if (error)
83483 + goto fail;
83484 + } else {
83485 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83486 + if (!vma_m) {
83487 + error = -ENOMEM;
83488 + goto fail;
83489 + }
83490 + vma->vm_flags = newflags;
83491 + error = pax_mirror_vma(vma_m, vma);
83492 + if (error) {
83493 + vma->vm_flags = oldflags;
83494 + goto fail;
83495 + }
83496 + }
83497 + }
83498 +#endif
83499 +
83500 /*
83501 * First try to merge with previous and/or next vma.
83502 */
83503 @@ -296,9 +399,21 @@ success:
83504 * vm_flags and vm_page_prot are protected by the mmap_sem
83505 * held in write mode.
83506 */
83507 +
83508 +#ifdef CONFIG_PAX_SEGMEXEC
83509 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
83510 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
83511 +#endif
83512 +
83513 vma->vm_flags = newflags;
83514 +
83515 +#ifdef CONFIG_PAX_MPROTECT
83516 + if (mm->binfmt && mm->binfmt->handle_mprotect)
83517 + mm->binfmt->handle_mprotect(vma, newflags);
83518 +#endif
83519 +
83520 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
83521 - vm_get_page_prot(newflags));
83522 + vm_get_page_prot(vma->vm_flags));
83523
83524 if (vma_wants_writenotify(vma)) {
83525 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
83526 @@ -337,6 +452,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83527 end = start + len;
83528 if (end <= start)
83529 return -ENOMEM;
83530 +
83531 +#ifdef CONFIG_PAX_SEGMEXEC
83532 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
83533 + if (end > SEGMEXEC_TASK_SIZE)
83534 + return -EINVAL;
83535 + } else
83536 +#endif
83537 +
83538 + if (end > TASK_SIZE)
83539 + return -EINVAL;
83540 +
83541 if (!arch_validate_prot(prot))
83542 return -EINVAL;
83543
83544 @@ -344,7 +470,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83545 /*
83546 * Does the application expect PROT_READ to imply PROT_EXEC:
83547 */
83548 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
83549 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
83550 prot |= PROT_EXEC;
83551
83552 vm_flags = calc_vm_prot_bits(prot);
83553 @@ -376,6 +502,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83554 if (start > vma->vm_start)
83555 prev = vma;
83556
83557 +#ifdef CONFIG_PAX_MPROTECT
83558 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
83559 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
83560 +#endif
83561 +
83562 for (nstart = start ; ; ) {
83563 unsigned long newflags;
83564
83565 @@ -386,6 +517,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83566
83567 /* newflags >> 4 shift VM_MAY% in place of VM_% */
83568 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
83569 + if (prot & (PROT_WRITE | PROT_EXEC))
83570 + gr_log_rwxmprotect(vma->vm_file);
83571 +
83572 + error = -EACCES;
83573 + goto out;
83574 + }
83575 +
83576 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
83577 error = -EACCES;
83578 goto out;
83579 }
83580 @@ -400,6 +539,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83581 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
83582 if (error)
83583 goto out;
83584 +
83585 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
83586 +
83587 nstart = tmp;
83588
83589 if (nstart < prev->vm_end)
83590 diff --git a/mm/mremap.c b/mm/mremap.c
83591 index e1031e1..1f2a0a1 100644
83592 --- a/mm/mremap.c
83593 +++ b/mm/mremap.c
83594 @@ -125,6 +125,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
83595 continue;
83596 pte = ptep_get_and_clear(mm, old_addr, old_pte);
83597 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
83598 +
83599 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83600 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
83601 + pte = pte_exprotect(pte);
83602 +#endif
83603 +
83604 set_pte_at(mm, new_addr, new_pte, pte);
83605 }
83606
83607 @@ -319,6 +325,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
83608 if (is_vm_hugetlb_page(vma))
83609 goto Einval;
83610
83611 +#ifdef CONFIG_PAX_SEGMEXEC
83612 + if (pax_find_mirror_vma(vma))
83613 + goto Einval;
83614 +#endif
83615 +
83616 /* We can't remap across vm area boundaries */
83617 if (old_len > vma->vm_end - addr)
83618 goto Efault;
83619 @@ -375,20 +386,25 @@ static unsigned long mremap_to(unsigned long addr,
83620 unsigned long ret = -EINVAL;
83621 unsigned long charged = 0;
83622 unsigned long map_flags;
83623 + unsigned long pax_task_size = TASK_SIZE;
83624
83625 if (new_addr & ~PAGE_MASK)
83626 goto out;
83627
83628 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
83629 +#ifdef CONFIG_PAX_SEGMEXEC
83630 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83631 + pax_task_size = SEGMEXEC_TASK_SIZE;
83632 +#endif
83633 +
83634 + pax_task_size -= PAGE_SIZE;
83635 +
83636 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
83637 goto out;
83638
83639 /* Check if the location we're moving into overlaps the
83640 * old location at all, and fail if it does.
83641 */
83642 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
83643 - goto out;
83644 -
83645 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
83646 + if (addr + old_len > new_addr && new_addr + new_len > addr)
83647 goto out;
83648
83649 ret = do_munmap(mm, new_addr, new_len);
83650 @@ -456,6 +472,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83651 struct vm_area_struct *vma;
83652 unsigned long ret = -EINVAL;
83653 unsigned long charged = 0;
83654 + unsigned long pax_task_size = TASK_SIZE;
83655
83656 down_write(&current->mm->mmap_sem);
83657
83658 @@ -476,6 +493,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83659 if (!new_len)
83660 goto out;
83661
83662 +#ifdef CONFIG_PAX_SEGMEXEC
83663 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83664 + pax_task_size = SEGMEXEC_TASK_SIZE;
83665 +#endif
83666 +
83667 + pax_task_size -= PAGE_SIZE;
83668 +
83669 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
83670 + old_len > pax_task_size || addr > pax_task_size-old_len)
83671 + goto out;
83672 +
83673 if (flags & MREMAP_FIXED) {
83674 if (flags & MREMAP_MAYMOVE)
83675 ret = mremap_to(addr, old_len, new_addr, new_len);
83676 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83677 addr + new_len);
83678 }
83679 ret = addr;
83680 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
83681 goto out;
83682 }
83683 }
83684 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83685 goto out;
83686 }
83687
83688 + map_flags = vma->vm_flags;
83689 ret = move_vma(vma, addr, old_len, new_len, new_addr);
83690 + if (!(ret & ~PAGE_MASK)) {
83691 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
83692 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
83693 + }
83694 }
83695 out:
83696 if (ret & ~PAGE_MASK)
83697 diff --git a/mm/nommu.c b/mm/nommu.c
83698 index 79c3cac..b2601ea 100644
83699 --- a/mm/nommu.c
83700 +++ b/mm/nommu.c
83701 @@ -62,7 +62,6 @@ int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
83702 int sysctl_overcommit_ratio = 50; /* default is 50% */
83703 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
83704 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
83705 -int heap_stack_gap = 0;
83706
83707 atomic_long_t mmap_pages_allocated;
83708
83709 @@ -819,7 +818,7 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
83710 struct vm_area_struct *vma;
83711
83712 /* check the cache first */
83713 - vma = mm->mmap_cache;
83714 + vma = ACCESS_ONCE(mm->mmap_cache);
83715 if (vma && vma->vm_start <= addr && vma->vm_end > addr)
83716 return vma;
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..3ab04ef 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 @@ -3752,7 +3791,13 @@ static int pageblock_is_reserved(unsigned long start_pfn, unsigned long end_pfn)
83892 unsigned long pfn;
83893
83894 for (pfn = start_pfn; pfn < end_pfn; pfn++) {
83895 +#ifdef CONFIG_X86_32
83896 + /* boot failures in VMware 8 on 32bit vanilla since
83897 + this change */
83898 + if (!pfn_valid(pfn) || PageReserved(pfn_to_page(pfn)))
83899 +#else
83900 if (!pfn_valid_within(pfn) || PageReserved(pfn_to_page(pfn)))
83901 +#endif
83902 return 1;
83903 }
83904 return 0;
83905 diff --git a/mm/percpu.c b/mm/percpu.c
83906 index 8c8e08f..73a5cda 100644
83907 --- a/mm/percpu.c
83908 +++ b/mm/percpu.c
83909 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
83910 static unsigned int pcpu_high_unit_cpu __read_mostly;
83911
83912 /* the address of the first chunk which starts with the kernel static area */
83913 -void *pcpu_base_addr __read_mostly;
83914 +void *pcpu_base_addr __read_only;
83915 EXPORT_SYMBOL_GPL(pcpu_base_addr);
83916
83917 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
83918 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
83919 index fd26d04..0cea1b0 100644
83920 --- a/mm/process_vm_access.c
83921 +++ b/mm/process_vm_access.c
83922 @@ -13,6 +13,7 @@
83923 #include <linux/uio.h>
83924 #include <linux/sched.h>
83925 #include <linux/highmem.h>
83926 +#include <linux/security.h>
83927 #include <linux/ptrace.h>
83928 #include <linux/slab.h>
83929 #include <linux/syscalls.h>
83930 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83931 size_t iov_l_curr_offset = 0;
83932 ssize_t iov_len;
83933
83934 + return -ENOSYS; // PaX: until properly audited
83935 +
83936 /*
83937 * Work out how many pages of struct pages we're going to need
83938 * when eventually calling get_user_pages
83939 */
83940 for (i = 0; i < riovcnt; i++) {
83941 iov_len = rvec[i].iov_len;
83942 - if (iov_len > 0) {
83943 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
83944 - + iov_len)
83945 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
83946 - / PAGE_SIZE + 1;
83947 - nr_pages = max(nr_pages, nr_pages_iov);
83948 - }
83949 + if (iov_len <= 0)
83950 + continue;
83951 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
83952 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
83953 + nr_pages = max(nr_pages, nr_pages_iov);
83954 }
83955
83956 if (nr_pages == 0)
83957 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83958 goto free_proc_pages;
83959 }
83960
83961 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
83962 + rc = -EPERM;
83963 + goto put_task_struct;
83964 + }
83965 +
83966 mm = mm_access(task, PTRACE_MODE_ATTACH);
83967 if (!mm || IS_ERR(mm)) {
83968 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
83969 diff --git a/mm/rmap.c b/mm/rmap.c
83970 index 2c78f8c..9e9c624 100644
83971 --- a/mm/rmap.c
83972 +++ b/mm/rmap.c
83973 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83974 struct anon_vma *anon_vma = vma->anon_vma;
83975 struct anon_vma_chain *avc;
83976
83977 +#ifdef CONFIG_PAX_SEGMEXEC
83978 + struct anon_vma_chain *avc_m = NULL;
83979 +#endif
83980 +
83981 might_sleep();
83982 if (unlikely(!anon_vma)) {
83983 struct mm_struct *mm = vma->vm_mm;
83984 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83985 if (!avc)
83986 goto out_enomem;
83987
83988 +#ifdef CONFIG_PAX_SEGMEXEC
83989 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
83990 + if (!avc_m)
83991 + goto out_enomem_free_avc;
83992 +#endif
83993 +
83994 anon_vma = find_mergeable_anon_vma(vma);
83995 allocated = NULL;
83996 if (!anon_vma) {
83997 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83998 /* page_table_lock to protect against threads */
83999 spin_lock(&mm->page_table_lock);
84000 if (likely(!vma->anon_vma)) {
84001 +
84002 +#ifdef CONFIG_PAX_SEGMEXEC
84003 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
84004 +
84005 + if (vma_m) {
84006 + BUG_ON(vma_m->anon_vma);
84007 + vma_m->anon_vma = anon_vma;
84008 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
84009 + avc_m = NULL;
84010 + }
84011 +#endif
84012 +
84013 vma->anon_vma = anon_vma;
84014 anon_vma_chain_link(vma, avc, anon_vma);
84015 allocated = NULL;
84016 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84017
84018 if (unlikely(allocated))
84019 put_anon_vma(allocated);
84020 +
84021 +#ifdef CONFIG_PAX_SEGMEXEC
84022 + if (unlikely(avc_m))
84023 + anon_vma_chain_free(avc_m);
84024 +#endif
84025 +
84026 if (unlikely(avc))
84027 anon_vma_chain_free(avc);
84028 }
84029 return 0;
84030
84031 out_enomem_free_avc:
84032 +
84033 +#ifdef CONFIG_PAX_SEGMEXEC
84034 + if (avc_m)
84035 + anon_vma_chain_free(avc_m);
84036 +#endif
84037 +
84038 anon_vma_chain_free(avc);
84039 out_enomem:
84040 return -ENOMEM;
84041 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
84042 * Attach the anon_vmas from src to dst.
84043 * Returns 0 on success, -ENOMEM on failure.
84044 */
84045 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
84046 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
84047 {
84048 struct anon_vma_chain *avc, *pavc;
84049 struct anon_vma *root = NULL;
84050 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
84051 * the corresponding VMA in the parent process is attached to.
84052 * Returns 0 on success, non-zero on failure.
84053 */
84054 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
84055 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
84056 {
84057 struct anon_vma_chain *avc;
84058 struct anon_vma *anon_vma;
84059 diff --git a/mm/shmem.c b/mm/shmem.c
84060 index efd0b3a..994b702 100644
84061 --- a/mm/shmem.c
84062 +++ b/mm/shmem.c
84063 @@ -31,7 +31,7 @@
84064 #include <linux/export.h>
84065 #include <linux/swap.h>
84066
84067 -static struct vfsmount *shm_mnt;
84068 +struct vfsmount *shm_mnt;
84069
84070 #ifdef CONFIG_SHMEM
84071 /*
84072 @@ -75,7 +75,7 @@ static struct vfsmount *shm_mnt;
84073 #define BOGO_DIRENT_SIZE 20
84074
84075 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
84076 -#define SHORT_SYMLINK_LEN 128
84077 +#define SHORT_SYMLINK_LEN 64
84078
84079 /*
84080 * shmem_fallocate and shmem_writepage communicate via inode->i_private
84081 @@ -2202,6 +2202,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
84082 static int shmem_xattr_validate(const char *name)
84083 {
84084 struct { const char *prefix; size_t len; } arr[] = {
84085 +
84086 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
84087 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
84088 +#endif
84089 +
84090 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
84091 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
84092 };
84093 @@ -2257,6 +2262,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
84094 if (err)
84095 return err;
84096
84097 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
84098 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
84099 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
84100 + return -EOPNOTSUPP;
84101 + if (size > 8)
84102 + return -EINVAL;
84103 + }
84104 +#endif
84105 +
84106 return simple_xattr_set(&info->xattrs, name, value, size, flags);
84107 }
84108
84109 @@ -2562,8 +2576,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
84110 int err = -ENOMEM;
84111
84112 /* Round up to L1_CACHE_BYTES to resist false sharing */
84113 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
84114 - L1_CACHE_BYTES), GFP_KERNEL);
84115 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
84116 if (!sbinfo)
84117 return -ENOMEM;
84118
84119 diff --git a/mm/slab.c b/mm/slab.c
84120 index e7667a3..a48e73b 100644
84121 --- a/mm/slab.c
84122 +++ b/mm/slab.c
84123 @@ -306,7 +306,7 @@ struct kmem_list3 {
84124 * Need this for bootstrapping a per node allocator.
84125 */
84126 #define NUM_INIT_LISTS (3 * MAX_NUMNODES)
84127 -static struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
84128 +static struct kmem_list3 initkmem_list3[NUM_INIT_LISTS];
84129 #define CACHE_CACHE 0
84130 #define SIZE_AC MAX_NUMNODES
84131 #define SIZE_L3 (2 * MAX_NUMNODES)
84132 @@ -407,10 +407,10 @@ static void kmem_list3_init(struct kmem_list3 *parent)
84133 if ((x)->max_freeable < i) \
84134 (x)->max_freeable = i; \
84135 } while (0)
84136 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
84137 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
84138 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
84139 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
84140 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
84141 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
84142 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
84143 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
84144 #else
84145 #define STATS_INC_ACTIVE(x) do { } while (0)
84146 #define STATS_DEC_ACTIVE(x) do { } while (0)
84147 @@ -518,7 +518,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
84148 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
84149 */
84150 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
84151 - const struct slab *slab, void *obj)
84152 + const struct slab *slab, const void *obj)
84153 {
84154 u32 offset = (obj - slab->s_mem);
84155 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
84156 @@ -539,12 +539,13 @@ EXPORT_SYMBOL(malloc_sizes);
84157 struct cache_names {
84158 char *name;
84159 char *name_dma;
84160 + char *name_usercopy;
84161 };
84162
84163 static struct cache_names __initdata cache_names[] = {
84164 -#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)" },
84165 +#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)", .name_usercopy = "size-" #x "(USERCOPY)" },
84166 #include <linux/kmalloc_sizes.h>
84167 - {NULL,}
84168 + {NULL}
84169 #undef CACHE
84170 };
84171
84172 @@ -729,6 +730,12 @@ static inline struct kmem_cache *__find_general_cachep(size_t size,
84173 if (unlikely(gfpflags & GFP_DMA))
84174 return csizep->cs_dmacachep;
84175 #endif
84176 +
84177 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84178 + if (unlikely(gfpflags & GFP_USERCOPY))
84179 + return csizep->cs_usercopycachep;
84180 +#endif
84181 +
84182 return csizep->cs_cachep;
84183 }
84184
84185 @@ -1482,7 +1489,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
84186 return notifier_from_errno(err);
84187 }
84188
84189 -static struct notifier_block __cpuinitdata cpucache_notifier = {
84190 +static struct notifier_block cpucache_notifier = {
84191 &cpuup_callback, NULL, 0
84192 };
84193
84194 @@ -1667,12 +1674,12 @@ void __init kmem_cache_init(void)
84195 */
84196
84197 sizes[INDEX_AC].cs_cachep = create_kmalloc_cache(names[INDEX_AC].name,
84198 - sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS);
84199 + sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84200
84201 if (INDEX_AC != INDEX_L3)
84202 sizes[INDEX_L3].cs_cachep =
84203 create_kmalloc_cache(names[INDEX_L3].name,
84204 - sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS);
84205 + sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84206
84207 slab_early_init = 0;
84208
84209 @@ -1686,13 +1693,20 @@ void __init kmem_cache_init(void)
84210 */
84211 if (!sizes->cs_cachep)
84212 sizes->cs_cachep = create_kmalloc_cache(names->name,
84213 - sizes->cs_size, ARCH_KMALLOC_FLAGS);
84214 + sizes->cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84215
84216 #ifdef CONFIG_ZONE_DMA
84217 sizes->cs_dmacachep = create_kmalloc_cache(
84218 names->name_dma, sizes->cs_size,
84219 SLAB_CACHE_DMA|ARCH_KMALLOC_FLAGS);
84220 #endif
84221 +
84222 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84223 + sizes->cs_usercopycachep = create_kmalloc_cache(
84224 + names->name_usercopy, sizes->cs_size,
84225 + ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84226 +#endif
84227 +
84228 sizes++;
84229 names++;
84230 }
84231 @@ -3924,6 +3938,7 @@ void kfree(const void *objp)
84232
84233 if (unlikely(ZERO_OR_NULL_PTR(objp)))
84234 return;
84235 + VM_BUG_ON(!virt_addr_valid(objp));
84236 local_irq_save(flags);
84237 kfree_debugcheck(objp);
84238 c = virt_to_cache(objp);
84239 @@ -4365,10 +4380,10 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
84240 }
84241 /* cpu stats */
84242 {
84243 - unsigned long allochit = atomic_read(&cachep->allochit);
84244 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
84245 - unsigned long freehit = atomic_read(&cachep->freehit);
84246 - unsigned long freemiss = atomic_read(&cachep->freemiss);
84247 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
84248 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
84249 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
84250 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
84251
84252 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
84253 allochit, allocmiss, freehit, freemiss);
84254 @@ -4600,13 +4615,71 @@ static const struct file_operations proc_slabstats_operations = {
84255 static int __init slab_proc_init(void)
84256 {
84257 #ifdef CONFIG_DEBUG_SLAB_LEAK
84258 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
84259 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
84260 #endif
84261 return 0;
84262 }
84263 module_init(slab_proc_init);
84264 #endif
84265
84266 +bool is_usercopy_object(const void *ptr)
84267 +{
84268 + struct page *page;
84269 + struct kmem_cache *cachep;
84270 +
84271 + if (ZERO_OR_NULL_PTR(ptr))
84272 + return false;
84273 +
84274 + if (!slab_is_available())
84275 + return false;
84276 +
84277 + if (!virt_addr_valid(ptr))
84278 + return false;
84279 +
84280 + page = virt_to_head_page(ptr);
84281 +
84282 + if (!PageSlab(page))
84283 + return false;
84284 +
84285 + cachep = page->slab_cache;
84286 + return cachep->flags & SLAB_USERCOPY;
84287 +}
84288 +
84289 +#ifdef CONFIG_PAX_USERCOPY
84290 +const char *check_heap_object(const void *ptr, unsigned long n)
84291 +{
84292 + struct page *page;
84293 + struct kmem_cache *cachep;
84294 + struct slab *slabp;
84295 + unsigned int objnr;
84296 + unsigned long offset;
84297 +
84298 + if (ZERO_OR_NULL_PTR(ptr))
84299 + return "<null>";
84300 +
84301 + if (!virt_addr_valid(ptr))
84302 + return NULL;
84303 +
84304 + page = virt_to_head_page(ptr);
84305 +
84306 + if (!PageSlab(page))
84307 + return NULL;
84308 +
84309 + cachep = page->slab_cache;
84310 + if (!(cachep->flags & SLAB_USERCOPY))
84311 + return cachep->name;
84312 +
84313 + slabp = page->slab_page;
84314 + objnr = obj_to_index(cachep, slabp, ptr);
84315 + BUG_ON(objnr >= cachep->num);
84316 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
84317 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
84318 + return NULL;
84319 +
84320 + return cachep->name;
84321 +}
84322 +#endif
84323 +
84324 /**
84325 * ksize - get the actual amount of memory allocated for a given object
84326 * @objp: Pointer to the object
84327 diff --git a/mm/slab.h b/mm/slab.h
84328 index 34a98d6..73633d1 100644
84329 --- a/mm/slab.h
84330 +++ b/mm/slab.h
84331 @@ -58,7 +58,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84332
84333 /* Legal flag mask for kmem_cache_create(), for various configurations */
84334 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
84335 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
84336 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_USERCOPY)
84337
84338 #if defined(CONFIG_DEBUG_SLAB)
84339 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
84340 @@ -220,6 +220,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
84341 return s;
84342
84343 page = virt_to_head_page(x);
84344 +
84345 + BUG_ON(!PageSlab(page));
84346 +
84347 cachep = page->slab_cache;
84348 if (slab_equal_or_root(cachep, s))
84349 return cachep;
84350 diff --git a/mm/slab_common.c b/mm/slab_common.c
84351 index 3f3cd97..93b0236 100644
84352 --- a/mm/slab_common.c
84353 +++ b/mm/slab_common.c
84354 @@ -22,7 +22,7 @@
84355
84356 #include "slab.h"
84357
84358 -enum slab_state slab_state;
84359 +enum slab_state slab_state __read_only;
84360 LIST_HEAD(slab_caches);
84361 DEFINE_MUTEX(slab_mutex);
84362 struct kmem_cache *kmem_cache;
84363 @@ -209,7 +209,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
84364
84365 err = __kmem_cache_create(s, flags);
84366 if (!err) {
84367 - s->refcount = 1;
84368 + atomic_set(&s->refcount, 1);
84369 list_add(&s->list, &slab_caches);
84370 memcg_cache_list_add(memcg, s);
84371 } else {
84372 @@ -255,8 +255,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
84373
84374 get_online_cpus();
84375 mutex_lock(&slab_mutex);
84376 - s->refcount--;
84377 - if (!s->refcount) {
84378 + if (atomic_dec_and_test(&s->refcount)) {
84379 list_del(&s->list);
84380
84381 if (!__kmem_cache_shutdown(s)) {
84382 @@ -302,7 +301,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
84383 panic("Creation of kmalloc slab %s size=%zd failed. Reason %d\n",
84384 name, size, err);
84385
84386 - s->refcount = -1; /* Exempt from merging for now */
84387 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
84388 }
84389
84390 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84391 @@ -315,7 +314,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84392
84393 create_boot_cache(s, name, size, flags);
84394 list_add(&s->list, &slab_caches);
84395 - s->refcount = 1;
84396 + atomic_set(&s->refcount, 1);
84397 return s;
84398 }
84399
84400 diff --git a/mm/slob.c b/mm/slob.c
84401 index a99fdf7..6ee34ec 100644
84402 --- a/mm/slob.c
84403 +++ b/mm/slob.c
84404 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
84405 /*
84406 * Return the size of a slob block.
84407 */
84408 -static slobidx_t slob_units(slob_t *s)
84409 +static slobidx_t slob_units(const slob_t *s)
84410 {
84411 if (s->units > 0)
84412 return s->units;
84413 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
84414 /*
84415 * Return the next free slob block pointer after this one.
84416 */
84417 -static slob_t *slob_next(slob_t *s)
84418 +static slob_t *slob_next(const slob_t *s)
84419 {
84420 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
84421 slobidx_t next;
84422 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
84423 /*
84424 * Returns true if s is the last free block in its page.
84425 */
84426 -static int slob_last(slob_t *s)
84427 +static int slob_last(const slob_t *s)
84428 {
84429 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
84430 }
84431
84432 -static void *slob_new_pages(gfp_t gfp, int order, int node)
84433 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
84434 {
84435 - void *page;
84436 + struct page *page;
84437
84438 #ifdef CONFIG_NUMA
84439 if (node != NUMA_NO_NODE)
84440 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
84441 if (!page)
84442 return NULL;
84443
84444 - return page_address(page);
84445 + __SetPageSlab(page);
84446 + return page;
84447 }
84448
84449 -static void slob_free_pages(void *b, int order)
84450 +static void slob_free_pages(struct page *sp, int order)
84451 {
84452 if (current->reclaim_state)
84453 current->reclaim_state->reclaimed_slab += 1 << order;
84454 - free_pages((unsigned long)b, order);
84455 + __ClearPageSlab(sp);
84456 + reset_page_mapcount(sp);
84457 + sp->private = 0;
84458 + __free_pages(sp, order);
84459 }
84460
84461 /*
84462 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
84463
84464 /* Not enough space: must allocate a new page */
84465 if (!b) {
84466 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84467 - if (!b)
84468 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84469 + if (!sp)
84470 return NULL;
84471 - sp = virt_to_page(b);
84472 - __SetPageSlab(sp);
84473 + b = page_address(sp);
84474
84475 spin_lock_irqsave(&slob_lock, flags);
84476 sp->units = SLOB_UNITS(PAGE_SIZE);
84477 sp->freelist = b;
84478 + sp->private = 0;
84479 INIT_LIST_HEAD(&sp->list);
84480 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
84481 set_slob_page_free(sp, slob_list);
84482 @@ -359,9 +363,7 @@ static void slob_free(void *block, int size)
84483 if (slob_page_free(sp))
84484 clear_slob_page_free(sp);
84485 spin_unlock_irqrestore(&slob_lock, flags);
84486 - __ClearPageSlab(sp);
84487 - reset_page_mapcount(sp);
84488 - slob_free_pages(b, 0);
84489 + slob_free_pages(sp, 0);
84490 return;
84491 }
84492
84493 @@ -424,11 +426,10 @@ out:
84494 */
84495
84496 static __always_inline void *
84497 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84498 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
84499 {
84500 - unsigned int *m;
84501 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84502 - void *ret;
84503 + slob_t *m;
84504 + void *ret = NULL;
84505
84506 gfp &= gfp_allowed_mask;
84507
84508 @@ -442,23 +443,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84509
84510 if (!m)
84511 return NULL;
84512 - *m = size;
84513 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
84514 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
84515 + m[0].units = size;
84516 + m[1].units = align;
84517 ret = (void *)m + align;
84518
84519 trace_kmalloc_node(caller, ret,
84520 size, size + align, gfp, node);
84521 } else {
84522 unsigned int order = get_order(size);
84523 + struct page *page;
84524
84525 if (likely(order))
84526 gfp |= __GFP_COMP;
84527 - ret = slob_new_pages(gfp, order, node);
84528 + page = slob_new_pages(gfp, order, node);
84529 + if (page) {
84530 + ret = page_address(page);
84531 + page->private = size;
84532 + }
84533
84534 trace_kmalloc_node(caller, ret,
84535 size, PAGE_SIZE << order, gfp, node);
84536 }
84537
84538 - kmemleak_alloc(ret, size, 1, gfp);
84539 + return ret;
84540 +}
84541 +
84542 +static __always_inline void *
84543 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84544 +{
84545 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84546 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
84547 +
84548 + if (!ZERO_OR_NULL_PTR(ret))
84549 + kmemleak_alloc(ret, size, 1, gfp);
84550 return ret;
84551 }
84552
84553 @@ -493,34 +512,112 @@ void kfree(const void *block)
84554 return;
84555 kmemleak_free(block);
84556
84557 + VM_BUG_ON(!virt_addr_valid(block));
84558 sp = virt_to_page(block);
84559 - if (PageSlab(sp)) {
84560 + VM_BUG_ON(!PageSlab(sp));
84561 + if (!sp->private) {
84562 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84563 - unsigned int *m = (unsigned int *)(block - align);
84564 - slob_free(m, *m + align);
84565 - } else
84566 + slob_t *m = (slob_t *)(block - align);
84567 + slob_free(m, m[0].units + align);
84568 + } else {
84569 + __ClearPageSlab(sp);
84570 + reset_page_mapcount(sp);
84571 + sp->private = 0;
84572 __free_pages(sp, compound_order(sp));
84573 + }
84574 }
84575 EXPORT_SYMBOL(kfree);
84576
84577 +bool is_usercopy_object(const void *ptr)
84578 +{
84579 + if (!slab_is_available())
84580 + return false;
84581 +
84582 + // PAX: TODO
84583 +
84584 + return false;
84585 +}
84586 +
84587 +#ifdef CONFIG_PAX_USERCOPY
84588 +const char *check_heap_object(const void *ptr, unsigned long n)
84589 +{
84590 + struct page *page;
84591 + const slob_t *free;
84592 + const void *base;
84593 + unsigned long flags;
84594 +
84595 + if (ZERO_OR_NULL_PTR(ptr))
84596 + return "<null>";
84597 +
84598 + if (!virt_addr_valid(ptr))
84599 + return NULL;
84600 +
84601 + page = virt_to_head_page(ptr);
84602 + if (!PageSlab(page))
84603 + return NULL;
84604 +
84605 + if (page->private) {
84606 + base = page;
84607 + if (base <= ptr && n <= page->private - (ptr - base))
84608 + return NULL;
84609 + return "<slob>";
84610 + }
84611 +
84612 + /* some tricky double walking to find the chunk */
84613 + spin_lock_irqsave(&slob_lock, flags);
84614 + base = (void *)((unsigned long)ptr & PAGE_MASK);
84615 + free = page->freelist;
84616 +
84617 + while (!slob_last(free) && (void *)free <= ptr) {
84618 + base = free + slob_units(free);
84619 + free = slob_next(free);
84620 + }
84621 +
84622 + while (base < (void *)free) {
84623 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
84624 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
84625 + int offset;
84626 +
84627 + if (ptr < base + align)
84628 + break;
84629 +
84630 + offset = ptr - base - align;
84631 + if (offset >= m) {
84632 + base += size;
84633 + continue;
84634 + }
84635 +
84636 + if (n > m - offset)
84637 + break;
84638 +
84639 + spin_unlock_irqrestore(&slob_lock, flags);
84640 + return NULL;
84641 + }
84642 +
84643 + spin_unlock_irqrestore(&slob_lock, flags);
84644 + return "<slob>";
84645 +}
84646 +#endif
84647 +
84648 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
84649 size_t ksize(const void *block)
84650 {
84651 struct page *sp;
84652 int align;
84653 - unsigned int *m;
84654 + slob_t *m;
84655
84656 BUG_ON(!block);
84657 if (unlikely(block == ZERO_SIZE_PTR))
84658 return 0;
84659
84660 sp = virt_to_page(block);
84661 - if (unlikely(!PageSlab(sp)))
84662 - return PAGE_SIZE << compound_order(sp);
84663 + VM_BUG_ON(!PageSlab(sp));
84664 + if (sp->private)
84665 + return sp->private;
84666
84667 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84668 - m = (unsigned int *)(block - align);
84669 - return SLOB_UNITS(*m) * SLOB_UNIT;
84670 + m = (slob_t *)(block - align);
84671 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
84672 }
84673 EXPORT_SYMBOL(ksize);
84674
84675 @@ -536,23 +633,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
84676
84677 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
84678 {
84679 - void *b;
84680 + void *b = NULL;
84681
84682 flags &= gfp_allowed_mask;
84683
84684 lockdep_trace_alloc(flags);
84685
84686 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84687 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
84688 +#else
84689 if (c->size < PAGE_SIZE) {
84690 b = slob_alloc(c->size, flags, c->align, node);
84691 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84692 SLOB_UNITS(c->size) * SLOB_UNIT,
84693 flags, node);
84694 } else {
84695 - b = slob_new_pages(flags, get_order(c->size), node);
84696 + struct page *sp;
84697 +
84698 + sp = slob_new_pages(flags, get_order(c->size), node);
84699 + if (sp) {
84700 + b = page_address(sp);
84701 + sp->private = c->size;
84702 + }
84703 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84704 PAGE_SIZE << get_order(c->size),
84705 flags, node);
84706 }
84707 +#endif
84708
84709 if (c->ctor)
84710 c->ctor(b);
84711 @@ -564,10 +671,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
84712
84713 static void __kmem_cache_free(void *b, int size)
84714 {
84715 - if (size < PAGE_SIZE)
84716 + struct page *sp;
84717 +
84718 + sp = virt_to_page(b);
84719 + BUG_ON(!PageSlab(sp));
84720 + if (!sp->private)
84721 slob_free(b, size);
84722 else
84723 - slob_free_pages(b, get_order(size));
84724 + slob_free_pages(sp, get_order(size));
84725 }
84726
84727 static void kmem_rcu_free(struct rcu_head *head)
84728 @@ -580,17 +691,31 @@ static void kmem_rcu_free(struct rcu_head *head)
84729
84730 void kmem_cache_free(struct kmem_cache *c, void *b)
84731 {
84732 + int size = c->size;
84733 +
84734 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84735 + if (size + c->align < PAGE_SIZE) {
84736 + size += c->align;
84737 + b -= c->align;
84738 + }
84739 +#endif
84740 +
84741 kmemleak_free_recursive(b, c->flags);
84742 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
84743 struct slob_rcu *slob_rcu;
84744 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
84745 - slob_rcu->size = c->size;
84746 + slob_rcu = b + (size - sizeof(struct slob_rcu));
84747 + slob_rcu->size = size;
84748 call_rcu(&slob_rcu->head, kmem_rcu_free);
84749 } else {
84750 - __kmem_cache_free(b, c->size);
84751 + __kmem_cache_free(b, size);
84752 }
84753
84754 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84755 + trace_kfree(_RET_IP_, b);
84756 +#else
84757 trace_kmem_cache_free(_RET_IP_, b);
84758 +#endif
84759 +
84760 }
84761 EXPORT_SYMBOL(kmem_cache_free);
84762
84763 diff --git a/mm/slub.c b/mm/slub.c
84764 index ba2ca53..991c4f7 100644
84765 --- a/mm/slub.c
84766 +++ b/mm/slub.c
84767 @@ -197,7 +197,7 @@ struct track {
84768
84769 enum track_item { TRACK_ALLOC, TRACK_FREE };
84770
84771 -#ifdef CONFIG_SYSFS
84772 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84773 static int sysfs_slab_add(struct kmem_cache *);
84774 static int sysfs_slab_alias(struct kmem_cache *, const char *);
84775 static void sysfs_slab_remove(struct kmem_cache *);
84776 @@ -518,7 +518,7 @@ static void print_track(const char *s, struct track *t)
84777 if (!t->addr)
84778 return;
84779
84780 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
84781 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
84782 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
84783 #ifdef CONFIG_STACKTRACE
84784 {
84785 @@ -2653,7 +2653,7 @@ static int slub_min_objects;
84786 * Merge control. If this is set then no merging of slab caches will occur.
84787 * (Could be removed. This was introduced to pacify the merge skeptics.)
84788 */
84789 -static int slub_nomerge;
84790 +static int slub_nomerge = 1;
84791
84792 /*
84793 * Calculate the order of allocation given an slab object size.
84794 @@ -3181,6 +3181,10 @@ EXPORT_SYMBOL(kmalloc_caches);
84795 static struct kmem_cache *kmalloc_dma_caches[SLUB_PAGE_SHIFT];
84796 #endif
84797
84798 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84799 +static struct kmem_cache *kmalloc_usercopy_caches[SLUB_PAGE_SHIFT];
84800 +#endif
84801 +
84802 static int __init setup_slub_min_order(char *str)
84803 {
84804 get_option(&str, &slub_min_order);
84805 @@ -3272,6 +3276,13 @@ static struct kmem_cache *get_slab(size_t size, gfp_t flags)
84806 return kmalloc_dma_caches[index];
84807
84808 #endif
84809 +
84810 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84811 + if (flags & SLAB_USERCOPY)
84812 + return kmalloc_usercopy_caches[index];
84813 +
84814 +#endif
84815 +
84816 return kmalloc_caches[index];
84817 }
84818
84819 @@ -3340,6 +3351,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
84820 EXPORT_SYMBOL(__kmalloc_node);
84821 #endif
84822
84823 +bool is_usercopy_object(const void *ptr)
84824 +{
84825 + struct page *page;
84826 + struct kmem_cache *s;
84827 +
84828 + if (ZERO_OR_NULL_PTR(ptr))
84829 + return false;
84830 +
84831 + if (!slab_is_available())
84832 + return false;
84833 +
84834 + if (!virt_addr_valid(ptr))
84835 + return false;
84836 +
84837 + page = virt_to_head_page(ptr);
84838 +
84839 + if (!PageSlab(page))
84840 + return false;
84841 +
84842 + s = page->slab_cache;
84843 + return s->flags & SLAB_USERCOPY;
84844 +}
84845 +
84846 +#ifdef CONFIG_PAX_USERCOPY
84847 +const char *check_heap_object(const void *ptr, unsigned long n)
84848 +{
84849 + struct page *page;
84850 + struct kmem_cache *s;
84851 + unsigned long offset;
84852 +
84853 + if (ZERO_OR_NULL_PTR(ptr))
84854 + return "<null>";
84855 +
84856 + if (!virt_addr_valid(ptr))
84857 + return NULL;
84858 +
84859 + page = virt_to_head_page(ptr);
84860 +
84861 + if (!PageSlab(page))
84862 + return NULL;
84863 +
84864 + s = page->slab_cache;
84865 + if (!(s->flags & SLAB_USERCOPY))
84866 + return s->name;
84867 +
84868 + offset = (ptr - page_address(page)) % s->size;
84869 + if (offset <= s->object_size && n <= s->object_size - offset)
84870 + return NULL;
84871 +
84872 + return s->name;
84873 +}
84874 +#endif
84875 +
84876 size_t ksize(const void *object)
84877 {
84878 struct page *page;
84879 @@ -3404,6 +3468,7 @@ void kfree(const void *x)
84880 if (unlikely(ZERO_OR_NULL_PTR(x)))
84881 return;
84882
84883 + VM_BUG_ON(!virt_addr_valid(x));
84884 page = virt_to_head_page(x);
84885 if (unlikely(!PageSlab(page))) {
84886 BUG_ON(!PageCompound(page));
84887 @@ -3712,17 +3777,17 @@ void __init kmem_cache_init(void)
84888
84889 /* Caches that are not of the two-to-the-power-of size */
84890 if (KMALLOC_MIN_SIZE <= 32) {
84891 - kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, 0);
84892 + kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, SLAB_USERCOPY);
84893 caches++;
84894 }
84895
84896 if (KMALLOC_MIN_SIZE <= 64) {
84897 - kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, 0);
84898 + kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, SLAB_USERCOPY);
84899 caches++;
84900 }
84901
84902 for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
84903 - kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, 0);
84904 + kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, SLAB_USERCOPY);
84905 caches++;
84906 }
84907
84908 @@ -3764,6 +3829,22 @@ void __init kmem_cache_init(void)
84909 }
84910 }
84911 #endif
84912 +
84913 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84914 + for (i = 0; i < SLUB_PAGE_SHIFT; i++) {
84915 + struct kmem_cache *s = kmalloc_caches[i];
84916 +
84917 + if (s && s->size) {
84918 + char *name = kasprintf(GFP_NOWAIT,
84919 + "usercopy-kmalloc-%d", s->object_size);
84920 +
84921 + BUG_ON(!name);
84922 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(name,
84923 + s->object_size, SLAB_USERCOPY);
84924 + }
84925 + }
84926 +#endif
84927 +
84928 printk(KERN_INFO
84929 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
84930 " CPUs=%d, Nodes=%d\n",
84931 @@ -3790,7 +3871,7 @@ static int slab_unmergeable(struct kmem_cache *s)
84932 /*
84933 * We may have set a slab to be unmergeable during bootstrap.
84934 */
84935 - if (s->refcount < 0)
84936 + if (atomic_read(&s->refcount) < 0)
84937 return 1;
84938
84939 return 0;
84940 @@ -3848,7 +3929,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84941
84942 s = find_mergeable(memcg, size, align, flags, name, ctor);
84943 if (s) {
84944 - s->refcount++;
84945 + atomic_inc(&s->refcount);
84946 /*
84947 * Adjust the object sizes so that we clear
84948 * the complete object on kzalloc.
84949 @@ -3857,7 +3938,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84950 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
84951
84952 if (sysfs_slab_alias(s, name)) {
84953 - s->refcount--;
84954 + atomic_dec(&s->refcount);
84955 s = NULL;
84956 }
84957 }
84958 @@ -3919,7 +4000,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
84959 return NOTIFY_OK;
84960 }
84961
84962 -static struct notifier_block __cpuinitdata slab_notifier = {
84963 +static struct notifier_block slab_notifier = {
84964 .notifier_call = slab_cpuup_callback
84965 };
84966
84967 @@ -3977,7 +4058,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
84968 }
84969 #endif
84970
84971 -#ifdef CONFIG_SYSFS
84972 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84973 static int count_inuse(struct page *page)
84974 {
84975 return page->inuse;
84976 @@ -4364,12 +4445,12 @@ static void resiliency_test(void)
84977 validate_slab_cache(kmalloc_caches[9]);
84978 }
84979 #else
84980 -#ifdef CONFIG_SYSFS
84981 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84982 static void resiliency_test(void) {};
84983 #endif
84984 #endif
84985
84986 -#ifdef CONFIG_SYSFS
84987 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84988 enum slab_stat_type {
84989 SL_ALL, /* All slabs */
84990 SL_PARTIAL, /* Only partially allocated slabs */
84991 @@ -4613,7 +4694,7 @@ SLAB_ATTR_RO(ctor);
84992
84993 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
84994 {
84995 - return sprintf(buf, "%d\n", s->refcount - 1);
84996 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
84997 }
84998 SLAB_ATTR_RO(aliases);
84999
85000 @@ -5266,6 +5347,7 @@ static char *create_unique_id(struct kmem_cache *s)
85001 return name;
85002 }
85003
85004 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85005 static int sysfs_slab_add(struct kmem_cache *s)
85006 {
85007 int err;
85008 @@ -5323,6 +5405,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
85009 kobject_del(&s->kobj);
85010 kobject_put(&s->kobj);
85011 }
85012 +#endif
85013
85014 /*
85015 * Need to buffer aliases during bootup until sysfs becomes
85016 @@ -5336,6 +5419,7 @@ struct saved_alias {
85017
85018 static struct saved_alias *alias_list;
85019
85020 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85021 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
85022 {
85023 struct saved_alias *al;
85024 @@ -5358,6 +5442,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
85025 alias_list = al;
85026 return 0;
85027 }
85028 +#endif
85029
85030 static int __init slab_sysfs_init(void)
85031 {
85032 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
85033 index 1b7e22a..3fcd4f3 100644
85034 --- a/mm/sparse-vmemmap.c
85035 +++ b/mm/sparse-vmemmap.c
85036 @@ -128,7 +128,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
85037 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
85038 if (!p)
85039 return NULL;
85040 - pud_populate(&init_mm, pud, p);
85041 + pud_populate_kernel(&init_mm, pud, p);
85042 }
85043 return pud;
85044 }
85045 @@ -140,7 +140,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
85046 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
85047 if (!p)
85048 return NULL;
85049 - pgd_populate(&init_mm, pgd, p);
85050 + pgd_populate_kernel(&init_mm, pgd, p);
85051 }
85052 return pgd;
85053 }
85054 diff --git a/mm/sparse.c b/mm/sparse.c
85055 index 6b5fb76..db0c190 100644
85056 --- a/mm/sparse.c
85057 +++ b/mm/sparse.c
85058 @@ -782,7 +782,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
85059
85060 for (i = 0; i < PAGES_PER_SECTION; i++) {
85061 if (PageHWPoison(&memmap[i])) {
85062 - atomic_long_sub(1, &mce_bad_pages);
85063 + atomic_long_sub_unchecked(1, &mce_bad_pages);
85064 ClearPageHWPoison(&memmap[i]);
85065 }
85066 }
85067 diff --git a/mm/swap.c b/mm/swap.c
85068 index 6310dc2..3662b3f 100644
85069 --- a/mm/swap.c
85070 +++ b/mm/swap.c
85071 @@ -30,6 +30,7 @@
85072 #include <linux/backing-dev.h>
85073 #include <linux/memcontrol.h>
85074 #include <linux/gfp.h>
85075 +#include <linux/hugetlb.h>
85076
85077 #include "internal.h"
85078
85079 @@ -72,6 +73,8 @@ static void __put_compound_page(struct page *page)
85080
85081 __page_cache_release(page);
85082 dtor = get_compound_page_dtor(page);
85083 + if (!PageHuge(page))
85084 + BUG_ON(dtor != free_compound_page);
85085 (*dtor)(page);
85086 }
85087
85088 diff --git a/mm/swapfile.c b/mm/swapfile.c
85089 index e97a0e5..b50e796 100644
85090 --- a/mm/swapfile.c
85091 +++ b/mm/swapfile.c
85092 @@ -64,7 +64,7 @@ static DEFINE_MUTEX(swapon_mutex);
85093
85094 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
85095 /* Activity counter to indicate that a swapon or swapoff has occurred */
85096 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
85097 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
85098
85099 static inline unsigned char swap_count(unsigned char ent)
85100 {
85101 @@ -1608,7 +1608,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
85102 }
85103 filp_close(swap_file, NULL);
85104 err = 0;
85105 - atomic_inc(&proc_poll_event);
85106 + atomic_inc_unchecked(&proc_poll_event);
85107 wake_up_interruptible(&proc_poll_wait);
85108
85109 out_dput:
85110 @@ -1625,8 +1625,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
85111
85112 poll_wait(file, &proc_poll_wait, wait);
85113
85114 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
85115 - seq->poll_event = atomic_read(&proc_poll_event);
85116 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
85117 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85118 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
85119 }
85120
85121 @@ -1724,7 +1724,7 @@ static int swaps_open(struct inode *inode, struct file *file)
85122 return ret;
85123
85124 seq = file->private_data;
85125 - seq->poll_event = atomic_read(&proc_poll_event);
85126 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85127 return 0;
85128 }
85129
85130 @@ -2066,7 +2066,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
85131 (frontswap_map) ? "FS" : "");
85132
85133 mutex_unlock(&swapon_mutex);
85134 - atomic_inc(&proc_poll_event);
85135 + atomic_inc_unchecked(&proc_poll_event);
85136 wake_up_interruptible(&proc_poll_wait);
85137
85138 if (S_ISREG(inode->i_mode))
85139 diff --git a/mm/util.c b/mm/util.c
85140 index c55e26b..3f913a9 100644
85141 --- a/mm/util.c
85142 +++ b/mm/util.c
85143 @@ -292,6 +292,12 @@ done:
85144 void arch_pick_mmap_layout(struct mm_struct *mm)
85145 {
85146 mm->mmap_base = TASK_UNMAPPED_BASE;
85147 +
85148 +#ifdef CONFIG_PAX_RANDMMAP
85149 + if (mm->pax_flags & MF_PAX_RANDMMAP)
85150 + mm->mmap_base += mm->delta_mmap;
85151 +#endif
85152 +
85153 mm->get_unmapped_area = arch_get_unmapped_area;
85154 mm->unmap_area = arch_unmap_area;
85155 }
85156 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
85157 index 5123a16..f234a48 100644
85158 --- a/mm/vmalloc.c
85159 +++ b/mm/vmalloc.c
85160 @@ -39,8 +39,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
85161
85162 pte = pte_offset_kernel(pmd, addr);
85163 do {
85164 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85165 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85166 +
85167 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85168 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
85169 + BUG_ON(!pte_exec(*pte));
85170 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
85171 + continue;
85172 + }
85173 +#endif
85174 +
85175 + {
85176 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85177 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85178 + }
85179 } while (pte++, addr += PAGE_SIZE, addr != end);
85180 }
85181
85182 @@ -100,16 +111,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
85183 pte = pte_alloc_kernel(pmd, addr);
85184 if (!pte)
85185 return -ENOMEM;
85186 +
85187 + pax_open_kernel();
85188 do {
85189 struct page *page = pages[*nr];
85190
85191 - if (WARN_ON(!pte_none(*pte)))
85192 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85193 + if (pgprot_val(prot) & _PAGE_NX)
85194 +#endif
85195 +
85196 + if (!pte_none(*pte)) {
85197 + pax_close_kernel();
85198 + WARN_ON(1);
85199 return -EBUSY;
85200 - if (WARN_ON(!page))
85201 + }
85202 + if (!page) {
85203 + pax_close_kernel();
85204 + WARN_ON(1);
85205 return -ENOMEM;
85206 + }
85207 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
85208 (*nr)++;
85209 } while (pte++, addr += PAGE_SIZE, addr != end);
85210 + pax_close_kernel();
85211 return 0;
85212 }
85213
85214 @@ -119,7 +143,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
85215 pmd_t *pmd;
85216 unsigned long next;
85217
85218 - pmd = pmd_alloc(&init_mm, pud, addr);
85219 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
85220 if (!pmd)
85221 return -ENOMEM;
85222 do {
85223 @@ -136,7 +160,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
85224 pud_t *pud;
85225 unsigned long next;
85226
85227 - pud = pud_alloc(&init_mm, pgd, addr);
85228 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85229 if (!pud)
85230 return -ENOMEM;
85231 do {
85232 @@ -191,11 +215,20 @@ int is_vmalloc_or_module_addr(const void *x)
85233 * and fall back on vmalloc() if that fails. Others
85234 * just put it in the vmalloc space.
85235 */
85236 -#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
85237 +#ifdef CONFIG_MODULES
85238 +#ifdef MODULES_VADDR
85239 unsigned long addr = (unsigned long)x;
85240 if (addr >= MODULES_VADDR && addr < MODULES_END)
85241 return 1;
85242 #endif
85243 +
85244 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85245 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
85246 + return 1;
85247 +#endif
85248 +
85249 +#endif
85250 +
85251 return is_vmalloc_addr(x);
85252 }
85253
85254 @@ -216,8 +249,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
85255
85256 if (!pgd_none(*pgd)) {
85257 pud_t *pud = pud_offset(pgd, addr);
85258 +#ifdef CONFIG_X86
85259 + if (!pud_large(*pud))
85260 +#endif
85261 if (!pud_none(*pud)) {
85262 pmd_t *pmd = pmd_offset(pud, addr);
85263 +#ifdef CONFIG_X86
85264 + if (!pmd_large(*pmd))
85265 +#endif
85266 if (!pmd_none(*pmd)) {
85267 pte_t *ptep, pte;
85268
85269 @@ -329,7 +368,7 @@ static void purge_vmap_area_lazy(void);
85270 * Allocate a region of KVA of the specified size and alignment, within the
85271 * vstart and vend.
85272 */
85273 -static struct vmap_area *alloc_vmap_area(unsigned long size,
85274 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
85275 unsigned long align,
85276 unsigned long vstart, unsigned long vend,
85277 int node, gfp_t gfp_mask)
85278 @@ -1328,6 +1367,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
85279 struct vm_struct *area;
85280
85281 BUG_ON(in_interrupt());
85282 +
85283 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85284 + if (flags & VM_KERNEXEC) {
85285 + if (start != VMALLOC_START || end != VMALLOC_END)
85286 + return NULL;
85287 + start = (unsigned long)MODULES_EXEC_VADDR;
85288 + end = (unsigned long)MODULES_EXEC_END;
85289 + }
85290 +#endif
85291 +
85292 if (flags & VM_IOREMAP) {
85293 int bit = fls(size);
85294
85295 @@ -1568,6 +1617,11 @@ void *vmap(struct page **pages, unsigned int count,
85296 if (count > totalram_pages)
85297 return NULL;
85298
85299 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85300 + if (!(pgprot_val(prot) & _PAGE_NX))
85301 + flags |= VM_KERNEXEC;
85302 +#endif
85303 +
85304 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
85305 __builtin_return_address(0));
85306 if (!area)
85307 @@ -1669,6 +1723,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
85308 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
85309 goto fail;
85310
85311 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85312 + if (!(pgprot_val(prot) & _PAGE_NX))
85313 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
85314 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
85315 + else
85316 +#endif
85317 +
85318 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
85319 start, end, node, gfp_mask, caller);
85320 if (!area)
85321 @@ -1842,10 +1903,9 @@ EXPORT_SYMBOL(vzalloc_node);
85322 * For tight control over page level allocator and protection flags
85323 * use __vmalloc() instead.
85324 */
85325 -
85326 void *vmalloc_exec(unsigned long size)
85327 {
85328 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
85329 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
85330 -1, __builtin_return_address(0));
85331 }
85332
85333 @@ -2136,6 +2196,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
85334 unsigned long uaddr = vma->vm_start;
85335 unsigned long usize = vma->vm_end - vma->vm_start;
85336
85337 + BUG_ON(vma->vm_mirror);
85338 +
85339 if ((PAGE_SIZE-1) & (unsigned long)addr)
85340 return -EINVAL;
85341
85342 @@ -2575,7 +2637,11 @@ static int s_show(struct seq_file *m, void *p)
85343 v->addr, v->addr + v->size, v->size);
85344
85345 if (v->caller)
85346 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85347 + seq_printf(m, " %pK", v->caller);
85348 +#else
85349 seq_printf(m, " %pS", v->caller);
85350 +#endif
85351
85352 if (v->nr_pages)
85353 seq_printf(m, " pages=%d", v->nr_pages);
85354 diff --git a/mm/vmstat.c b/mm/vmstat.c
85355 index 9800306..76b4b27 100644
85356 --- a/mm/vmstat.c
85357 +++ b/mm/vmstat.c
85358 @@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu)
85359 *
85360 * vm_stat contains the global counters
85361 */
85362 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85363 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85364 EXPORT_SYMBOL(vm_stat);
85365
85366 #ifdef CONFIG_SMP
85367 @@ -454,7 +454,7 @@ void refresh_cpu_vm_stats(int cpu)
85368 v = p->vm_stat_diff[i];
85369 p->vm_stat_diff[i] = 0;
85370 local_irq_restore(flags);
85371 - atomic_long_add(v, &zone->vm_stat[i]);
85372 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85373 global_diff[i] += v;
85374 #ifdef CONFIG_NUMA
85375 /* 3 seconds idle till flush */
85376 @@ -492,7 +492,7 @@ void refresh_cpu_vm_stats(int cpu)
85377
85378 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
85379 if (global_diff[i])
85380 - atomic_long_add(global_diff[i], &vm_stat[i]);
85381 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
85382 }
85383
85384 void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85385 @@ -503,8 +503,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85386 if (pset->vm_stat_diff[i]) {
85387 int v = pset->vm_stat_diff[i];
85388 pset->vm_stat_diff[i] = 0;
85389 - atomic_long_add(v, &zone->vm_stat[i]);
85390 - atomic_long_add(v, &vm_stat[i]);
85391 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85392 + atomic_long_add_unchecked(v, &vm_stat[i]);
85393 }
85394 }
85395 #endif
85396 @@ -1223,7 +1223,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
85397 return NOTIFY_OK;
85398 }
85399
85400 -static struct notifier_block __cpuinitdata vmstat_notifier =
85401 +static struct notifier_block vmstat_notifier =
85402 { &vmstat_cpuup_callback, NULL, 0 };
85403 #endif
85404
85405 @@ -1238,10 +1238,20 @@ static int __init setup_vmstat(void)
85406 start_cpu_timer(cpu);
85407 #endif
85408 #ifdef CONFIG_PROC_FS
85409 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
85410 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
85411 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
85412 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
85413 + {
85414 + mode_t gr_mode = S_IRUGO;
85415 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85416 + gr_mode = S_IRUSR;
85417 +#endif
85418 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
85419 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
85420 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
85421 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
85422 +#else
85423 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
85424 +#endif
85425 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
85426 + }
85427 #endif
85428 return 0;
85429 }
85430 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
85431 index acc74ad..be02639 100644
85432 --- a/net/8021q/vlan.c
85433 +++ b/net/8021q/vlan.c
85434 @@ -108,6 +108,13 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
85435 if (vlan_id)
85436 vlan_vid_del(real_dev, vlan_id);
85437
85438 + /* Take it out of our own structures, but be sure to interlock with
85439 + * HW accelerating devices or SW vlan input packet processing if
85440 + * VLAN is not 0 (leave it there for 802.1p).
85441 + */
85442 + if (vlan_id)
85443 + vlan_vid_del(real_dev, vlan_id);
85444 +
85445 /* Get rid of the vlan's reference to real_dev */
85446 dev_put(real_dev);
85447 }
85448 @@ -485,7 +492,7 @@ out:
85449 return NOTIFY_DONE;
85450 }
85451
85452 -static struct notifier_block vlan_notifier_block __read_mostly = {
85453 +static struct notifier_block vlan_notifier_block = {
85454 .notifier_call = vlan_device_event,
85455 };
85456
85457 @@ -560,8 +567,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
85458 err = -EPERM;
85459 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
85460 break;
85461 - if ((args.u.name_type >= 0) &&
85462 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
85463 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
85464 struct vlan_net *vn;
85465
85466 vn = net_generic(net, vlan_net_id);
85467 diff --git a/net/9p/mod.c b/net/9p/mod.c
85468 index 6ab36ae..6f1841b 100644
85469 --- a/net/9p/mod.c
85470 +++ b/net/9p/mod.c
85471 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
85472 void v9fs_register_trans(struct p9_trans_module *m)
85473 {
85474 spin_lock(&v9fs_trans_lock);
85475 - list_add_tail(&m->list, &v9fs_trans_list);
85476 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
85477 spin_unlock(&v9fs_trans_lock);
85478 }
85479 EXPORT_SYMBOL(v9fs_register_trans);
85480 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
85481 void v9fs_unregister_trans(struct p9_trans_module *m)
85482 {
85483 spin_lock(&v9fs_trans_lock);
85484 - list_del_init(&m->list);
85485 + pax_list_del_init((struct list_head *)&m->list);
85486 spin_unlock(&v9fs_trans_lock);
85487 }
85488 EXPORT_SYMBOL(v9fs_unregister_trans);
85489 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
85490 index 02efb25..41541a9 100644
85491 --- a/net/9p/trans_fd.c
85492 +++ b/net/9p/trans_fd.c
85493 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
85494 oldfs = get_fs();
85495 set_fs(get_ds());
85496 /* The cast to a user pointer is valid due to the set_fs() */
85497 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
85498 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
85499 set_fs(oldfs);
85500
85501 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
85502 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
85503 index 876fbe8..8bbea9f 100644
85504 --- a/net/atm/atm_misc.c
85505 +++ b/net/atm/atm_misc.c
85506 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
85507 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
85508 return 1;
85509 atm_return(vcc, truesize);
85510 - atomic_inc(&vcc->stats->rx_drop);
85511 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85512 return 0;
85513 }
85514 EXPORT_SYMBOL(atm_charge);
85515 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
85516 }
85517 }
85518 atm_return(vcc, guess);
85519 - atomic_inc(&vcc->stats->rx_drop);
85520 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85521 return NULL;
85522 }
85523 EXPORT_SYMBOL(atm_alloc_charge);
85524 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
85525
85526 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85527 {
85528 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85529 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85530 __SONET_ITEMS
85531 #undef __HANDLE_ITEM
85532 }
85533 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
85534
85535 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85536 {
85537 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85538 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
85539 __SONET_ITEMS
85540 #undef __HANDLE_ITEM
85541 }
85542 diff --git a/net/atm/lec.h b/net/atm/lec.h
85543 index a86aff9..3a0d6f6 100644
85544 --- a/net/atm/lec.h
85545 +++ b/net/atm/lec.h
85546 @@ -48,7 +48,7 @@ struct lane2_ops {
85547 const u8 *tlvs, u32 sizeoftlvs);
85548 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
85549 const u8 *tlvs, u32 sizeoftlvs);
85550 -};
85551 +} __no_const;
85552
85553 /*
85554 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
85555 diff --git a/net/atm/proc.c b/net/atm/proc.c
85556 index 0d020de..011c7bb 100644
85557 --- a/net/atm/proc.c
85558 +++ b/net/atm/proc.c
85559 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
85560 const struct k_atm_aal_stats *stats)
85561 {
85562 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
85563 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
85564 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
85565 - atomic_read(&stats->rx_drop));
85566 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
85567 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
85568 + atomic_read_unchecked(&stats->rx_drop));
85569 }
85570
85571 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
85572 diff --git a/net/atm/resources.c b/net/atm/resources.c
85573 index 0447d5d..3cf4728 100644
85574 --- a/net/atm/resources.c
85575 +++ b/net/atm/resources.c
85576 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
85577 static void copy_aal_stats(struct k_atm_aal_stats *from,
85578 struct atm_aal_stats *to)
85579 {
85580 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85581 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85582 __AAL_STAT_ITEMS
85583 #undef __HANDLE_ITEM
85584 }
85585 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
85586 static void subtract_aal_stats(struct k_atm_aal_stats *from,
85587 struct atm_aal_stats *to)
85588 {
85589 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85590 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
85591 __AAL_STAT_ITEMS
85592 #undef __HANDLE_ITEM
85593 }
85594 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
85595 index d5744b7..506bae3 100644
85596 --- a/net/ax25/sysctl_net_ax25.c
85597 +++ b/net/ax25/sysctl_net_ax25.c
85598 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
85599 {
85600 char path[sizeof("net/ax25/") + IFNAMSIZ];
85601 int k;
85602 - struct ctl_table *table;
85603 + ctl_table_no_const *table;
85604
85605 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
85606 if (!table)
85607 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
85608 index 1ee94d0..14beea2 100644
85609 --- a/net/batman-adv/bat_iv_ogm.c
85610 +++ b/net/batman-adv/bat_iv_ogm.c
85611 @@ -63,7 +63,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
85612
85613 /* randomize initial seqno to avoid collision */
85614 get_random_bytes(&random_seqno, sizeof(random_seqno));
85615 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85616 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85617
85618 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
85619 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
85620 @@ -615,9 +615,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
85621 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
85622
85623 /* change sequence number to network order */
85624 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
85625 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
85626 batadv_ogm_packet->seqno = htonl(seqno);
85627 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
85628 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
85629
85630 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
85631 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
85632 @@ -1022,7 +1022,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
85633 return;
85634
85635 /* could be changed by schedule_own_packet() */
85636 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
85637 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
85638
85639 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
85640 has_directlink_flag = 1;
85641 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
85642 index f1d37cd..4190879 100644
85643 --- a/net/batman-adv/hard-interface.c
85644 +++ b/net/batman-adv/hard-interface.c
85645 @@ -370,7 +370,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
85646 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
85647 dev_add_pack(&hard_iface->batman_adv_ptype);
85648
85649 - atomic_set(&hard_iface->frag_seqno, 1);
85650 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
85651 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
85652 hard_iface->net_dev->name);
85653
85654 @@ -493,7 +493,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
85655 /* This can't be called via a bat_priv callback because
85656 * we have no bat_priv yet.
85657 */
85658 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
85659 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
85660 hard_iface->bat_iv.ogm_buff = NULL;
85661
85662 return hard_iface;
85663 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
85664 index 6b548fd..fc32c8d 100644
85665 --- a/net/batman-adv/soft-interface.c
85666 +++ b/net/batman-adv/soft-interface.c
85667 @@ -252,7 +252,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
85668 primary_if->net_dev->dev_addr, ETH_ALEN);
85669
85670 /* set broadcast sequence number */
85671 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
85672 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
85673 bcast_packet->seqno = htonl(seqno);
85674
85675 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
85676 @@ -497,7 +497,7 @@ struct net_device *batadv_softif_create(const char *name)
85677 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
85678
85679 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
85680 - atomic_set(&bat_priv->bcast_seqno, 1);
85681 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
85682 atomic_set(&bat_priv->tt.vn, 0);
85683 atomic_set(&bat_priv->tt.local_changes, 0);
85684 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
85685 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
85686 index ae9ac9a..11e0fe7 100644
85687 --- a/net/batman-adv/types.h
85688 +++ b/net/batman-adv/types.h
85689 @@ -48,7 +48,7 @@
85690 struct batadv_hard_iface_bat_iv {
85691 unsigned char *ogm_buff;
85692 int ogm_buff_len;
85693 - atomic_t ogm_seqno;
85694 + atomic_unchecked_t ogm_seqno;
85695 };
85696
85697 struct batadv_hard_iface {
85698 @@ -56,7 +56,7 @@ struct batadv_hard_iface {
85699 int16_t if_num;
85700 char if_status;
85701 struct net_device *net_dev;
85702 - atomic_t frag_seqno;
85703 + atomic_unchecked_t frag_seqno;
85704 struct kobject *hardif_obj;
85705 atomic_t refcount;
85706 struct packet_type batman_adv_ptype;
85707 @@ -284,7 +284,7 @@ struct batadv_priv {
85708 atomic_t orig_interval; /* uint */
85709 atomic_t hop_penalty; /* uint */
85710 atomic_t log_level; /* uint */
85711 - atomic_t bcast_seqno;
85712 + atomic_unchecked_t bcast_seqno;
85713 atomic_t bcast_queue_left;
85714 atomic_t batman_queue_left;
85715 char num_ifaces;
85716 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
85717 index 10aff49..ea8e021 100644
85718 --- a/net/batman-adv/unicast.c
85719 +++ b/net/batman-adv/unicast.c
85720 @@ -272,7 +272,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
85721 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
85722 frag2->flags = large_tail;
85723
85724 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
85725 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
85726 frag1->seqno = htons(seqno - 1);
85727 frag2->seqno = htons(seqno);
85728
85729 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
85730 index 07f0739..3c42e34 100644
85731 --- a/net/bluetooth/hci_sock.c
85732 +++ b/net/bluetooth/hci_sock.c
85733 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
85734 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
85735 }
85736
85737 - len = min_t(unsigned int, len, sizeof(uf));
85738 + len = min((size_t)len, sizeof(uf));
85739 if (copy_from_user(&uf, optval, len)) {
85740 err = -EFAULT;
85741 break;
85742 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
85743 index 22e6583..426e2f3 100644
85744 --- a/net/bluetooth/l2cap_core.c
85745 +++ b/net/bluetooth/l2cap_core.c
85746 @@ -3400,8 +3400,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
85747 break;
85748
85749 case L2CAP_CONF_RFC:
85750 - if (olen == sizeof(rfc))
85751 - memcpy(&rfc, (void *)val, olen);
85752 + if (olen != sizeof(rfc))
85753 + break;
85754 +
85755 + memcpy(&rfc, (void *)val, olen);
85756
85757 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
85758 rfc.mode != chan->mode)
85759 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
85760 index 1bcfb84..dad9f98 100644
85761 --- a/net/bluetooth/l2cap_sock.c
85762 +++ b/net/bluetooth/l2cap_sock.c
85763 @@ -479,7 +479,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85764 struct sock *sk = sock->sk;
85765 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
85766 struct l2cap_options opts;
85767 - int len, err = 0;
85768 + int err = 0;
85769 + size_t len = optlen;
85770 u32 opt;
85771
85772 BT_DBG("sk %p", sk);
85773 @@ -501,7 +502,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85774 opts.max_tx = chan->max_tx;
85775 opts.txwin_size = chan->tx_win;
85776
85777 - len = min_t(unsigned int, sizeof(opts), optlen);
85778 + len = min(sizeof(opts), len);
85779 if (copy_from_user((char *) &opts, optval, len)) {
85780 err = -EFAULT;
85781 break;
85782 @@ -581,7 +582,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85783 struct bt_security sec;
85784 struct bt_power pwr;
85785 struct l2cap_conn *conn;
85786 - int len, err = 0;
85787 + int err = 0;
85788 + size_t len = optlen;
85789 u32 opt;
85790
85791 BT_DBG("sk %p", sk);
85792 @@ -604,7 +606,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85793
85794 sec.level = BT_SECURITY_LOW;
85795
85796 - len = min_t(unsigned int, sizeof(sec), optlen);
85797 + len = min(sizeof(sec), len);
85798 if (copy_from_user((char *) &sec, optval, len)) {
85799 err = -EFAULT;
85800 break;
85801 @@ -701,7 +703,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85802
85803 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
85804
85805 - len = min_t(unsigned int, sizeof(pwr), optlen);
85806 + len = min(sizeof(pwr), len);
85807 if (copy_from_user((char *) &pwr, optval, len)) {
85808 err = -EFAULT;
85809 break;
85810 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
85811 index ce3f665..2c7d08f 100644
85812 --- a/net/bluetooth/rfcomm/sock.c
85813 +++ b/net/bluetooth/rfcomm/sock.c
85814 @@ -667,7 +667,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85815 struct sock *sk = sock->sk;
85816 struct bt_security sec;
85817 int err = 0;
85818 - size_t len;
85819 + size_t len = optlen;
85820 u32 opt;
85821
85822 BT_DBG("sk %p", sk);
85823 @@ -689,7 +689,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85824
85825 sec.level = BT_SECURITY_LOW;
85826
85827 - len = min_t(unsigned int, sizeof(sec), optlen);
85828 + len = min(sizeof(sec), len);
85829 if (copy_from_user((char *) &sec, optval, len)) {
85830 err = -EFAULT;
85831 break;
85832 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
85833 index bd6fd0f..6492cba 100644
85834 --- a/net/bluetooth/rfcomm/tty.c
85835 +++ b/net/bluetooth/rfcomm/tty.c
85836 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
85837 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
85838
85839 spin_lock_irqsave(&dev->port.lock, flags);
85840 - if (dev->port.count > 0) {
85841 + if (atomic_read(&dev->port.count) > 0) {
85842 spin_unlock_irqrestore(&dev->port.lock, flags);
85843 return;
85844 }
85845 @@ -664,10 +664,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
85846 return -ENODEV;
85847
85848 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
85849 - dev->channel, dev->port.count);
85850 + dev->channel, atomic_read(&dev->port.count));
85851
85852 spin_lock_irqsave(&dev->port.lock, flags);
85853 - if (++dev->port.count > 1) {
85854 + if (atomic_inc_return(&dev->port.count) > 1) {
85855 spin_unlock_irqrestore(&dev->port.lock, flags);
85856 return 0;
85857 }
85858 @@ -732,10 +732,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
85859 return;
85860
85861 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
85862 - dev->port.count);
85863 + atomic_read(&dev->port.count));
85864
85865 spin_lock_irqsave(&dev->port.lock, flags);
85866 - if (!--dev->port.count) {
85867 + if (!atomic_dec_return(&dev->port.count)) {
85868 spin_unlock_irqrestore(&dev->port.lock, flags);
85869 if (dev->tty_dev->parent)
85870 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
85871 diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
85872 index d9576e6..85f4f4e 100644
85873 --- a/net/bridge/br_fdb.c
85874 +++ b/net/bridge/br_fdb.c
85875 @@ -386,7 +386,7 @@ static int fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
85876 return 0;
85877 br_warn(br, "adding interface %s with same address "
85878 "as a received packet\n",
85879 - source->dev->name);
85880 + source ? source->dev->name : br->dev->name);
85881 fdb_delete(br, fdb);
85882 }
85883
85884 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
85885 index 5fe2ff3..121d696 100644
85886 --- a/net/bridge/netfilter/ebtables.c
85887 +++ b/net/bridge/netfilter/ebtables.c
85888 @@ -1523,7 +1523,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
85889 tmp.valid_hooks = t->table->valid_hooks;
85890 }
85891 mutex_unlock(&ebt_mutex);
85892 - if (copy_to_user(user, &tmp, *len) != 0){
85893 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
85894 BUGPRINT("c2u Didn't work\n");
85895 ret = -EFAULT;
85896 break;
85897 @@ -2327,7 +2327,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85898 goto out;
85899 tmp.valid_hooks = t->valid_hooks;
85900
85901 - if (copy_to_user(user, &tmp, *len) != 0) {
85902 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
85903 ret = -EFAULT;
85904 break;
85905 }
85906 @@ -2338,7 +2338,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85907 tmp.entries_size = t->table->entries_size;
85908 tmp.valid_hooks = t->table->valid_hooks;
85909
85910 - if (copy_to_user(user, &tmp, *len) != 0) {
85911 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
85912 ret = -EFAULT;
85913 break;
85914 }
85915 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
85916 index a376ec1..1fbd6be 100644
85917 --- a/net/caif/cfctrl.c
85918 +++ b/net/caif/cfctrl.c
85919 @@ -10,6 +10,7 @@
85920 #include <linux/spinlock.h>
85921 #include <linux/slab.h>
85922 #include <linux/pkt_sched.h>
85923 +#include <linux/sched.h>
85924 #include <net/caif/caif_layer.h>
85925 #include <net/caif/cfpkt.h>
85926 #include <net/caif/cfctrl.h>
85927 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
85928 memset(&dev_info, 0, sizeof(dev_info));
85929 dev_info.id = 0xff;
85930 cfsrvl_init(&this->serv, 0, &dev_info, false);
85931 - atomic_set(&this->req_seq_no, 1);
85932 - atomic_set(&this->rsp_seq_no, 1);
85933 + atomic_set_unchecked(&this->req_seq_no, 1);
85934 + atomic_set_unchecked(&this->rsp_seq_no, 1);
85935 this->serv.layer.receive = cfctrl_recv;
85936 sprintf(this->serv.layer.name, "ctrl");
85937 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
85938 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
85939 struct cfctrl_request_info *req)
85940 {
85941 spin_lock_bh(&ctrl->info_list_lock);
85942 - atomic_inc(&ctrl->req_seq_no);
85943 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
85944 + atomic_inc_unchecked(&ctrl->req_seq_no);
85945 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
85946 list_add_tail(&req->list, &ctrl->list);
85947 spin_unlock_bh(&ctrl->info_list_lock);
85948 }
85949 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
85950 if (p != first)
85951 pr_warn("Requests are not received in order\n");
85952
85953 - atomic_set(&ctrl->rsp_seq_no,
85954 + atomic_set_unchecked(&ctrl->rsp_seq_no,
85955 p->sequence_no);
85956 list_del(&p->list);
85957 goto out;
85958 diff --git a/net/can/af_can.c b/net/can/af_can.c
85959 index ddac1ee..3ee0a78 100644
85960 --- a/net/can/af_can.c
85961 +++ b/net/can/af_can.c
85962 @@ -872,7 +872,7 @@ static const struct net_proto_family can_family_ops = {
85963 };
85964
85965 /* notifier block for netdevice event */
85966 -static struct notifier_block can_netdev_notifier __read_mostly = {
85967 +static struct notifier_block can_netdev_notifier = {
85968 .notifier_call = can_notifier,
85969 };
85970
85971 diff --git a/net/can/gw.c b/net/can/gw.c
85972 index 574dda78e..d42c4cd 100644
85973 --- a/net/can/gw.c
85974 +++ b/net/can/gw.c
85975 @@ -67,7 +67,6 @@ MODULE_AUTHOR("Oliver Hartkopp <oliver.hartkopp@volkswagen.de>");
85976 MODULE_ALIAS("can-gw");
85977
85978 static HLIST_HEAD(cgw_list);
85979 -static struct notifier_block notifier;
85980
85981 static struct kmem_cache *cgw_cache __read_mostly;
85982
85983 @@ -436,7 +435,7 @@ static int cgw_notifier(struct notifier_block *nb,
85984 if (gwj->src.dev == dev || gwj->dst.dev == dev) {
85985 hlist_del(&gwj->list);
85986 cgw_unregister_filter(gwj);
85987 - kfree(gwj);
85988 + kmem_cache_free(cgw_cache, gwj);
85989 }
85990 }
85991 }
85992 @@ -829,7 +828,7 @@ static void cgw_remove_all_jobs(void)
85993 hlist_for_each_entry_safe(gwj, n, nx, &cgw_list, list) {
85994 hlist_del(&gwj->list);
85995 cgw_unregister_filter(gwj);
85996 - kfree(gwj);
85997 + kmem_cache_free(cgw_cache, gwj);
85998 }
85999 }
86000
86001 @@ -885,7 +884,7 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
86002
86003 hlist_del(&gwj->list);
86004 cgw_unregister_filter(gwj);
86005 - kfree(gwj);
86006 + kmem_cache_free(cgw_cache, gwj);
86007 err = 0;
86008 break;
86009 }
86010 @@ -893,6 +892,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
86011 return err;
86012 }
86013
86014 +static struct notifier_block notifier = {
86015 + .notifier_call = cgw_notifier
86016 +};
86017 +
86018 static __init int cgw_module_init(void)
86019 {
86020 printk(banner);
86021 @@ -904,7 +907,6 @@ static __init int cgw_module_init(void)
86022 return -ENOMEM;
86023
86024 /* set notifier */
86025 - notifier.notifier_call = cgw_notifier;
86026 register_netdevice_notifier(&notifier);
86027
86028 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
86029 diff --git a/net/compat.c b/net/compat.c
86030 index 79ae884..17c5c09 100644
86031 --- a/net/compat.c
86032 +++ b/net/compat.c
86033 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
86034 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
86035 __get_user(kmsg->msg_flags, &umsg->msg_flags))
86036 return -EFAULT;
86037 - kmsg->msg_name = compat_ptr(tmp1);
86038 - kmsg->msg_iov = compat_ptr(tmp2);
86039 - kmsg->msg_control = compat_ptr(tmp3);
86040 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
86041 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
86042 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
86043 return 0;
86044 }
86045
86046 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86047
86048 if (kern_msg->msg_namelen) {
86049 if (mode == VERIFY_READ) {
86050 - int err = move_addr_to_kernel(kern_msg->msg_name,
86051 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
86052 kern_msg->msg_namelen,
86053 kern_address);
86054 if (err < 0)
86055 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86056 kern_msg->msg_name = NULL;
86057
86058 tot_len = iov_from_user_compat_to_kern(kern_iov,
86059 - (struct compat_iovec __user *)kern_msg->msg_iov,
86060 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
86061 kern_msg->msg_iovlen);
86062 if (tot_len >= 0)
86063 kern_msg->msg_iov = kern_iov;
86064 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86065
86066 #define CMSG_COMPAT_FIRSTHDR(msg) \
86067 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
86068 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
86069 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
86070 (struct compat_cmsghdr __user *)NULL)
86071
86072 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
86073 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
86074 (ucmlen) <= (unsigned long) \
86075 ((mhdr)->msg_controllen - \
86076 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
86077 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
86078
86079 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
86080 struct compat_cmsghdr __user *cmsg, int cmsg_len)
86081 {
86082 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
86083 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
86084 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
86085 msg->msg_controllen)
86086 return NULL;
86087 return (struct compat_cmsghdr __user *)ptr;
86088 @@ -219,7 +219,7 @@ Efault:
86089
86090 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
86091 {
86092 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
86093 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
86094 struct compat_cmsghdr cmhdr;
86095 struct compat_timeval ctv;
86096 struct compat_timespec cts[3];
86097 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
86098
86099 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
86100 {
86101 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
86102 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
86103 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
86104 int fdnum = scm->fp->count;
86105 struct file **fp = scm->fp->fp;
86106 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
86107 return -EFAULT;
86108 old_fs = get_fs();
86109 set_fs(KERNEL_DS);
86110 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
86111 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
86112 set_fs(old_fs);
86113
86114 return err;
86115 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
86116 len = sizeof(ktime);
86117 old_fs = get_fs();
86118 set_fs(KERNEL_DS);
86119 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
86120 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
86121 set_fs(old_fs);
86122
86123 if (!err) {
86124 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86125 case MCAST_JOIN_GROUP:
86126 case MCAST_LEAVE_GROUP:
86127 {
86128 - struct compat_group_req __user *gr32 = (void *)optval;
86129 + struct compat_group_req __user *gr32 = (void __user *)optval;
86130 struct group_req __user *kgr =
86131 compat_alloc_user_space(sizeof(struct group_req));
86132 u32 interface;
86133 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86134 case MCAST_BLOCK_SOURCE:
86135 case MCAST_UNBLOCK_SOURCE:
86136 {
86137 - struct compat_group_source_req __user *gsr32 = (void *)optval;
86138 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
86139 struct group_source_req __user *kgsr = compat_alloc_user_space(
86140 sizeof(struct group_source_req));
86141 u32 interface;
86142 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86143 }
86144 case MCAST_MSFILTER:
86145 {
86146 - struct compat_group_filter __user *gf32 = (void *)optval;
86147 + struct compat_group_filter __user *gf32 = (void __user *)optval;
86148 struct group_filter __user *kgf;
86149 u32 interface, fmode, numsrc;
86150
86151 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
86152 char __user *optval, int __user *optlen,
86153 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
86154 {
86155 - struct compat_group_filter __user *gf32 = (void *)optval;
86156 + struct compat_group_filter __user *gf32 = (void __user *)optval;
86157 struct group_filter __user *kgf;
86158 int __user *koptlen;
86159 u32 interface, fmode, numsrc;
86160 @@ -796,7 +796,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
86161
86162 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
86163 return -EINVAL;
86164 - if (copy_from_user(a, args, nas[call]))
86165 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
86166 return -EFAULT;
86167 a0 = a[0];
86168 a1 = a[1];
86169 diff --git a/net/core/datagram.c b/net/core/datagram.c
86170 index 368f9c3..f82d4a3 100644
86171 --- a/net/core/datagram.c
86172 +++ b/net/core/datagram.c
86173 @@ -289,7 +289,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
86174 }
86175
86176 kfree_skb(skb);
86177 - atomic_inc(&sk->sk_drops);
86178 + atomic_inc_unchecked(&sk->sk_drops);
86179 sk_mem_reclaim_partial(sk);
86180
86181 return err;
86182 diff --git a/net/core/dev.c b/net/core/dev.c
86183 index 5d9c43d..b471558 100644
86184 --- a/net/core/dev.c
86185 +++ b/net/core/dev.c
86186 @@ -1250,9 +1250,13 @@ void dev_load(struct net *net, const char *name)
86187 if (no_module && capable(CAP_NET_ADMIN))
86188 no_module = request_module("netdev-%s", name);
86189 if (no_module && capable(CAP_SYS_MODULE)) {
86190 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
86191 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
86192 +#else
86193 if (!request_module("%s", name))
86194 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
86195 name);
86196 +#endif
86197 }
86198 }
86199 EXPORT_SYMBOL(dev_load);
86200 @@ -1714,7 +1718,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86201 {
86202 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
86203 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
86204 - atomic_long_inc(&dev->rx_dropped);
86205 + atomic_long_inc_unchecked(&dev->rx_dropped);
86206 kfree_skb(skb);
86207 return NET_RX_DROP;
86208 }
86209 @@ -1724,7 +1728,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86210 nf_reset(skb);
86211
86212 if (unlikely(!is_skb_forwardable(dev, skb))) {
86213 - atomic_long_inc(&dev->rx_dropped);
86214 + atomic_long_inc_unchecked(&dev->rx_dropped);
86215 kfree_skb(skb);
86216 return NET_RX_DROP;
86217 }
86218 @@ -2179,7 +2183,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
86219
86220 struct dev_gso_cb {
86221 void (*destructor)(struct sk_buff *skb);
86222 -};
86223 +} __no_const;
86224
86225 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
86226
86227 @@ -3052,7 +3056,7 @@ enqueue:
86228
86229 local_irq_restore(flags);
86230
86231 - atomic_long_inc(&skb->dev->rx_dropped);
86232 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86233 kfree_skb(skb);
86234 return NET_RX_DROP;
86235 }
86236 @@ -3124,7 +3128,7 @@ int netif_rx_ni(struct sk_buff *skb)
86237 }
86238 EXPORT_SYMBOL(netif_rx_ni);
86239
86240 -static void net_tx_action(struct softirq_action *h)
86241 +static void net_tx_action(void)
86242 {
86243 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86244
86245 @@ -3462,7 +3466,7 @@ ncls:
86246 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
86247 } else {
86248 drop:
86249 - atomic_long_inc(&skb->dev->rx_dropped);
86250 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86251 kfree_skb(skb);
86252 /* Jamal, now you will not able to escape explaining
86253 * me how you were going to use this. :-)
86254 @@ -4045,7 +4049,7 @@ void netif_napi_del(struct napi_struct *napi)
86255 }
86256 EXPORT_SYMBOL(netif_napi_del);
86257
86258 -static void net_rx_action(struct softirq_action *h)
86259 +static void net_rx_action(void)
86260 {
86261 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86262 unsigned long time_limit = jiffies + 2;
86263 @@ -4529,8 +4533,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
86264 else
86265 seq_printf(seq, "%04x", ntohs(pt->type));
86266
86267 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86268 + seq_printf(seq, " %-8s %p\n",
86269 + pt->dev ? pt->dev->name : "", NULL);
86270 +#else
86271 seq_printf(seq, " %-8s %pF\n",
86272 pt->dev ? pt->dev->name : "", pt->func);
86273 +#endif
86274 }
86275
86276 return 0;
86277 @@ -6102,7 +6111,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
86278 } else {
86279 netdev_stats_to_stats64(storage, &dev->stats);
86280 }
86281 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
86282 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
86283 return storage;
86284 }
86285 EXPORT_SYMBOL(dev_get_stats);
86286 diff --git a/net/core/flow.c b/net/core/flow.c
86287 index 3bad824..2071a55 100644
86288 --- a/net/core/flow.c
86289 +++ b/net/core/flow.c
86290 @@ -61,7 +61,7 @@ struct flow_cache {
86291 struct timer_list rnd_timer;
86292 };
86293
86294 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
86295 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
86296 EXPORT_SYMBOL(flow_cache_genid);
86297 static struct flow_cache flow_cache_global;
86298 static struct kmem_cache *flow_cachep __read_mostly;
86299 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
86300
86301 static int flow_entry_valid(struct flow_cache_entry *fle)
86302 {
86303 - if (atomic_read(&flow_cache_genid) != fle->genid)
86304 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
86305 return 0;
86306 if (fle->object && !fle->object->ops->check(fle->object))
86307 return 0;
86308 @@ -259,7 +259,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
86309 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
86310 fcp->hash_count++;
86311 }
86312 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
86313 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
86314 flo = fle->object;
86315 if (!flo)
86316 goto ret_object;
86317 @@ -280,7 +280,7 @@ nocache:
86318 }
86319 flo = resolver(net, key, family, dir, flo, ctx);
86320 if (fle) {
86321 - fle->genid = atomic_read(&flow_cache_genid);
86322 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
86323 if (!IS_ERR(flo))
86324 fle->object = flo;
86325 else
86326 diff --git a/net/core/iovec.c b/net/core/iovec.c
86327 index 7e7aeb0..2a998cb 100644
86328 --- a/net/core/iovec.c
86329 +++ b/net/core/iovec.c
86330 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86331 if (m->msg_namelen) {
86332 if (mode == VERIFY_READ) {
86333 void __user *namep;
86334 - namep = (void __user __force *) m->msg_name;
86335 + namep = (void __force_user *) m->msg_name;
86336 err = move_addr_to_kernel(namep, m->msg_namelen,
86337 address);
86338 if (err < 0)
86339 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86340 }
86341
86342 size = m->msg_iovlen * sizeof(struct iovec);
86343 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
86344 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
86345 return -EFAULT;
86346
86347 m->msg_iov = iov;
86348 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
86349 index c815f28..e6403f2 100644
86350 --- a/net/core/neighbour.c
86351 +++ b/net/core/neighbour.c
86352 @@ -2776,7 +2776,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
86353 size_t *lenp, loff_t *ppos)
86354 {
86355 int size, ret;
86356 - ctl_table tmp = *ctl;
86357 + ctl_table_no_const tmp = *ctl;
86358
86359 tmp.extra1 = &zero;
86360 tmp.extra2 = &unres_qlen_max;
86361 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
86362 index 28c5f5a..7edf2e2 100644
86363 --- a/net/core/net-sysfs.c
86364 +++ b/net/core/net-sysfs.c
86365 @@ -1455,7 +1455,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
86366 }
86367 EXPORT_SYMBOL(netdev_class_remove_file);
86368
86369 -int netdev_kobject_init(void)
86370 +int __init netdev_kobject_init(void)
86371 {
86372 kobj_ns_type_register(&net_ns_type_operations);
86373 return class_register(&net_class);
86374 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
86375 index 8acce01..2e306bb 100644
86376 --- a/net/core/net_namespace.c
86377 +++ b/net/core/net_namespace.c
86378 @@ -442,7 +442,7 @@ static int __register_pernet_operations(struct list_head *list,
86379 int error;
86380 LIST_HEAD(net_exit_list);
86381
86382 - list_add_tail(&ops->list, list);
86383 + pax_list_add_tail((struct list_head *)&ops->list, list);
86384 if (ops->init || (ops->id && ops->size)) {
86385 for_each_net(net) {
86386 error = ops_init(ops, net);
86387 @@ -455,7 +455,7 @@ static int __register_pernet_operations(struct list_head *list,
86388
86389 out_undo:
86390 /* If I have an error cleanup all namespaces I initialized */
86391 - list_del(&ops->list);
86392 + pax_list_del((struct list_head *)&ops->list);
86393 ops_exit_list(ops, &net_exit_list);
86394 ops_free_list(ops, &net_exit_list);
86395 return error;
86396 @@ -466,7 +466,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
86397 struct net *net;
86398 LIST_HEAD(net_exit_list);
86399
86400 - list_del(&ops->list);
86401 + pax_list_del((struct list_head *)&ops->list);
86402 for_each_net(net)
86403 list_add_tail(&net->exit_list, &net_exit_list);
86404 ops_exit_list(ops, &net_exit_list);
86405 @@ -600,7 +600,7 @@ int register_pernet_device(struct pernet_operations *ops)
86406 mutex_lock(&net_mutex);
86407 error = register_pernet_operations(&pernet_list, ops);
86408 if (!error && (first_device == &pernet_list))
86409 - first_device = &ops->list;
86410 + first_device = (struct list_head *)&ops->list;
86411 mutex_unlock(&net_mutex);
86412 return error;
86413 }
86414 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
86415 index 6212ec9..5ee16b2 100644
86416 --- a/net/core/rtnetlink.c
86417 +++ b/net/core/rtnetlink.c
86418 @@ -58,7 +58,7 @@ struct rtnl_link {
86419 rtnl_doit_func doit;
86420 rtnl_dumpit_func dumpit;
86421 rtnl_calcit_func calcit;
86422 -};
86423 +} __no_const;
86424
86425 static DEFINE_MUTEX(rtnl_mutex);
86426
86427 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
86428 if (rtnl_link_ops_get(ops->kind))
86429 return -EEXIST;
86430
86431 - if (!ops->dellink)
86432 - ops->dellink = unregister_netdevice_queue;
86433 + if (!ops->dellink) {
86434 + pax_open_kernel();
86435 + *(void **)&ops->dellink = unregister_netdevice_queue;
86436 + pax_close_kernel();
86437 + }
86438
86439 - list_add_tail(&ops->list, &link_ops);
86440 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
86441 return 0;
86442 }
86443 EXPORT_SYMBOL_GPL(__rtnl_link_register);
86444 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
86445 for_each_net(net) {
86446 __rtnl_kill_links(net, ops);
86447 }
86448 - list_del(&ops->list);
86449 + pax_list_del((struct list_head *)&ops->list);
86450 }
86451 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
86452
86453 @@ -1068,7 +1071,7 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
86454 rcu_read_lock();
86455 cb->seq = net->dev_base_seq;
86456
86457 - if (nlmsg_parse(cb->nlh, sizeof(struct rtgenmsg), tb, IFLA_MAX,
86458 + if (nlmsg_parse(cb->nlh, sizeof(struct ifinfomsg), tb, IFLA_MAX,
86459 ifla_policy) >= 0) {
86460
86461 if (tb[IFLA_EXT_MASK])
86462 @@ -1924,7 +1927,7 @@ static u16 rtnl_calcit(struct sk_buff *skb, struct nlmsghdr *nlh)
86463 u32 ext_filter_mask = 0;
86464 u16 min_ifinfo_dump_size = 0;
86465
86466 - if (nlmsg_parse(nlh, sizeof(struct rtgenmsg), tb, IFLA_MAX,
86467 + if (nlmsg_parse(nlh, sizeof(struct ifinfomsg), tb, IFLA_MAX,
86468 ifla_policy) >= 0) {
86469 if (tb[IFLA_EXT_MASK])
86470 ext_filter_mask = nla_get_u32(tb[IFLA_EXT_MASK]);
86471 diff --git a/net/core/scm.c b/net/core/scm.c
86472 index 2dc6cda..2159524 100644
86473 --- a/net/core/scm.c
86474 +++ b/net/core/scm.c
86475 @@ -226,7 +226,7 @@ EXPORT_SYMBOL(__scm_send);
86476 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86477 {
86478 struct cmsghdr __user *cm
86479 - = (__force struct cmsghdr __user *)msg->msg_control;
86480 + = (struct cmsghdr __force_user *)msg->msg_control;
86481 struct cmsghdr cmhdr;
86482 int cmlen = CMSG_LEN(len);
86483 int err;
86484 @@ -249,7 +249,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86485 err = -EFAULT;
86486 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
86487 goto out;
86488 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
86489 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
86490 goto out;
86491 cmlen = CMSG_SPACE(len);
86492 if (msg->msg_controllen < cmlen)
86493 @@ -265,7 +265,7 @@ EXPORT_SYMBOL(put_cmsg);
86494 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86495 {
86496 struct cmsghdr __user *cm
86497 - = (__force struct cmsghdr __user*)msg->msg_control;
86498 + = (struct cmsghdr __force_user *)msg->msg_control;
86499
86500 int fdmax = 0;
86501 int fdnum = scm->fp->count;
86502 @@ -285,7 +285,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86503 if (fdnum < fdmax)
86504 fdmax = fdnum;
86505
86506 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
86507 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
86508 i++, cmfptr++)
86509 {
86510 struct socket *sock;
86511 diff --git a/net/core/sock.c b/net/core/sock.c
86512 index bc131d4..029e378 100644
86513 --- a/net/core/sock.c
86514 +++ b/net/core/sock.c
86515 @@ -388,7 +388,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86516 struct sk_buff_head *list = &sk->sk_receive_queue;
86517
86518 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
86519 - atomic_inc(&sk->sk_drops);
86520 + atomic_inc_unchecked(&sk->sk_drops);
86521 trace_sock_rcvqueue_full(sk, skb);
86522 return -ENOMEM;
86523 }
86524 @@ -398,7 +398,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86525 return err;
86526
86527 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
86528 - atomic_inc(&sk->sk_drops);
86529 + atomic_inc_unchecked(&sk->sk_drops);
86530 return -ENOBUFS;
86531 }
86532
86533 @@ -418,7 +418,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86534 skb_dst_force(skb);
86535
86536 spin_lock_irqsave(&list->lock, flags);
86537 - skb->dropcount = atomic_read(&sk->sk_drops);
86538 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
86539 __skb_queue_tail(list, skb);
86540 spin_unlock_irqrestore(&list->lock, flags);
86541
86542 @@ -438,7 +438,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86543 skb->dev = NULL;
86544
86545 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
86546 - atomic_inc(&sk->sk_drops);
86547 + atomic_inc_unchecked(&sk->sk_drops);
86548 goto discard_and_relse;
86549 }
86550 if (nested)
86551 @@ -456,7 +456,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86552 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
86553 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
86554 bh_unlock_sock(sk);
86555 - atomic_inc(&sk->sk_drops);
86556 + atomic_inc_unchecked(&sk->sk_drops);
86557 goto discard_and_relse;
86558 }
86559
86560 @@ -930,12 +930,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86561 struct timeval tm;
86562 } v;
86563
86564 - int lv = sizeof(int);
86565 - int len;
86566 + unsigned int lv = sizeof(int);
86567 + unsigned int len;
86568
86569 if (get_user(len, optlen))
86570 return -EFAULT;
86571 - if (len < 0)
86572 + if (len > INT_MAX)
86573 return -EINVAL;
86574
86575 memset(&v, 0, sizeof(v));
86576 @@ -1083,11 +1083,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86577
86578 case SO_PEERNAME:
86579 {
86580 - char address[128];
86581 + char address[_K_SS_MAXSIZE];
86582
86583 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
86584 return -ENOTCONN;
86585 - if (lv < len)
86586 + if (lv < len || sizeof address < len)
86587 return -EINVAL;
86588 if (copy_to_user(optval, address, len))
86589 return -EFAULT;
86590 @@ -1146,7 +1146,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86591
86592 if (len > lv)
86593 len = lv;
86594 - if (copy_to_user(optval, &v, len))
86595 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
86596 return -EFAULT;
86597 lenout:
86598 if (put_user(len, optlen))
86599 @@ -2276,7 +2276,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
86600 */
86601 smp_wmb();
86602 atomic_set(&sk->sk_refcnt, 1);
86603 - atomic_set(&sk->sk_drops, 0);
86604 + atomic_set_unchecked(&sk->sk_drops, 0);
86605 }
86606 EXPORT_SYMBOL(sock_init_data);
86607
86608 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
86609 index 750f44f..922399c 100644
86610 --- a/net/core/sock_diag.c
86611 +++ b/net/core/sock_diag.c
86612 @@ -9,26 +9,33 @@
86613 #include <linux/inet_diag.h>
86614 #include <linux/sock_diag.h>
86615
86616 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
86617 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
86618 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
86619 static DEFINE_MUTEX(sock_diag_table_mutex);
86620
86621 int sock_diag_check_cookie(void *sk, __u32 *cookie)
86622 {
86623 +#ifndef CONFIG_GRKERNSEC_HIDESYM
86624 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
86625 cookie[1] != INET_DIAG_NOCOOKIE) &&
86626 ((u32)(unsigned long)sk != cookie[0] ||
86627 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
86628 return -ESTALE;
86629 else
86630 +#endif
86631 return 0;
86632 }
86633 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
86634
86635 void sock_diag_save_cookie(void *sk, __u32 *cookie)
86636 {
86637 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86638 + cookie[0] = 0;
86639 + cookie[1] = 0;
86640 +#else
86641 cookie[0] = (u32)(unsigned long)sk;
86642 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
86643 +#endif
86644 }
86645 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
86646
86647 @@ -75,8 +82,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
86648 mutex_lock(&sock_diag_table_mutex);
86649 if (sock_diag_handlers[hndl->family])
86650 err = -EBUSY;
86651 - else
86652 + else {
86653 + pax_open_kernel();
86654 sock_diag_handlers[hndl->family] = hndl;
86655 + pax_close_kernel();
86656 + }
86657 mutex_unlock(&sock_diag_table_mutex);
86658
86659 return err;
86660 @@ -92,26 +102,13 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
86661
86662 mutex_lock(&sock_diag_table_mutex);
86663 BUG_ON(sock_diag_handlers[family] != hnld);
86664 + pax_open_kernel();
86665 sock_diag_handlers[family] = NULL;
86666 + pax_close_kernel();
86667 mutex_unlock(&sock_diag_table_mutex);
86668 }
86669 EXPORT_SYMBOL_GPL(sock_diag_unregister);
86670
86671 -static const inline struct sock_diag_handler *sock_diag_lock_handler(int family)
86672 -{
86673 - if (sock_diag_handlers[family] == NULL)
86674 - request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
86675 - NETLINK_SOCK_DIAG, family);
86676 -
86677 - mutex_lock(&sock_diag_table_mutex);
86678 - return sock_diag_handlers[family];
86679 -}
86680 -
86681 -static inline void sock_diag_unlock_handler(const struct sock_diag_handler *h)
86682 -{
86683 - mutex_unlock(&sock_diag_table_mutex);
86684 -}
86685 -
86686 static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
86687 {
86688 int err;
86689 @@ -124,12 +121,17 @@ static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
86690 if (req->sdiag_family >= AF_MAX)
86691 return -EINVAL;
86692
86693 - hndl = sock_diag_lock_handler(req->sdiag_family);
86694 + if (sock_diag_handlers[req->sdiag_family] == NULL)
86695 + request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
86696 + NETLINK_SOCK_DIAG, req->sdiag_family);
86697 +
86698 + mutex_lock(&sock_diag_table_mutex);
86699 + hndl = sock_diag_handlers[req->sdiag_family];
86700 if (hndl == NULL)
86701 err = -ENOENT;
86702 else
86703 err = hndl->dump(skb, nlh);
86704 - sock_diag_unlock_handler(hndl);
86705 + mutex_unlock(&sock_diag_table_mutex);
86706
86707 return err;
86708 }
86709 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
86710 index d1b0804..98cf5f7 100644
86711 --- a/net/core/sysctl_net_core.c
86712 +++ b/net/core/sysctl_net_core.c
86713 @@ -26,7 +26,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
86714 {
86715 unsigned int orig_size, size;
86716 int ret, i;
86717 - ctl_table tmp = {
86718 + ctl_table_no_const tmp = {
86719 .data = &size,
86720 .maxlen = sizeof(size),
86721 .mode = table->mode
86722 @@ -205,13 +205,12 @@ static struct ctl_table netns_core_table[] = {
86723
86724 static __net_init int sysctl_core_net_init(struct net *net)
86725 {
86726 - struct ctl_table *tbl;
86727 + ctl_table_no_const *tbl = NULL;
86728
86729 net->core.sysctl_somaxconn = SOMAXCONN;
86730
86731 - tbl = netns_core_table;
86732 if (!net_eq(net, &init_net)) {
86733 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
86734 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
86735 if (tbl == NULL)
86736 goto err_dup;
86737
86738 @@ -221,17 +220,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
86739 if (net->user_ns != &init_user_ns) {
86740 tbl[0].procname = NULL;
86741 }
86742 - }
86743 -
86744 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86745 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86746 + } else
86747 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
86748 if (net->core.sysctl_hdr == NULL)
86749 goto err_reg;
86750
86751 return 0;
86752
86753 err_reg:
86754 - if (tbl != netns_core_table)
86755 - kfree(tbl);
86756 + kfree(tbl);
86757 err_dup:
86758 return -ENOMEM;
86759 }
86760 @@ -246,7 +244,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
86761 kfree(tbl);
86762 }
86763
86764 -static __net_initdata struct pernet_operations sysctl_core_ops = {
86765 +static __net_initconst struct pernet_operations sysctl_core_ops = {
86766 .init = sysctl_core_net_init,
86767 .exit = sysctl_core_net_exit,
86768 };
86769 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
86770 index 307c322..78a4c6f 100644
86771 --- a/net/decnet/af_decnet.c
86772 +++ b/net/decnet/af_decnet.c
86773 @@ -468,6 +468,7 @@ static struct proto dn_proto = {
86774 .sysctl_rmem = sysctl_decnet_rmem,
86775 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
86776 .obj_size = sizeof(struct dn_sock),
86777 + .slab_flags = SLAB_USERCOPY,
86778 };
86779
86780 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
86781 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
86782 index a55eecc..dd8428c 100644
86783 --- a/net/decnet/sysctl_net_decnet.c
86784 +++ b/net/decnet/sysctl_net_decnet.c
86785 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
86786
86787 if (len > *lenp) len = *lenp;
86788
86789 - if (copy_to_user(buffer, addr, len))
86790 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
86791 return -EFAULT;
86792
86793 *lenp = len;
86794 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
86795
86796 if (len > *lenp) len = *lenp;
86797
86798 - if (copy_to_user(buffer, devname, len))
86799 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
86800 return -EFAULT;
86801
86802 *lenp = len;
86803 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
86804 index fcf104e..95552d4 100644
86805 --- a/net/ipv4/af_inet.c
86806 +++ b/net/ipv4/af_inet.c
86807 @@ -1717,13 +1717,9 @@ static int __init inet_init(void)
86808
86809 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > sizeof(dummy_skb->cb));
86810
86811 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
86812 - if (!sysctl_local_reserved_ports)
86813 - goto out;
86814 -
86815 rc = proto_register(&tcp_prot, 1);
86816 if (rc)
86817 - goto out_free_reserved_ports;
86818 + goto out;
86819
86820 rc = proto_register(&udp_prot, 1);
86821 if (rc)
86822 @@ -1832,8 +1828,6 @@ out_unregister_udp_proto:
86823 proto_unregister(&udp_prot);
86824 out_unregister_tcp_proto:
86825 proto_unregister(&tcp_prot);
86826 -out_free_reserved_ports:
86827 - kfree(sysctl_local_reserved_ports);
86828 goto out;
86829 }
86830
86831 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
86832 index a69b4e4..dbccba5 100644
86833 --- a/net/ipv4/ah4.c
86834 +++ b/net/ipv4/ah4.c
86835 @@ -421,7 +421,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
86836 return;
86837
86838 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86839 - atomic_inc(&flow_cache_genid);
86840 + atomic_inc_unchecked(&flow_cache_genid);
86841 rt_genid_bump(net);
86842
86843 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
86844 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
86845 index a8e4f26..25e5f40 100644
86846 --- a/net/ipv4/devinet.c
86847 +++ b/net/ipv4/devinet.c
86848 @@ -1763,7 +1763,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
86849 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
86850 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
86851
86852 -static struct devinet_sysctl_table {
86853 +static const struct devinet_sysctl_table {
86854 struct ctl_table_header *sysctl_header;
86855 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
86856 } devinet_sysctl = {
86857 @@ -1881,7 +1881,7 @@ static __net_init int devinet_init_net(struct net *net)
86858 int err;
86859 struct ipv4_devconf *all, *dflt;
86860 #ifdef CONFIG_SYSCTL
86861 - struct ctl_table *tbl = ctl_forward_entry;
86862 + ctl_table_no_const *tbl = NULL;
86863 struct ctl_table_header *forw_hdr;
86864 #endif
86865
86866 @@ -1899,7 +1899,7 @@ static __net_init int devinet_init_net(struct net *net)
86867 goto err_alloc_dflt;
86868
86869 #ifdef CONFIG_SYSCTL
86870 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
86871 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
86872 if (tbl == NULL)
86873 goto err_alloc_ctl;
86874
86875 @@ -1919,7 +1919,10 @@ static __net_init int devinet_init_net(struct net *net)
86876 goto err_reg_dflt;
86877
86878 err = -ENOMEM;
86879 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86880 + if (!net_eq(net, &init_net))
86881 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86882 + else
86883 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
86884 if (forw_hdr == NULL)
86885 goto err_reg_ctl;
86886 net->ipv4.forw_hdr = forw_hdr;
86887 @@ -1935,8 +1938,7 @@ err_reg_ctl:
86888 err_reg_dflt:
86889 __devinet_sysctl_unregister(all);
86890 err_reg_all:
86891 - if (tbl != ctl_forward_entry)
86892 - kfree(tbl);
86893 + kfree(tbl);
86894 err_alloc_ctl:
86895 #endif
86896 if (dflt != &ipv4_devconf_dflt)
86897 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
86898 index 3b4f0cd..8cb864c 100644
86899 --- a/net/ipv4/esp4.c
86900 +++ b/net/ipv4/esp4.c
86901 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
86902 return;
86903
86904 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86905 - atomic_inc(&flow_cache_genid);
86906 + atomic_inc_unchecked(&flow_cache_genid);
86907 rt_genid_bump(net);
86908
86909 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
86910 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
86911 index 5cd75e2..f57ef39 100644
86912 --- a/net/ipv4/fib_frontend.c
86913 +++ b/net/ipv4/fib_frontend.c
86914 @@ -1020,12 +1020,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
86915 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86916 fib_sync_up(dev);
86917 #endif
86918 - atomic_inc(&net->ipv4.dev_addr_genid);
86919 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86920 rt_cache_flush(dev_net(dev));
86921 break;
86922 case NETDEV_DOWN:
86923 fib_del_ifaddr(ifa, NULL);
86924 - atomic_inc(&net->ipv4.dev_addr_genid);
86925 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86926 if (ifa->ifa_dev->ifa_list == NULL) {
86927 /* Last address was deleted from this interface.
86928 * Disable IP.
86929 @@ -1061,7 +1061,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
86930 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86931 fib_sync_up(dev);
86932 #endif
86933 - atomic_inc(&net->ipv4.dev_addr_genid);
86934 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86935 rt_cache_flush(net);
86936 break;
86937 case NETDEV_DOWN:
86938 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
86939 index 4797a80..2bd54e9 100644
86940 --- a/net/ipv4/fib_semantics.c
86941 +++ b/net/ipv4/fib_semantics.c
86942 @@ -767,7 +767,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
86943 nh->nh_saddr = inet_select_addr(nh->nh_dev,
86944 nh->nh_gw,
86945 nh->nh_parent->fib_scope);
86946 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
86947 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
86948
86949 return nh->nh_saddr;
86950 }
86951 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
86952 index d0670f0..744ac80 100644
86953 --- a/net/ipv4/inet_connection_sock.c
86954 +++ b/net/ipv4/inet_connection_sock.c
86955 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
86956 .range = { 32768, 61000 },
86957 };
86958
86959 -unsigned long *sysctl_local_reserved_ports;
86960 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
86961 EXPORT_SYMBOL(sysctl_local_reserved_ports);
86962
86963 void inet_get_local_port_range(int *low, int *high)
86964 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
86965 index fa3ae81..0dbe6b8 100644
86966 --- a/net/ipv4/inet_hashtables.c
86967 +++ b/net/ipv4/inet_hashtables.c
86968 @@ -18,12 +18,15 @@
86969 #include <linux/sched.h>
86970 #include <linux/slab.h>
86971 #include <linux/wait.h>
86972 +#include <linux/security.h>
86973
86974 #include <net/inet_connection_sock.h>
86975 #include <net/inet_hashtables.h>
86976 #include <net/secure_seq.h>
86977 #include <net/ip.h>
86978
86979 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
86980 +
86981 /*
86982 * Allocate and initialize a new local port bind bucket.
86983 * The bindhash mutex for snum's hash chain must be held here.
86984 @@ -540,6 +543,8 @@ ok:
86985 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
86986 spin_unlock(&head->lock);
86987
86988 + gr_update_task_in_ip_table(current, inet_sk(sk));
86989 +
86990 if (tw) {
86991 inet_twsk_deschedule(tw, death_row);
86992 while (twrefcnt) {
86993 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
86994 index 000e3d2..5472da3 100644
86995 --- a/net/ipv4/inetpeer.c
86996 +++ b/net/ipv4/inetpeer.c
86997 @@ -503,8 +503,8 @@ relookup:
86998 if (p) {
86999 p->daddr = *daddr;
87000 atomic_set(&p->refcnt, 1);
87001 - atomic_set(&p->rid, 0);
87002 - atomic_set(&p->ip_id_count,
87003 + atomic_set_unchecked(&p->rid, 0);
87004 + atomic_set_unchecked(&p->ip_id_count,
87005 (daddr->family == AF_INET) ?
87006 secure_ip_id(daddr->addr.a4) :
87007 secure_ipv6_id(daddr->addr.a6));
87008 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
87009 index a8fc332..4ca4ca65 100644
87010 --- a/net/ipv4/ip_fragment.c
87011 +++ b/net/ipv4/ip_fragment.c
87012 @@ -319,7 +319,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
87013 return 0;
87014
87015 start = qp->rid;
87016 - end = atomic_inc_return(&peer->rid);
87017 + end = atomic_inc_return_unchecked(&peer->rid);
87018 qp->rid = end;
87019
87020 rc = qp->q.fragments && (end - start) > max;
87021 @@ -786,12 +786,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
87022
87023 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87024 {
87025 - struct ctl_table *table;
87026 + ctl_table_no_const *table = NULL;
87027 struct ctl_table_header *hdr;
87028
87029 - table = ip4_frags_ns_ctl_table;
87030 if (!net_eq(net, &init_net)) {
87031 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
87032 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
87033 if (table == NULL)
87034 goto err_alloc;
87035
87036 @@ -802,9 +801,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87037 /* Don't export sysctls to unprivileged users */
87038 if (net->user_ns != &init_user_ns)
87039 table[0].procname = NULL;
87040 - }
87041 + hdr = register_net_sysctl(net, "net/ipv4", table);
87042 + } else
87043 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
87044
87045 - hdr = register_net_sysctl(net, "net/ipv4", table);
87046 if (hdr == NULL)
87047 goto err_reg;
87048
87049 @@ -812,8 +812,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87050 return 0;
87051
87052 err_reg:
87053 - if (!net_eq(net, &init_net))
87054 - kfree(table);
87055 + kfree(table);
87056 err_alloc:
87057 return -ENOMEM;
87058 }
87059 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
87060 index a85062b..2958a9b 100644
87061 --- a/net/ipv4/ip_gre.c
87062 +++ b/net/ipv4/ip_gre.c
87063 @@ -124,7 +124,7 @@ static bool log_ecn_error = true;
87064 module_param(log_ecn_error, bool, 0644);
87065 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
87066
87067 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
87068 +static struct rtnl_link_ops ipgre_link_ops;
87069 static int ipgre_tunnel_init(struct net_device *dev);
87070 static void ipgre_tunnel_setup(struct net_device *dev);
87071 static int ipgre_tunnel_bind_dev(struct net_device *dev);
87072 @@ -1753,7 +1753,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
87073 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
87074 };
87075
87076 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
87077 +static struct rtnl_link_ops ipgre_link_ops = {
87078 .kind = "gre",
87079 .maxtype = IFLA_GRE_MAX,
87080 .policy = ipgre_policy,
87081 @@ -1766,7 +1766,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
87082 .fill_info = ipgre_fill_info,
87083 };
87084
87085 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
87086 +static struct rtnl_link_ops ipgre_tap_ops = {
87087 .kind = "gretap",
87088 .maxtype = IFLA_GRE_MAX,
87089 .policy = ipgre_policy,
87090 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
87091 index d9c4f11..02b82dbc 100644
87092 --- a/net/ipv4/ip_sockglue.c
87093 +++ b/net/ipv4/ip_sockglue.c
87094 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
87095 len = min_t(unsigned int, len, opt->optlen);
87096 if (put_user(len, optlen))
87097 return -EFAULT;
87098 - if (copy_to_user(optval, opt->__data, len))
87099 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
87100 + copy_to_user(optval, opt->__data, len))
87101 return -EFAULT;
87102 return 0;
87103 }
87104 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
87105 if (sk->sk_type != SOCK_STREAM)
87106 return -ENOPROTOOPT;
87107
87108 - msg.msg_control = optval;
87109 + msg.msg_control = (void __force_kernel *)optval;
87110 msg.msg_controllen = len;
87111 msg.msg_flags = flags;
87112
87113 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
87114 index c3a4233..1412161 100644
87115 --- a/net/ipv4/ip_vti.c
87116 +++ b/net/ipv4/ip_vti.c
87117 @@ -47,7 +47,7 @@
87118 #define HASH_SIZE 16
87119 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
87120
87121 -static struct rtnl_link_ops vti_link_ops __read_mostly;
87122 +static struct rtnl_link_ops vti_link_ops;
87123
87124 static int vti_net_id __read_mostly;
87125 struct vti_net {
87126 @@ -886,7 +886,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
87127 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
87128 };
87129
87130 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
87131 +static struct rtnl_link_ops vti_link_ops = {
87132 .kind = "vti",
87133 .maxtype = IFLA_VTI_MAX,
87134 .policy = vti_policy,
87135 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
87136 index 9a46dae..5f793a0 100644
87137 --- a/net/ipv4/ipcomp.c
87138 +++ b/net/ipv4/ipcomp.c
87139 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
87140 return;
87141
87142 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
87143 - atomic_inc(&flow_cache_genid);
87144 + atomic_inc_unchecked(&flow_cache_genid);
87145 rt_genid_bump(net);
87146
87147 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
87148 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
87149 index a2e50ae..e152b7c 100644
87150 --- a/net/ipv4/ipconfig.c
87151 +++ b/net/ipv4/ipconfig.c
87152 @@ -323,7 +323,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
87153
87154 mm_segment_t oldfs = get_fs();
87155 set_fs(get_ds());
87156 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
87157 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
87158 set_fs(oldfs);
87159 return res;
87160 }
87161 @@ -334,7 +334,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
87162
87163 mm_segment_t oldfs = get_fs();
87164 set_fs(get_ds());
87165 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
87166 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
87167 set_fs(oldfs);
87168 return res;
87169 }
87170 @@ -345,7 +345,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
87171
87172 mm_segment_t oldfs = get_fs();
87173 set_fs(get_ds());
87174 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
87175 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
87176 set_fs(oldfs);
87177 return res;
87178 }
87179 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
87180 index 191fc24..1b3b804 100644
87181 --- a/net/ipv4/ipip.c
87182 +++ b/net/ipv4/ipip.c
87183 @@ -138,7 +138,7 @@ struct ipip_net {
87184 static int ipip_tunnel_init(struct net_device *dev);
87185 static void ipip_tunnel_setup(struct net_device *dev);
87186 static void ipip_dev_free(struct net_device *dev);
87187 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
87188 +static struct rtnl_link_ops ipip_link_ops;
87189
87190 static struct rtnl_link_stats64 *ipip_get_stats64(struct net_device *dev,
87191 struct rtnl_link_stats64 *tot)
87192 @@ -972,7 +972,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
87193 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
87194 };
87195
87196 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
87197 +static struct rtnl_link_ops ipip_link_ops = {
87198 .kind = "ipip",
87199 .maxtype = IFLA_IPTUN_MAX,
87200 .policy = ipip_policy,
87201 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
87202 index 3ea4127..849297b 100644
87203 --- a/net/ipv4/netfilter/arp_tables.c
87204 +++ b/net/ipv4/netfilter/arp_tables.c
87205 @@ -879,14 +879,14 @@ static int compat_table_info(const struct xt_table_info *info,
87206 #endif
87207
87208 static int get_info(struct net *net, void __user *user,
87209 - const int *len, int compat)
87210 + int len, int compat)
87211 {
87212 char name[XT_TABLE_MAXNAMELEN];
87213 struct xt_table *t;
87214 int ret;
87215
87216 - if (*len != sizeof(struct arpt_getinfo)) {
87217 - duprintf("length %u != %Zu\n", *len,
87218 + if (len != sizeof(struct arpt_getinfo)) {
87219 + duprintf("length %u != %Zu\n", len,
87220 sizeof(struct arpt_getinfo));
87221 return -EINVAL;
87222 }
87223 @@ -923,7 +923,7 @@ static int get_info(struct net *net, void __user *user,
87224 info.size = private->size;
87225 strcpy(info.name, name);
87226
87227 - if (copy_to_user(user, &info, *len) != 0)
87228 + if (copy_to_user(user, &info, len) != 0)
87229 ret = -EFAULT;
87230 else
87231 ret = 0;
87232 @@ -1682,7 +1682,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
87233
87234 switch (cmd) {
87235 case ARPT_SO_GET_INFO:
87236 - ret = get_info(sock_net(sk), user, len, 1);
87237 + ret = get_info(sock_net(sk), user, *len, 1);
87238 break;
87239 case ARPT_SO_GET_ENTRIES:
87240 ret = compat_get_entries(sock_net(sk), user, len);
87241 @@ -1727,7 +1727,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
87242
87243 switch (cmd) {
87244 case ARPT_SO_GET_INFO:
87245 - ret = get_info(sock_net(sk), user, len, 0);
87246 + ret = get_info(sock_net(sk), user, *len, 0);
87247 break;
87248
87249 case ARPT_SO_GET_ENTRIES:
87250 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
87251 index 17c5e06..1b91206 100644
87252 --- a/net/ipv4/netfilter/ip_tables.c
87253 +++ b/net/ipv4/netfilter/ip_tables.c
87254 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
87255 #endif
87256
87257 static int get_info(struct net *net, void __user *user,
87258 - const int *len, int compat)
87259 + int len, int compat)
87260 {
87261 char name[XT_TABLE_MAXNAMELEN];
87262 struct xt_table *t;
87263 int ret;
87264
87265 - if (*len != sizeof(struct ipt_getinfo)) {
87266 - duprintf("length %u != %zu\n", *len,
87267 + if (len != sizeof(struct ipt_getinfo)) {
87268 + duprintf("length %u != %zu\n", len,
87269 sizeof(struct ipt_getinfo));
87270 return -EINVAL;
87271 }
87272 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
87273 info.size = private->size;
87274 strcpy(info.name, name);
87275
87276 - if (copy_to_user(user, &info, *len) != 0)
87277 + if (copy_to_user(user, &info, len) != 0)
87278 ret = -EFAULT;
87279 else
87280 ret = 0;
87281 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87282
87283 switch (cmd) {
87284 case IPT_SO_GET_INFO:
87285 - ret = get_info(sock_net(sk), user, len, 1);
87286 + ret = get_info(sock_net(sk), user, *len, 1);
87287 break;
87288 case IPT_SO_GET_ENTRIES:
87289 ret = compat_get_entries(sock_net(sk), user, len);
87290 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87291
87292 switch (cmd) {
87293 case IPT_SO_GET_INFO:
87294 - ret = get_info(sock_net(sk), user, len, 0);
87295 + ret = get_info(sock_net(sk), user, *len, 0);
87296 break;
87297
87298 case IPT_SO_GET_ENTRIES:
87299 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
87300 index dc454cc..5bb917f 100644
87301 --- a/net/ipv4/ping.c
87302 +++ b/net/ipv4/ping.c
87303 @@ -844,7 +844,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
87304 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87305 0, sock_i_ino(sp),
87306 atomic_read(&sp->sk_refcnt), sp,
87307 - atomic_read(&sp->sk_drops), len);
87308 + atomic_read_unchecked(&sp->sk_drops), len);
87309 }
87310
87311 static int ping_seq_show(struct seq_file *seq, void *v)
87312 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
87313 index 6f08991..55867ad 100644
87314 --- a/net/ipv4/raw.c
87315 +++ b/net/ipv4/raw.c
87316 @@ -311,7 +311,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
87317 int raw_rcv(struct sock *sk, struct sk_buff *skb)
87318 {
87319 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
87320 - atomic_inc(&sk->sk_drops);
87321 + atomic_inc_unchecked(&sk->sk_drops);
87322 kfree_skb(skb);
87323 return NET_RX_DROP;
87324 }
87325 @@ -747,16 +747,20 @@ static int raw_init(struct sock *sk)
87326
87327 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
87328 {
87329 + struct icmp_filter filter;
87330 +
87331 if (optlen > sizeof(struct icmp_filter))
87332 optlen = sizeof(struct icmp_filter);
87333 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
87334 + if (copy_from_user(&filter, optval, optlen))
87335 return -EFAULT;
87336 + raw_sk(sk)->filter = filter;
87337 return 0;
87338 }
87339
87340 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
87341 {
87342 int len, ret = -EFAULT;
87343 + struct icmp_filter filter;
87344
87345 if (get_user(len, optlen))
87346 goto out;
87347 @@ -766,8 +770,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
87348 if (len > sizeof(struct icmp_filter))
87349 len = sizeof(struct icmp_filter);
87350 ret = -EFAULT;
87351 - if (put_user(len, optlen) ||
87352 - copy_to_user(optval, &raw_sk(sk)->filter, len))
87353 + filter = raw_sk(sk)->filter;
87354 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
87355 goto out;
87356 ret = 0;
87357 out: return ret;
87358 @@ -998,7 +1002,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
87359 0, 0L, 0,
87360 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
87361 0, sock_i_ino(sp),
87362 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
87363 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
87364 }
87365
87366 static int raw_seq_show(struct seq_file *seq, void *v)
87367 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
87368 index a0fcc47..32e2c89 100644
87369 --- a/net/ipv4/route.c
87370 +++ b/net/ipv4/route.c
87371 @@ -2552,34 +2552,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
87372 .maxlen = sizeof(int),
87373 .mode = 0200,
87374 .proc_handler = ipv4_sysctl_rtcache_flush,
87375 + .extra1 = &init_net,
87376 },
87377 { },
87378 };
87379
87380 static __net_init int sysctl_route_net_init(struct net *net)
87381 {
87382 - struct ctl_table *tbl;
87383 + ctl_table_no_const *tbl = NULL;
87384
87385 - tbl = ipv4_route_flush_table;
87386 if (!net_eq(net, &init_net)) {
87387 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87388 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87389 if (tbl == NULL)
87390 goto err_dup;
87391
87392 /* Don't export sysctls to unprivileged users */
87393 if (net->user_ns != &init_user_ns)
87394 tbl[0].procname = NULL;
87395 - }
87396 - tbl[0].extra1 = net;
87397 + tbl[0].extra1 = net;
87398 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87399 + } else
87400 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
87401
87402 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87403 if (net->ipv4.route_hdr == NULL)
87404 goto err_reg;
87405 return 0;
87406
87407 err_reg:
87408 - if (tbl != ipv4_route_flush_table)
87409 - kfree(tbl);
87410 + kfree(tbl);
87411 err_dup:
87412 return -ENOMEM;
87413 }
87414 @@ -2602,7 +2602,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
87415
87416 static __net_init int rt_genid_init(struct net *net)
87417 {
87418 - atomic_set(&net->rt_genid, 0);
87419 + atomic_set_unchecked(&net->rt_genid, 0);
87420 get_random_bytes(&net->ipv4.dev_addr_genid,
87421 sizeof(net->ipv4.dev_addr_genid));
87422 return 0;
87423 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
87424 index d84400b..62e066e 100644
87425 --- a/net/ipv4/sysctl_net_ipv4.c
87426 +++ b/net/ipv4/sysctl_net_ipv4.c
87427 @@ -54,7 +54,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
87428 {
87429 int ret;
87430 int range[2];
87431 - ctl_table tmp = {
87432 + ctl_table_no_const tmp = {
87433 .data = &range,
87434 .maxlen = sizeof(range),
87435 .mode = table->mode,
87436 @@ -107,7 +107,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
87437 int ret;
87438 gid_t urange[2];
87439 kgid_t low, high;
87440 - ctl_table tmp = {
87441 + ctl_table_no_const tmp = {
87442 .data = &urange,
87443 .maxlen = sizeof(urange),
87444 .mode = table->mode,
87445 @@ -138,7 +138,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
87446 void __user *buffer, size_t *lenp, loff_t *ppos)
87447 {
87448 char val[TCP_CA_NAME_MAX];
87449 - ctl_table tbl = {
87450 + ctl_table_no_const tbl = {
87451 .data = val,
87452 .maxlen = TCP_CA_NAME_MAX,
87453 };
87454 @@ -157,7 +157,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
87455 void __user *buffer, size_t *lenp,
87456 loff_t *ppos)
87457 {
87458 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
87459 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
87460 int ret;
87461
87462 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87463 @@ -174,7 +174,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
87464 void __user *buffer, size_t *lenp,
87465 loff_t *ppos)
87466 {
87467 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
87468 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
87469 int ret;
87470
87471 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87472 @@ -200,15 +200,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87473 struct mem_cgroup *memcg;
87474 #endif
87475
87476 - ctl_table tmp = {
87477 + ctl_table_no_const tmp = {
87478 .data = &vec,
87479 .maxlen = sizeof(vec),
87480 .mode = ctl->mode,
87481 };
87482
87483 if (!write) {
87484 - ctl->data = &net->ipv4.sysctl_tcp_mem;
87485 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
87486 + ctl_table_no_const tcp_mem = *ctl;
87487 +
87488 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
87489 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
87490 }
87491
87492 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
87493 @@ -235,7 +237,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87494 int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
87495 size_t *lenp, loff_t *ppos)
87496 {
87497 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87498 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87499 struct tcp_fastopen_context *ctxt;
87500 int ret;
87501 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
87502 @@ -476,7 +478,7 @@ static struct ctl_table ipv4_table[] = {
87503 },
87504 {
87505 .procname = "ip_local_reserved_ports",
87506 - .data = NULL, /* initialized in sysctl_ipv4_init */
87507 + .data = sysctl_local_reserved_ports,
87508 .maxlen = 65536,
87509 .mode = 0644,
87510 .proc_handler = proc_do_large_bitmap,
87511 @@ -860,11 +862,10 @@ static struct ctl_table ipv4_net_table[] = {
87512
87513 static __net_init int ipv4_sysctl_init_net(struct net *net)
87514 {
87515 - struct ctl_table *table;
87516 + ctl_table_no_const *table = NULL;
87517
87518 - table = ipv4_net_table;
87519 if (!net_eq(net, &init_net)) {
87520 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
87521 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
87522 if (table == NULL)
87523 goto err_alloc;
87524
87525 @@ -897,15 +898,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
87526
87527 tcp_init_mem(net);
87528
87529 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87530 + if (!net_eq(net, &init_net))
87531 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87532 + else
87533 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
87534 if (net->ipv4.ipv4_hdr == NULL)
87535 goto err_reg;
87536
87537 return 0;
87538
87539 err_reg:
87540 - if (!net_eq(net, &init_net))
87541 - kfree(table);
87542 + kfree(table);
87543 err_alloc:
87544 return -ENOMEM;
87545 }
87546 @@ -927,16 +930,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
87547 static __init int sysctl_ipv4_init(void)
87548 {
87549 struct ctl_table_header *hdr;
87550 - struct ctl_table *i;
87551 -
87552 - for (i = ipv4_table; i->procname; i++) {
87553 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
87554 - i->data = sysctl_local_reserved_ports;
87555 - break;
87556 - }
87557 - }
87558 - if (!i->procname)
87559 - return -EINVAL;
87560
87561 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
87562 if (hdr == NULL)
87563 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
87564 index 9841a71..ef60409 100644
87565 --- a/net/ipv4/tcp_input.c
87566 +++ b/net/ipv4/tcp_input.c
87567 @@ -4730,7 +4730,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
87568 * simplifies code)
87569 */
87570 static void
87571 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87572 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87573 struct sk_buff *head, struct sk_buff *tail,
87574 u32 start, u32 end)
87575 {
87576 @@ -5847,6 +5847,7 @@ discard:
87577 tcp_paws_reject(&tp->rx_opt, 0))
87578 goto discard_and_undo;
87579
87580 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
87581 if (th->syn) {
87582 /* We see SYN without ACK. It is attempt of
87583 * simultaneous connect with crossed SYNs.
87584 @@ -5897,6 +5898,7 @@ discard:
87585 goto discard;
87586 #endif
87587 }
87588 +#endif
87589 /* "fifth, if neither of the SYN or RST bits is set then
87590 * drop the segment and return."
87591 */
87592 @@ -5941,7 +5943,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
87593 goto discard;
87594
87595 if (th->syn) {
87596 - if (th->fin)
87597 + if (th->fin || th->urg || th->psh)
87598 goto discard;
87599 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
87600 return 1;
87601 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
87602 index d9130a9..00328ff 100644
87603 --- a/net/ipv4/tcp_ipv4.c
87604 +++ b/net/ipv4/tcp_ipv4.c
87605 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
87606 EXPORT_SYMBOL(sysctl_tcp_low_latency);
87607
87608
87609 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87610 +extern int grsec_enable_blackhole;
87611 +#endif
87612 +
87613 #ifdef CONFIG_TCP_MD5SIG
87614 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
87615 __be32 daddr, __be32 saddr, const struct tcphdr *th);
87616 @@ -1895,6 +1899,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
87617 return 0;
87618
87619 reset:
87620 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87621 + if (!grsec_enable_blackhole)
87622 +#endif
87623 tcp_v4_send_reset(rsk, skb);
87624 discard:
87625 kfree_skb(skb);
87626 @@ -1994,12 +2001,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
87627 TCP_SKB_CB(skb)->sacked = 0;
87628
87629 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
87630 - if (!sk)
87631 + if (!sk) {
87632 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87633 + ret = 1;
87634 +#endif
87635 goto no_tcp_socket;
87636 -
87637 + }
87638 process:
87639 - if (sk->sk_state == TCP_TIME_WAIT)
87640 + if (sk->sk_state == TCP_TIME_WAIT) {
87641 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87642 + ret = 2;
87643 +#endif
87644 goto do_time_wait;
87645 + }
87646
87647 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
87648 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
87649 @@ -2050,6 +2064,10 @@ no_tcp_socket:
87650 bad_packet:
87651 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
87652 } else {
87653 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87654 + if (!grsec_enable_blackhole || (ret == 1 &&
87655 + (skb->dev->flags & IFF_LOOPBACK)))
87656 +#endif
87657 tcp_v4_send_reset(NULL, skb);
87658 }
87659
87660 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
87661 index f35f2df..ccb5ca6 100644
87662 --- a/net/ipv4/tcp_minisocks.c
87663 +++ b/net/ipv4/tcp_minisocks.c
87664 @@ -27,6 +27,10 @@
87665 #include <net/inet_common.h>
87666 #include <net/xfrm.h>
87667
87668 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87669 +extern int grsec_enable_blackhole;
87670 +#endif
87671 +
87672 int sysctl_tcp_syncookies __read_mostly = 1;
87673 EXPORT_SYMBOL(sysctl_tcp_syncookies);
87674
87675 @@ -742,7 +746,10 @@ embryonic_reset:
87676 * avoid becoming vulnerable to outside attack aiming at
87677 * resetting legit local connections.
87678 */
87679 - req->rsk_ops->send_reset(sk, skb);
87680 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87681 + if (!grsec_enable_blackhole)
87682 +#endif
87683 + req->rsk_ops->send_reset(sk, skb);
87684 } else if (fastopen) { /* received a valid RST pkt */
87685 reqsk_fastopen_remove(sk, req, true);
87686 tcp_reset(sk);
87687 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
87688 index 4526fe6..1a34e43 100644
87689 --- a/net/ipv4/tcp_probe.c
87690 +++ b/net/ipv4/tcp_probe.c
87691 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
87692 if (cnt + width >= len)
87693 break;
87694
87695 - if (copy_to_user(buf + cnt, tbuf, width))
87696 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
87697 return -EFAULT;
87698 cnt += width;
87699 }
87700 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
87701 index b78aac3..e18230b 100644
87702 --- a/net/ipv4/tcp_timer.c
87703 +++ b/net/ipv4/tcp_timer.c
87704 @@ -22,6 +22,10 @@
87705 #include <linux/gfp.h>
87706 #include <net/tcp.h>
87707
87708 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87709 +extern int grsec_lastack_retries;
87710 +#endif
87711 +
87712 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
87713 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
87714 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
87715 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
87716 }
87717 }
87718
87719 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87720 + if ((sk->sk_state == TCP_LAST_ACK) &&
87721 + (grsec_lastack_retries > 0) &&
87722 + (grsec_lastack_retries < retry_until))
87723 + retry_until = grsec_lastack_retries;
87724 +#endif
87725 +
87726 if (retransmits_timed_out(sk, retry_until,
87727 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
87728 /* Has it gone just too far? */
87729 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
87730 index 1f4d405..3524677 100644
87731 --- a/net/ipv4/udp.c
87732 +++ b/net/ipv4/udp.c
87733 @@ -87,6 +87,7 @@
87734 #include <linux/types.h>
87735 #include <linux/fcntl.h>
87736 #include <linux/module.h>
87737 +#include <linux/security.h>
87738 #include <linux/socket.h>
87739 #include <linux/sockios.h>
87740 #include <linux/igmp.h>
87741 @@ -111,6 +112,10 @@
87742 #include <trace/events/skb.h>
87743 #include "udp_impl.h"
87744
87745 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87746 +extern int grsec_enable_blackhole;
87747 +#endif
87748 +
87749 struct udp_table udp_table __read_mostly;
87750 EXPORT_SYMBOL(udp_table);
87751
87752 @@ -569,6 +574,9 @@ found:
87753 return s;
87754 }
87755
87756 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
87757 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
87758 +
87759 /*
87760 * This routine is called by the ICMP module when it gets some
87761 * sort of error condition. If err < 0 then the socket should
87762 @@ -864,9 +872,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
87763 dport = usin->sin_port;
87764 if (dport == 0)
87765 return -EINVAL;
87766 +
87767 + err = gr_search_udp_sendmsg(sk, usin);
87768 + if (err)
87769 + return err;
87770 } else {
87771 if (sk->sk_state != TCP_ESTABLISHED)
87772 return -EDESTADDRREQ;
87773 +
87774 + err = gr_search_udp_sendmsg(sk, NULL);
87775 + if (err)
87776 + return err;
87777 +
87778 daddr = inet->inet_daddr;
87779 dport = inet->inet_dport;
87780 /* Open fast path for connected socket.
87781 @@ -1108,7 +1125,7 @@ static unsigned int first_packet_length(struct sock *sk)
87782 udp_lib_checksum_complete(skb)) {
87783 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87784 IS_UDPLITE(sk));
87785 - atomic_inc(&sk->sk_drops);
87786 + atomic_inc_unchecked(&sk->sk_drops);
87787 __skb_unlink(skb, rcvq);
87788 __skb_queue_tail(&list_kill, skb);
87789 }
87790 @@ -1194,6 +1211,10 @@ try_again:
87791 if (!skb)
87792 goto out;
87793
87794 + err = gr_search_udp_recvmsg(sk, skb);
87795 + if (err)
87796 + goto out_free;
87797 +
87798 ulen = skb->len - sizeof(struct udphdr);
87799 copied = len;
87800 if (copied > ulen)
87801 @@ -1227,7 +1248,7 @@ try_again:
87802 if (unlikely(err)) {
87803 trace_kfree_skb(skb, udp_recvmsg);
87804 if (!peeked) {
87805 - atomic_inc(&sk->sk_drops);
87806 + atomic_inc_unchecked(&sk->sk_drops);
87807 UDP_INC_STATS_USER(sock_net(sk),
87808 UDP_MIB_INERRORS, is_udplite);
87809 }
87810 @@ -1510,7 +1531,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87811
87812 drop:
87813 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
87814 - atomic_inc(&sk->sk_drops);
87815 + atomic_inc_unchecked(&sk->sk_drops);
87816 kfree_skb(skb);
87817 return -1;
87818 }
87819 @@ -1529,7 +1550,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
87820 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
87821
87822 if (!skb1) {
87823 - atomic_inc(&sk->sk_drops);
87824 + atomic_inc_unchecked(&sk->sk_drops);
87825 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
87826 IS_UDPLITE(sk));
87827 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87828 @@ -1698,6 +1719,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
87829 goto csum_error;
87830
87831 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
87832 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87833 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
87834 +#endif
87835 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
87836
87837 /*
87838 @@ -2120,7 +2144,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
87839 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87840 0, sock_i_ino(sp),
87841 atomic_read(&sp->sk_refcnt), sp,
87842 - atomic_read(&sp->sk_drops), len);
87843 + atomic_read_unchecked(&sp->sk_drops), len);
87844 }
87845
87846 int udp4_seq_show(struct seq_file *seq, void *v)
87847 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
87848 index a36d17e..96d099f 100644
87849 --- a/net/ipv6/addrconf.c
87850 +++ b/net/ipv6/addrconf.c
87851 @@ -2272,7 +2272,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
87852 p.iph.ihl = 5;
87853 p.iph.protocol = IPPROTO_IPV6;
87854 p.iph.ttl = 64;
87855 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
87856 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
87857
87858 if (ops->ndo_do_ioctl) {
87859 mm_segment_t oldfs = get_fs();
87860 @@ -4388,7 +4388,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
87861 int *valp = ctl->data;
87862 int val = *valp;
87863 loff_t pos = *ppos;
87864 - ctl_table lctl;
87865 + ctl_table_no_const lctl;
87866 int ret;
87867
87868 /*
87869 @@ -4470,7 +4470,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
87870 int *valp = ctl->data;
87871 int val = *valp;
87872 loff_t pos = *ppos;
87873 - ctl_table lctl;
87874 + ctl_table_no_const lctl;
87875 int ret;
87876
87877 /*
87878 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
87879 index fff5bdd..15194fb 100644
87880 --- a/net/ipv6/icmp.c
87881 +++ b/net/ipv6/icmp.c
87882 @@ -973,7 +973,7 @@ ctl_table ipv6_icmp_table_template[] = {
87883
87884 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
87885 {
87886 - struct ctl_table *table;
87887 + ctl_table_no_const *table;
87888
87889 table = kmemdup(ipv6_icmp_table_template,
87890 sizeof(ipv6_icmp_table_template),
87891 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
87892 index 131dd09..f7ed64f 100644
87893 --- a/net/ipv6/ip6_gre.c
87894 +++ b/net/ipv6/ip6_gre.c
87895 @@ -73,7 +73,7 @@ struct ip6gre_net {
87896 struct net_device *fb_tunnel_dev;
87897 };
87898
87899 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
87900 +static struct rtnl_link_ops ip6gre_link_ops;
87901 static int ip6gre_tunnel_init(struct net_device *dev);
87902 static void ip6gre_tunnel_setup(struct net_device *dev);
87903 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
87904 @@ -1337,7 +1337,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
87905 }
87906
87907
87908 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
87909 +static struct inet6_protocol ip6gre_protocol = {
87910 .handler = ip6gre_rcv,
87911 .err_handler = ip6gre_err,
87912 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
87913 @@ -1671,7 +1671,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
87914 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
87915 };
87916
87917 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87918 +static struct rtnl_link_ops ip6gre_link_ops = {
87919 .kind = "ip6gre",
87920 .maxtype = IFLA_GRE_MAX,
87921 .policy = ip6gre_policy,
87922 @@ -1684,7 +1684,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87923 .fill_info = ip6gre_fill_info,
87924 };
87925
87926 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
87927 +static struct rtnl_link_ops ip6gre_tap_ops = {
87928 .kind = "ip6gretap",
87929 .maxtype = IFLA_GRE_MAX,
87930 .policy = ip6gre_policy,
87931 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
87932 index a14f28b..b4b8956 100644
87933 --- a/net/ipv6/ip6_tunnel.c
87934 +++ b/net/ipv6/ip6_tunnel.c
87935 @@ -87,7 +87,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
87936
87937 static int ip6_tnl_dev_init(struct net_device *dev);
87938 static void ip6_tnl_dev_setup(struct net_device *dev);
87939 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
87940 +static struct rtnl_link_ops ip6_link_ops;
87941
87942 static int ip6_tnl_net_id __read_mostly;
87943 struct ip6_tnl_net {
87944 @@ -1686,7 +1686,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
87945 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
87946 };
87947
87948 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
87949 +static struct rtnl_link_ops ip6_link_ops = {
87950 .kind = "ip6tnl",
87951 .maxtype = IFLA_IPTUN_MAX,
87952 .policy = ip6_tnl_policy,
87953 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
87954 index d1e2e8e..51c19ae 100644
87955 --- a/net/ipv6/ipv6_sockglue.c
87956 +++ b/net/ipv6/ipv6_sockglue.c
87957 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
87958 if (sk->sk_type != SOCK_STREAM)
87959 return -ENOPROTOOPT;
87960
87961 - msg.msg_control = optval;
87962 + msg.msg_control = (void __force_kernel *)optval;
87963 msg.msg_controllen = len;
87964 msg.msg_flags = flags;
87965
87966 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
87967 index 125a90d..2a11f36 100644
87968 --- a/net/ipv6/netfilter/ip6_tables.c
87969 +++ b/net/ipv6/netfilter/ip6_tables.c
87970 @@ -1076,14 +1076,14 @@ static int compat_table_info(const struct xt_table_info *info,
87971 #endif
87972
87973 static int get_info(struct net *net, void __user *user,
87974 - const int *len, int compat)
87975 + int len, int compat)
87976 {
87977 char name[XT_TABLE_MAXNAMELEN];
87978 struct xt_table *t;
87979 int ret;
87980
87981 - if (*len != sizeof(struct ip6t_getinfo)) {
87982 - duprintf("length %u != %zu\n", *len,
87983 + if (len != sizeof(struct ip6t_getinfo)) {
87984 + duprintf("length %u != %zu\n", len,
87985 sizeof(struct ip6t_getinfo));
87986 return -EINVAL;
87987 }
87988 @@ -1120,7 +1120,7 @@ static int get_info(struct net *net, void __user *user,
87989 info.size = private->size;
87990 strcpy(info.name, name);
87991
87992 - if (copy_to_user(user, &info, *len) != 0)
87993 + if (copy_to_user(user, &info, len) != 0)
87994 ret = -EFAULT;
87995 else
87996 ret = 0;
87997 @@ -1974,7 +1974,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87998
87999 switch (cmd) {
88000 case IP6T_SO_GET_INFO:
88001 - ret = get_info(sock_net(sk), user, len, 1);
88002 + ret = get_info(sock_net(sk), user, *len, 1);
88003 break;
88004 case IP6T_SO_GET_ENTRIES:
88005 ret = compat_get_entries(sock_net(sk), user, len);
88006 @@ -2021,7 +2021,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
88007
88008 switch (cmd) {
88009 case IP6T_SO_GET_INFO:
88010 - ret = get_info(sock_net(sk), user, len, 0);
88011 + ret = get_info(sock_net(sk), user, *len, 0);
88012 break;
88013
88014 case IP6T_SO_GET_ENTRIES:
88015 diff --git a/net/ipv6/netfilter/ip6t_NPT.c b/net/ipv6/netfilter/ip6t_NPT.c
88016 index 83acc14..0ea43c7 100644
88017 --- a/net/ipv6/netfilter/ip6t_NPT.c
88018 +++ b/net/ipv6/netfilter/ip6t_NPT.c
88019 @@ -57,7 +57,7 @@ static bool ip6t_npt_map_pfx(const struct ip6t_npt_tginfo *npt,
88020 if (pfx_len - i >= 32)
88021 mask = 0;
88022 else
88023 - mask = htonl(~((1 << (pfx_len - i)) - 1));
88024 + mask = htonl((1 << (i - pfx_len + 32)) - 1);
88025
88026 idx = i / 32;
88027 addr->s6_addr32[idx] &= mask;
88028 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
88029 index 2f3a018..8bca195 100644
88030 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
88031 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
88032 @@ -89,12 +89,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
88033
88034 static int nf_ct_frag6_sysctl_register(struct net *net)
88035 {
88036 - struct ctl_table *table;
88037 + ctl_table_no_const *table = NULL;
88038 struct ctl_table_header *hdr;
88039
88040 - table = nf_ct_frag6_sysctl_table;
88041 if (!net_eq(net, &init_net)) {
88042 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
88043 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
88044 GFP_KERNEL);
88045 if (table == NULL)
88046 goto err_alloc;
88047 @@ -102,9 +101,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
88048 table[0].data = &net->ipv6.frags.high_thresh;
88049 table[1].data = &net->ipv6.frags.low_thresh;
88050 table[2].data = &net->ipv6.frags.timeout;
88051 - }
88052 -
88053 - hdr = register_net_sysctl(net, "net/netfilter", table);
88054 + hdr = register_net_sysctl(net, "net/netfilter", table);
88055 + } else
88056 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
88057 if (hdr == NULL)
88058 goto err_reg;
88059
88060 @@ -112,8 +111,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
88061 return 0;
88062
88063 err_reg:
88064 - if (!net_eq(net, &init_net))
88065 - kfree(table);
88066 + kfree(table);
88067 err_alloc:
88068 return -ENOMEM;
88069 }
88070 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
88071 index 70fa814..d70c28c 100644
88072 --- a/net/ipv6/raw.c
88073 +++ b/net/ipv6/raw.c
88074 @@ -379,7 +379,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
88075 {
88076 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
88077 skb_checksum_complete(skb)) {
88078 - atomic_inc(&sk->sk_drops);
88079 + atomic_inc_unchecked(&sk->sk_drops);
88080 kfree_skb(skb);
88081 return NET_RX_DROP;
88082 }
88083 @@ -407,7 +407,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
88084 struct raw6_sock *rp = raw6_sk(sk);
88085
88086 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
88087 - atomic_inc(&sk->sk_drops);
88088 + atomic_inc_unchecked(&sk->sk_drops);
88089 kfree_skb(skb);
88090 return NET_RX_DROP;
88091 }
88092 @@ -431,7 +431,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
88093
88094 if (inet->hdrincl) {
88095 if (skb_checksum_complete(skb)) {
88096 - atomic_inc(&sk->sk_drops);
88097 + atomic_inc_unchecked(&sk->sk_drops);
88098 kfree_skb(skb);
88099 return NET_RX_DROP;
88100 }
88101 @@ -604,7 +604,7 @@ out:
88102 return err;
88103 }
88104
88105 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
88106 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
88107 struct flowi6 *fl6, struct dst_entry **dstp,
88108 unsigned int flags)
88109 {
88110 @@ -916,12 +916,15 @@ do_confirm:
88111 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
88112 char __user *optval, int optlen)
88113 {
88114 + struct icmp6_filter filter;
88115 +
88116 switch (optname) {
88117 case ICMPV6_FILTER:
88118 if (optlen > sizeof(struct icmp6_filter))
88119 optlen = sizeof(struct icmp6_filter);
88120 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
88121 + if (copy_from_user(&filter, optval, optlen))
88122 return -EFAULT;
88123 + raw6_sk(sk)->filter = filter;
88124 return 0;
88125 default:
88126 return -ENOPROTOOPT;
88127 @@ -934,6 +937,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
88128 char __user *optval, int __user *optlen)
88129 {
88130 int len;
88131 + struct icmp6_filter filter;
88132
88133 switch (optname) {
88134 case ICMPV6_FILTER:
88135 @@ -945,7 +949,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
88136 len = sizeof(struct icmp6_filter);
88137 if (put_user(len, optlen))
88138 return -EFAULT;
88139 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
88140 + filter = raw6_sk(sk)->filter;
88141 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
88142 return -EFAULT;
88143 return 0;
88144 default:
88145 @@ -1253,7 +1258,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
88146 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
88147 0,
88148 sock_i_ino(sp),
88149 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
88150 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
88151 }
88152
88153 static int raw6_seq_show(struct seq_file *seq, void *v)
88154 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
88155 index d9ba8a2..f3f9e14 100644
88156 --- a/net/ipv6/reassembly.c
88157 +++ b/net/ipv6/reassembly.c
88158 @@ -608,12 +608,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
88159
88160 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88161 {
88162 - struct ctl_table *table;
88163 + ctl_table_no_const *table = NULL;
88164 struct ctl_table_header *hdr;
88165
88166 - table = ip6_frags_ns_ctl_table;
88167 if (!net_eq(net, &init_net)) {
88168 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88169 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88170 if (table == NULL)
88171 goto err_alloc;
88172
88173 @@ -624,9 +623,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88174 /* Don't export sysctls to unprivileged users */
88175 if (net->user_ns != &init_user_ns)
88176 table[0].procname = NULL;
88177 - }
88178 + hdr = register_net_sysctl(net, "net/ipv6", table);
88179 + } else
88180 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
88181
88182 - hdr = register_net_sysctl(net, "net/ipv6", table);
88183 if (hdr == NULL)
88184 goto err_reg;
88185
88186 @@ -634,8 +634,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88187 return 0;
88188
88189 err_reg:
88190 - if (!net_eq(net, &init_net))
88191 - kfree(table);
88192 + kfree(table);
88193 err_alloc:
88194 return -ENOMEM;
88195 }
88196 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
88197 index 5845613..3af8fc7 100644
88198 --- a/net/ipv6/route.c
88199 +++ b/net/ipv6/route.c
88200 @@ -2966,7 +2966,7 @@ ctl_table ipv6_route_table_template[] = {
88201
88202 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
88203 {
88204 - struct ctl_table *table;
88205 + ctl_table_no_const *table;
88206
88207 table = kmemdup(ipv6_route_table_template,
88208 sizeof(ipv6_route_table_template),
88209 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
88210 index cfba99b..20ca511 100644
88211 --- a/net/ipv6/sit.c
88212 +++ b/net/ipv6/sit.c
88213 @@ -72,7 +72,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
88214 static int ipip6_tunnel_init(struct net_device *dev);
88215 static void ipip6_tunnel_setup(struct net_device *dev);
88216 static void ipip6_dev_free(struct net_device *dev);
88217 -static struct rtnl_link_ops sit_link_ops __read_mostly;
88218 +static struct rtnl_link_ops sit_link_ops;
88219
88220 static int sit_net_id __read_mostly;
88221 struct sit_net {
88222 @@ -1463,7 +1463,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
88223 #endif
88224 };
88225
88226 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
88227 +static struct rtnl_link_ops sit_link_ops = {
88228 .kind = "sit",
88229 .maxtype = IFLA_IPTUN_MAX,
88230 .policy = ipip6_policy,
88231 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
88232 index e85c48b..b8268d3 100644
88233 --- a/net/ipv6/sysctl_net_ipv6.c
88234 +++ b/net/ipv6/sysctl_net_ipv6.c
88235 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
88236
88237 static int __net_init ipv6_sysctl_net_init(struct net *net)
88238 {
88239 - struct ctl_table *ipv6_table;
88240 + ctl_table_no_const *ipv6_table;
88241 struct ctl_table *ipv6_route_table;
88242 struct ctl_table *ipv6_icmp_table;
88243 int err;
88244 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
88245 index 8d19346..f122ba5 100644
88246 --- a/net/ipv6/tcp_ipv6.c
88247 +++ b/net/ipv6/tcp_ipv6.c
88248 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
88249 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
88250 }
88251
88252 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88253 +extern int grsec_enable_blackhole;
88254 +#endif
88255 +
88256 static void tcp_v6_hash(struct sock *sk)
88257 {
88258 if (sk->sk_state != TCP_CLOSE) {
88259 @@ -386,6 +390,7 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
88260
88261 if (dst)
88262 dst->ops->redirect(dst, sk, skb);
88263 + goto out;
88264 }
88265
88266 if (type == ICMPV6_PKT_TOOBIG) {
88267 @@ -1440,6 +1445,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
88268 return 0;
88269
88270 reset:
88271 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88272 + if (!grsec_enable_blackhole)
88273 +#endif
88274 tcp_v6_send_reset(sk, skb);
88275 discard:
88276 if (opt_skb)
88277 @@ -1521,12 +1529,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
88278 TCP_SKB_CB(skb)->sacked = 0;
88279
88280 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
88281 - if (!sk)
88282 + if (!sk) {
88283 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88284 + ret = 1;
88285 +#endif
88286 goto no_tcp_socket;
88287 + }
88288
88289 process:
88290 - if (sk->sk_state == TCP_TIME_WAIT)
88291 + if (sk->sk_state == TCP_TIME_WAIT) {
88292 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88293 + ret = 2;
88294 +#endif
88295 goto do_time_wait;
88296 + }
88297
88298 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
88299 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
88300 @@ -1575,6 +1591,10 @@ no_tcp_socket:
88301 bad_packet:
88302 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
88303 } else {
88304 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88305 + if (!grsec_enable_blackhole || (ret == 1 &&
88306 + (skb->dev->flags & IFF_LOOPBACK)))
88307 +#endif
88308 tcp_v6_send_reset(NULL, skb);
88309 }
88310
88311 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
88312 index fb08329..2d6919e 100644
88313 --- a/net/ipv6/udp.c
88314 +++ b/net/ipv6/udp.c
88315 @@ -51,6 +51,10 @@
88316 #include <trace/events/skb.h>
88317 #include "udp_impl.h"
88318
88319 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88320 +extern int grsec_enable_blackhole;
88321 +#endif
88322 +
88323 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
88324 {
88325 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
88326 @@ -395,7 +399,7 @@ try_again:
88327 if (unlikely(err)) {
88328 trace_kfree_skb(skb, udpv6_recvmsg);
88329 if (!peeked) {
88330 - atomic_inc(&sk->sk_drops);
88331 + atomic_inc_unchecked(&sk->sk_drops);
88332 if (is_udp4)
88333 UDP_INC_STATS_USER(sock_net(sk),
88334 UDP_MIB_INERRORS,
88335 @@ -633,7 +637,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
88336 return rc;
88337 drop:
88338 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
88339 - atomic_inc(&sk->sk_drops);
88340 + atomic_inc_unchecked(&sk->sk_drops);
88341 kfree_skb(skb);
88342 return -1;
88343 }
88344 @@ -691,7 +695,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
88345 if (likely(skb1 == NULL))
88346 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
88347 if (!skb1) {
88348 - atomic_inc(&sk->sk_drops);
88349 + atomic_inc_unchecked(&sk->sk_drops);
88350 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
88351 IS_UDPLITE(sk));
88352 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
88353 @@ -862,6 +866,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
88354 goto discard;
88355
88356 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
88357 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88358 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
88359 +#endif
88360 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
88361
88362 kfree_skb(skb);
88363 @@ -1379,7 +1386,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
88364 0,
88365 sock_i_ino(sp),
88366 atomic_read(&sp->sk_refcnt), sp,
88367 - atomic_read(&sp->sk_drops));
88368 + atomic_read_unchecked(&sp->sk_drops));
88369 }
88370
88371 int udp6_seq_show(struct seq_file *seq, void *v)
88372 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
88373 index a68c88c..d55b0c5 100644
88374 --- a/net/irda/ircomm/ircomm_tty.c
88375 +++ b/net/irda/ircomm/ircomm_tty.c
88376 @@ -312,12 +312,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88377 add_wait_queue(&port->open_wait, &wait);
88378
88379 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
88380 - __FILE__, __LINE__, tty->driver->name, port->count);
88381 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88382
88383 spin_lock_irqsave(&port->lock, flags);
88384 if (!tty_hung_up_p(filp)) {
88385 extra_count = 1;
88386 - port->count--;
88387 + atomic_dec(&port->count);
88388 }
88389 spin_unlock_irqrestore(&port->lock, flags);
88390 port->blocked_open++;
88391 @@ -353,7 +353,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88392 }
88393
88394 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
88395 - __FILE__, __LINE__, tty->driver->name, port->count);
88396 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88397
88398 schedule();
88399 }
88400 @@ -364,13 +364,13 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88401 if (extra_count) {
88402 /* ++ is not atomic, so this should be protected - Jean II */
88403 spin_lock_irqsave(&port->lock, flags);
88404 - port->count++;
88405 + atomic_inc(&port->count);
88406 spin_unlock_irqrestore(&port->lock, flags);
88407 }
88408 port->blocked_open--;
88409
88410 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
88411 - __FILE__, __LINE__, tty->driver->name, port->count);
88412 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88413
88414 if (!retval)
88415 port->flags |= ASYNC_NORMAL_ACTIVE;
88416 @@ -444,12 +444,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
88417
88418 /* ++ is not atomic, so this should be protected - Jean II */
88419 spin_lock_irqsave(&self->port.lock, flags);
88420 - self->port.count++;
88421 + atomic_inc(&self->port.count);
88422 spin_unlock_irqrestore(&self->port.lock, flags);
88423 tty_port_tty_set(&self->port, tty);
88424
88425 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
88426 - self->line, self->port.count);
88427 + self->line, atomic_read(&self->port.count));
88428
88429 /* Not really used by us, but lets do it anyway */
88430 tty->low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
88431 @@ -986,7 +986,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
88432 tty_kref_put(port->tty);
88433 }
88434 port->tty = NULL;
88435 - port->count = 0;
88436 + atomic_set(&port->count, 0);
88437 spin_unlock_irqrestore(&port->lock, flags);
88438
88439 wake_up_interruptible(&port->open_wait);
88440 @@ -1343,7 +1343,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
88441 seq_putc(m, '\n');
88442
88443 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
88444 - seq_printf(m, "Open count: %d\n", self->port.count);
88445 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
88446 seq_printf(m, "Max data size: %d\n", self->max_data_size);
88447 seq_printf(m, "Max header size: %d\n", self->max_header_size);
88448
88449 diff --git a/net/irda/iriap.c b/net/irda/iriap.c
88450 index e71e85b..29340a9 100644
88451 --- a/net/irda/iriap.c
88452 +++ b/net/irda/iriap.c
88453 @@ -495,8 +495,11 @@ static void iriap_getvaluebyclass_confirm(struct iriap_cb *self,
88454 /* case CS_ISO_8859_9: */
88455 /* case CS_UNICODE: */
88456 default:
88457 - IRDA_DEBUG(0, "%s(), charset %s, not supported\n",
88458 - __func__, ias_charset_types[charset]);
88459 + IRDA_DEBUG(0, "%s(), charset [%d] %s, not supported\n",
88460 + __func__, charset,
88461 + charset < ARRAY_SIZE(ias_charset_types) ?
88462 + ias_charset_types[charset] :
88463 + "(unknown)");
88464
88465 /* Aborting, close connection! */
88466 iriap_disconnect_request(self);
88467 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
88468 index cd6f7a9..e63fe89 100644
88469 --- a/net/iucv/af_iucv.c
88470 +++ b/net/iucv/af_iucv.c
88471 @@ -782,10 +782,10 @@ static int iucv_sock_autobind(struct sock *sk)
88472
88473 write_lock_bh(&iucv_sk_list.lock);
88474
88475 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
88476 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88477 while (__iucv_get_sock_by_name(name)) {
88478 sprintf(name, "%08x",
88479 - atomic_inc_return(&iucv_sk_list.autobind_name));
88480 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88481 }
88482
88483 write_unlock_bh(&iucv_sk_list.lock);
88484 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
88485 index df08250..02021fe 100644
88486 --- a/net/iucv/iucv.c
88487 +++ b/net/iucv/iucv.c
88488 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
88489 return NOTIFY_OK;
88490 }
88491
88492 -static struct notifier_block __refdata iucv_cpu_notifier = {
88493 +static struct notifier_block iucv_cpu_notifier = {
88494 .notifier_call = iucv_cpu_notify,
88495 };
88496
88497 diff --git a/net/key/af_key.c b/net/key/af_key.c
88498 index 5b426a6..970032b 100644
88499 --- a/net/key/af_key.c
88500 +++ b/net/key/af_key.c
88501 @@ -3019,10 +3019,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
88502 static u32 get_acqseq(void)
88503 {
88504 u32 res;
88505 - static atomic_t acqseq;
88506 + static atomic_unchecked_t acqseq;
88507
88508 do {
88509 - res = atomic_inc_return(&acqseq);
88510 + res = atomic_inc_return_unchecked(&acqseq);
88511 } while (!res);
88512 return res;
88513 }
88514 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
88515 index 0479c64..9e72ff4 100644
88516 --- a/net/mac80211/cfg.c
88517 +++ b/net/mac80211/cfg.c
88518 @@ -790,7 +790,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
88519 ret = ieee80211_vif_use_channel(sdata, chandef,
88520 IEEE80211_CHANCTX_EXCLUSIVE);
88521 }
88522 - } else if (local->open_count == local->monitors) {
88523 + } else if (local_read(&local->open_count) == local->monitors) {
88524 local->_oper_channel = chandef->chan;
88525 local->_oper_channel_type = cfg80211_get_chandef_type(chandef);
88526 ieee80211_hw_config(local, 0);
88527 @@ -2499,7 +2499,7 @@ static int ieee80211_cancel_roc(struct ieee80211_local *local,
88528 list_del(&dep->list);
88529 mutex_unlock(&local->mtx);
88530
88531 - ieee80211_roc_notify_destroy(dep);
88532 + ieee80211_roc_notify_destroy(dep, true);
88533 return 0;
88534 }
88535
88536 @@ -2539,7 +2539,7 @@ static int ieee80211_cancel_roc(struct ieee80211_local *local,
88537 ieee80211_start_next_roc(local);
88538 mutex_unlock(&local->mtx);
88539
88540 - ieee80211_roc_notify_destroy(found);
88541 + ieee80211_roc_notify_destroy(found, true);
88542 } else {
88543 /* work may be pending so use it all the time */
88544 found->abort = true;
88545 @@ -2549,6 +2549,8 @@ static int ieee80211_cancel_roc(struct ieee80211_local *local,
88546
88547 /* work will clean up etc */
88548 flush_delayed_work(&found->work);
88549 + WARN_ON(!found->to_be_freed);
88550 + kfree(found);
88551 }
88552
88553 return 0;
88554 @@ -2716,7 +2718,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
88555 else
88556 local->probe_req_reg--;
88557
88558 - if (!local->open_count)
88559 + if (!local_read(&local->open_count))
88560 break;
88561
88562 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
88563 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
88564 index 2ed065c..bec0c2b 100644
88565 --- a/net/mac80211/ieee80211_i.h
88566 +++ b/net/mac80211/ieee80211_i.h
88567 @@ -28,6 +28,7 @@
88568 #include <net/ieee80211_radiotap.h>
88569 #include <net/cfg80211.h>
88570 #include <net/mac80211.h>
88571 +#include <asm/local.h>
88572 #include "key.h"
88573 #include "sta_info.h"
88574 #include "debug.h"
88575 @@ -346,6 +347,7 @@ struct ieee80211_roc_work {
88576 struct ieee80211_channel *chan;
88577
88578 bool started, abort, hw_begun, notified;
88579 + bool to_be_freed;
88580
88581 unsigned long hw_start_time;
88582
88583 @@ -909,7 +911,7 @@ struct ieee80211_local {
88584 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
88585 spinlock_t queue_stop_reason_lock;
88586
88587 - int open_count;
88588 + local_t open_count;
88589 int monitors, cooked_mntrs;
88590 /* number of interfaces with corresponding FIF_ flags */
88591 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
88592 @@ -1363,7 +1365,7 @@ void ieee80211_offchannel_return(struct ieee80211_local *local);
88593 void ieee80211_roc_setup(struct ieee80211_local *local);
88594 void ieee80211_start_next_roc(struct ieee80211_local *local);
88595 void ieee80211_roc_purge(struct ieee80211_sub_if_data *sdata);
88596 -void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc);
88597 +void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc, bool free);
88598 void ieee80211_sw_roc_work(struct work_struct *work);
88599 void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc);
88600
88601 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
88602 index 8be854e..ad72a69 100644
88603 --- a/net/mac80211/iface.c
88604 +++ b/net/mac80211/iface.c
88605 @@ -546,7 +546,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88606 break;
88607 }
88608
88609 - if (local->open_count == 0) {
88610 + if (local_read(&local->open_count) == 0) {
88611 res = drv_start(local);
88612 if (res)
88613 goto err_del_bss;
88614 @@ -591,7 +591,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88615 break;
88616 }
88617
88618 - if (local->monitors == 0 && local->open_count == 0) {
88619 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
88620 res = ieee80211_add_virtual_monitor(local);
88621 if (res)
88622 goto err_stop;
88623 @@ -699,7 +699,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88624 mutex_unlock(&local->mtx);
88625
88626 if (coming_up)
88627 - local->open_count++;
88628 + local_inc(&local->open_count);
88629
88630 if (hw_reconf_flags)
88631 ieee80211_hw_config(local, hw_reconf_flags);
88632 @@ -713,7 +713,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88633 err_del_interface:
88634 drv_remove_interface(local, sdata);
88635 err_stop:
88636 - if (!local->open_count)
88637 + if (!local_read(&local->open_count))
88638 drv_stop(local);
88639 err_del_bss:
88640 sdata->bss = NULL;
88641 @@ -827,7 +827,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88642 }
88643
88644 if (going_down)
88645 - local->open_count--;
88646 + local_dec(&local->open_count);
88647
88648 switch (sdata->vif.type) {
88649 case NL80211_IFTYPE_AP_VLAN:
88650 @@ -884,7 +884,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88651
88652 ieee80211_recalc_ps(local, -1);
88653
88654 - if (local->open_count == 0) {
88655 + if (local_read(&local->open_count) == 0) {
88656 if (local->ops->napi_poll)
88657 napi_disable(&local->napi);
88658 ieee80211_clear_tx_pending(local);
88659 @@ -910,7 +910,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88660 }
88661 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
88662
88663 - if (local->monitors == local->open_count && local->monitors > 0)
88664 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
88665 ieee80211_add_virtual_monitor(local);
88666 }
88667
88668 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
88669 index 1b087ff..bf600e9 100644
88670 --- a/net/mac80211/main.c
88671 +++ b/net/mac80211/main.c
88672 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
88673 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
88674 IEEE80211_CONF_CHANGE_POWER);
88675
88676 - if (changed && local->open_count) {
88677 + if (changed && local_read(&local->open_count)) {
88678 ret = drv_config(local, changed);
88679 /*
88680 * Goal:
88681 diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c
88682 index a3ad4c3..7acbdaa 100644
88683 --- a/net/mac80211/offchannel.c
88684 +++ b/net/mac80211/offchannel.c
88685 @@ -299,10 +299,13 @@ void ieee80211_start_next_roc(struct ieee80211_local *local)
88686 }
88687 }
88688
88689 -void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc)
88690 +void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc, bool free)
88691 {
88692 struct ieee80211_roc_work *dep, *tmp;
88693
88694 + if (WARN_ON(roc->to_be_freed))
88695 + return;
88696 +
88697 /* was never transmitted */
88698 if (roc->frame) {
88699 cfg80211_mgmt_tx_status(&roc->sdata->wdev,
88700 @@ -318,9 +321,12 @@ void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc)
88701 GFP_KERNEL);
88702
88703 list_for_each_entry_safe(dep, tmp, &roc->dependents, list)
88704 - ieee80211_roc_notify_destroy(dep);
88705 + ieee80211_roc_notify_destroy(dep, true);
88706
88707 - kfree(roc);
88708 + if (free)
88709 + kfree(roc);
88710 + else
88711 + roc->to_be_freed = true;
88712 }
88713
88714 void ieee80211_sw_roc_work(struct work_struct *work)
88715 @@ -333,6 +339,9 @@ void ieee80211_sw_roc_work(struct work_struct *work)
88716
88717 mutex_lock(&local->mtx);
88718
88719 + if (roc->to_be_freed)
88720 + goto out_unlock;
88721 +
88722 if (roc->abort)
88723 goto finish;
88724
88725 @@ -372,7 +381,7 @@ void ieee80211_sw_roc_work(struct work_struct *work)
88726 finish:
88727 list_del(&roc->list);
88728 started = roc->started;
88729 - ieee80211_roc_notify_destroy(roc);
88730 + ieee80211_roc_notify_destroy(roc, !roc->abort);
88731
88732 if (started) {
88733 drv_flush(local, false);
88734 @@ -412,7 +421,7 @@ static void ieee80211_hw_roc_done(struct work_struct *work)
88735
88736 list_del(&roc->list);
88737
88738 - ieee80211_roc_notify_destroy(roc);
88739 + ieee80211_roc_notify_destroy(roc, true);
88740
88741 /* if there's another roc, start it now */
88742 ieee80211_start_next_roc(local);
88743 @@ -462,12 +471,14 @@ void ieee80211_roc_purge(struct ieee80211_sub_if_data *sdata)
88744 list_for_each_entry_safe(roc, tmp, &tmp_list, list) {
88745 if (local->ops->remain_on_channel) {
88746 list_del(&roc->list);
88747 - ieee80211_roc_notify_destroy(roc);
88748 + ieee80211_roc_notify_destroy(roc, true);
88749 } else {
88750 ieee80211_queue_delayed_work(&local->hw, &roc->work, 0);
88751
88752 /* work will clean up etc */
88753 flush_delayed_work(&roc->work);
88754 + WARN_ON(!roc->to_be_freed);
88755 + kfree(roc);
88756 }
88757 }
88758
88759 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
88760 index 79a48f3..5e185c9 100644
88761 --- a/net/mac80211/pm.c
88762 +++ b/net/mac80211/pm.c
88763 @@ -35,7 +35,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88764 struct sta_info *sta;
88765 struct ieee80211_chanctx *ctx;
88766
88767 - if (!local->open_count)
88768 + if (!local_read(&local->open_count))
88769 goto suspend;
88770
88771 ieee80211_scan_cancel(local);
88772 @@ -73,7 +73,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88773 cancel_work_sync(&local->dynamic_ps_enable_work);
88774 del_timer_sync(&local->dynamic_ps_timer);
88775
88776 - local->wowlan = wowlan && local->open_count;
88777 + local->wowlan = wowlan && local_read(&local->open_count);
88778 if (local->wowlan) {
88779 int err = drv_suspend(local, wowlan);
88780 if (err < 0) {
88781 @@ -187,7 +187,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88782 mutex_unlock(&local->chanctx_mtx);
88783
88784 /* stop hardware - this must stop RX */
88785 - if (local->open_count)
88786 + if (local_read(&local->open_count))
88787 ieee80211_stop_device(local);
88788
88789 suspend:
88790 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
88791 index dd88381..eef4dd6 100644
88792 --- a/net/mac80211/rate.c
88793 +++ b/net/mac80211/rate.c
88794 @@ -493,7 +493,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
88795
88796 ASSERT_RTNL();
88797
88798 - if (local->open_count)
88799 + if (local_read(&local->open_count))
88800 return -EBUSY;
88801
88802 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
88803 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
88804 index c97a065..ff61928 100644
88805 --- a/net/mac80211/rc80211_pid_debugfs.c
88806 +++ b/net/mac80211/rc80211_pid_debugfs.c
88807 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
88808
88809 spin_unlock_irqrestore(&events->lock, status);
88810
88811 - if (copy_to_user(buf, pb, p))
88812 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
88813 return -EFAULT;
88814
88815 return p;
88816 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
88817 index f11e8c5..08d0013 100644
88818 --- a/net/mac80211/util.c
88819 +++ b/net/mac80211/util.c
88820 @@ -1380,7 +1380,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
88821 }
88822 #endif
88823 /* everything else happens only if HW was up & running */
88824 - if (!local->open_count)
88825 + if (!local_read(&local->open_count))
88826 goto wake_up;
88827
88828 /*
88829 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
88830 index 49e96df..63a51c3 100644
88831 --- a/net/netfilter/Kconfig
88832 +++ b/net/netfilter/Kconfig
88833 @@ -936,6 +936,16 @@ config NETFILTER_XT_MATCH_ESP
88834
88835 To compile it as a module, choose M here. If unsure, say N.
88836
88837 +config NETFILTER_XT_MATCH_GRADM
88838 + tristate '"gradm" match support'
88839 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
88840 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
88841 + ---help---
88842 + The gradm match allows to match on grsecurity RBAC being enabled.
88843 + It is useful when iptables rules are applied early on bootup to
88844 + prevent connections to the machine (except from a trusted host)
88845 + while the RBAC system is disabled.
88846 +
88847 config NETFILTER_XT_MATCH_HASHLIMIT
88848 tristate '"hashlimit" match support'
88849 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
88850 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
88851 index 3259697..54d5393 100644
88852 --- a/net/netfilter/Makefile
88853 +++ b/net/netfilter/Makefile
88854 @@ -109,6 +109,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
88855 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
88856 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
88857 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
88858 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
88859 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
88860 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
88861 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
88862 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
88863 index 6d6d8f2..a676749 100644
88864 --- a/net/netfilter/ipset/ip_set_core.c
88865 +++ b/net/netfilter/ipset/ip_set_core.c
88866 @@ -1800,7 +1800,7 @@ done:
88867 return ret;
88868 }
88869
88870 -static struct nf_sockopt_ops so_set __read_mostly = {
88871 +static struct nf_sockopt_ops so_set = {
88872 .pf = PF_INET,
88873 .get_optmin = SO_IP_SET,
88874 .get_optmax = SO_IP_SET + 1,
88875 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
88876 index 30e764a..c3b6a9d 100644
88877 --- a/net/netfilter/ipvs/ip_vs_conn.c
88878 +++ b/net/netfilter/ipvs/ip_vs_conn.c
88879 @@ -554,7 +554,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
88880 /* Increase the refcnt counter of the dest */
88881 atomic_inc(&dest->refcnt);
88882
88883 - conn_flags = atomic_read(&dest->conn_flags);
88884 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
88885 if (cp->protocol != IPPROTO_UDP)
88886 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
88887 flags = cp->flags;
88888 @@ -899,7 +899,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
88889 atomic_set(&cp->refcnt, 1);
88890
88891 atomic_set(&cp->n_control, 0);
88892 - atomic_set(&cp->in_pkts, 0);
88893 + atomic_set_unchecked(&cp->in_pkts, 0);
88894
88895 atomic_inc(&ipvs->conn_count);
88896 if (flags & IP_VS_CONN_F_NO_CPORT)
88897 @@ -1180,7 +1180,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
88898
88899 /* Don't drop the entry if its number of incoming packets is not
88900 located in [0, 8] */
88901 - i = atomic_read(&cp->in_pkts);
88902 + i = atomic_read_unchecked(&cp->in_pkts);
88903 if (i > 8 || i < 0) return 0;
88904
88905 if (!todrop_rate[i]) return 0;
88906 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
88907 index 47edf5a..235b07d 100644
88908 --- a/net/netfilter/ipvs/ip_vs_core.c
88909 +++ b/net/netfilter/ipvs/ip_vs_core.c
88910 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
88911 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
88912 /* do not touch skb anymore */
88913
88914 - atomic_inc(&cp->in_pkts);
88915 + atomic_inc_unchecked(&cp->in_pkts);
88916 ip_vs_conn_put(cp);
88917 return ret;
88918 }
88919 @@ -1691,7 +1691,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
88920 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
88921 pkts = sysctl_sync_threshold(ipvs);
88922 else
88923 - pkts = atomic_add_return(1, &cp->in_pkts);
88924 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88925
88926 if (ipvs->sync_state & IP_VS_STATE_MASTER)
88927 ip_vs_sync_conn(net, cp, pkts);
88928 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
88929 index ec664cb..7f34a77 100644
88930 --- a/net/netfilter/ipvs/ip_vs_ctl.c
88931 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
88932 @@ -787,7 +787,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
88933 ip_vs_rs_hash(ipvs, dest);
88934 write_unlock_bh(&ipvs->rs_lock);
88935 }
88936 - atomic_set(&dest->conn_flags, conn_flags);
88937 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
88938
88939 /* bind the service */
88940 if (!dest->svc) {
88941 @@ -1688,7 +1688,7 @@ proc_do_sync_ports(ctl_table *table, int write,
88942 * align with netns init in ip_vs_control_net_init()
88943 */
88944
88945 -static struct ctl_table vs_vars[] = {
88946 +static ctl_table_no_const vs_vars[] __read_only = {
88947 {
88948 .procname = "amemthresh",
88949 .maxlen = sizeof(int),
88950 @@ -2081,7 +2081,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88951 " %-7s %-6d %-10d %-10d\n",
88952 &dest->addr.in6,
88953 ntohs(dest->port),
88954 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88955 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88956 atomic_read(&dest->weight),
88957 atomic_read(&dest->activeconns),
88958 atomic_read(&dest->inactconns));
88959 @@ -2092,7 +2092,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88960 "%-7s %-6d %-10d %-10d\n",
88961 ntohl(dest->addr.ip),
88962 ntohs(dest->port),
88963 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88964 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88965 atomic_read(&dest->weight),
88966 atomic_read(&dest->activeconns),
88967 atomic_read(&dest->inactconns));
88968 @@ -2562,7 +2562,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
88969
88970 entry.addr = dest->addr.ip;
88971 entry.port = dest->port;
88972 - entry.conn_flags = atomic_read(&dest->conn_flags);
88973 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
88974 entry.weight = atomic_read(&dest->weight);
88975 entry.u_threshold = dest->u_threshold;
88976 entry.l_threshold = dest->l_threshold;
88977 @@ -3098,7 +3098,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
88978 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
88979 nla_put_u16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
88980 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
88981 - (atomic_read(&dest->conn_flags) &
88982 + (atomic_read_unchecked(&dest->conn_flags) &
88983 IP_VS_CONN_F_FWD_MASK)) ||
88984 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
88985 atomic_read(&dest->weight)) ||
88986 @@ -3688,7 +3688,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
88987 {
88988 int idx;
88989 struct netns_ipvs *ipvs = net_ipvs(net);
88990 - struct ctl_table *tbl;
88991 + ctl_table_no_const *tbl;
88992
88993 atomic_set(&ipvs->dropentry, 0);
88994 spin_lock_init(&ipvs->dropentry_lock);
88995 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
88996 index fdd89b9..bd96aa9 100644
88997 --- a/net/netfilter/ipvs/ip_vs_lblc.c
88998 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
88999 @@ -115,7 +115,7 @@ struct ip_vs_lblc_table {
89000 * IPVS LBLC sysctl table
89001 */
89002 #ifdef CONFIG_SYSCTL
89003 -static ctl_table vs_vars_table[] = {
89004 +static ctl_table_no_const vs_vars_table[] __read_only = {
89005 {
89006 .procname = "lblc_expiration",
89007 .data = NULL,
89008 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
89009 index c03b6a3..8ce3681 100644
89010 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
89011 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
89012 @@ -288,7 +288,7 @@ struct ip_vs_lblcr_table {
89013 * IPVS LBLCR sysctl table
89014 */
89015
89016 -static ctl_table vs_vars_table[] = {
89017 +static ctl_table_no_const vs_vars_table[] __read_only = {
89018 {
89019 .procname = "lblcr_expiration",
89020 .data = NULL,
89021 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
89022 index 44fd10c..2a163b3 100644
89023 --- a/net/netfilter/ipvs/ip_vs_sync.c
89024 +++ b/net/netfilter/ipvs/ip_vs_sync.c
89025 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
89026 cp = cp->control;
89027 if (cp) {
89028 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
89029 - pkts = atomic_add_return(1, &cp->in_pkts);
89030 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
89031 else
89032 pkts = sysctl_sync_threshold(ipvs);
89033 ip_vs_sync_conn(net, cp->control, pkts);
89034 @@ -758,7 +758,7 @@ control:
89035 if (!cp)
89036 return;
89037 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
89038 - pkts = atomic_add_return(1, &cp->in_pkts);
89039 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
89040 else
89041 pkts = sysctl_sync_threshold(ipvs);
89042 goto sloop;
89043 @@ -885,7 +885,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
89044
89045 if (opt)
89046 memcpy(&cp->in_seq, opt, sizeof(*opt));
89047 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
89048 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
89049 cp->state = state;
89050 cp->old_state = cp->state;
89051 /*
89052 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
89053 index ee6b7a9..f9a89f6 100644
89054 --- a/net/netfilter/ipvs/ip_vs_xmit.c
89055 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
89056 @@ -1210,7 +1210,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
89057 else
89058 rc = NF_ACCEPT;
89059 /* do not touch skb anymore */
89060 - atomic_inc(&cp->in_pkts);
89061 + atomic_inc_unchecked(&cp->in_pkts);
89062 goto out;
89063 }
89064
89065 @@ -1332,7 +1332,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
89066 else
89067 rc = NF_ACCEPT;
89068 /* do not touch skb anymore */
89069 - atomic_inc(&cp->in_pkts);
89070 + atomic_inc_unchecked(&cp->in_pkts);
89071 goto out;
89072 }
89073
89074 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
89075 index 7df424e..a527b02 100644
89076 --- a/net/netfilter/nf_conntrack_acct.c
89077 +++ b/net/netfilter/nf_conntrack_acct.c
89078 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
89079 #ifdef CONFIG_SYSCTL
89080 static int nf_conntrack_acct_init_sysctl(struct net *net)
89081 {
89082 - struct ctl_table *table;
89083 + ctl_table_no_const *table;
89084
89085 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
89086 GFP_KERNEL);
89087 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
89088 index e4a0c4f..c263f28 100644
89089 --- a/net/netfilter/nf_conntrack_core.c
89090 +++ b/net/netfilter/nf_conntrack_core.c
89091 @@ -1529,6 +1529,10 @@ err_extend:
89092 #define DYING_NULLS_VAL ((1<<30)+1)
89093 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
89094
89095 +#ifdef CONFIG_GRKERNSEC_HIDESYM
89096 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
89097 +#endif
89098 +
89099 static int nf_conntrack_init_net(struct net *net)
89100 {
89101 int ret;
89102 @@ -1543,7 +1547,11 @@ static int nf_conntrack_init_net(struct net *net)
89103 goto err_stat;
89104 }
89105
89106 +#ifdef CONFIG_GRKERNSEC_HIDESYM
89107 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
89108 +#else
89109 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
89110 +#endif
89111 if (!net->ct.slabname) {
89112 ret = -ENOMEM;
89113 goto err_slabname;
89114 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
89115 index faa978f..1afb18f 100644
89116 --- a/net/netfilter/nf_conntrack_ecache.c
89117 +++ b/net/netfilter/nf_conntrack_ecache.c
89118 @@ -186,7 +186,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
89119 #ifdef CONFIG_SYSCTL
89120 static int nf_conntrack_event_init_sysctl(struct net *net)
89121 {
89122 - struct ctl_table *table;
89123 + ctl_table_no_const *table;
89124
89125 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
89126 GFP_KERNEL);
89127 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
89128 index 884f2b3..d53b33a 100644
89129 --- a/net/netfilter/nf_conntrack_helper.c
89130 +++ b/net/netfilter/nf_conntrack_helper.c
89131 @@ -55,7 +55,7 @@ static struct ctl_table helper_sysctl_table[] = {
89132
89133 static int nf_conntrack_helper_init_sysctl(struct net *net)
89134 {
89135 - struct ctl_table *table;
89136 + ctl_table_no_const *table;
89137
89138 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
89139 GFP_KERNEL);
89140 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
89141 index 51e928d..72a413a 100644
89142 --- a/net/netfilter/nf_conntrack_proto.c
89143 +++ b/net/netfilter/nf_conntrack_proto.c
89144 @@ -51,7 +51,7 @@ nf_ct_register_sysctl(struct net *net,
89145
89146 static void
89147 nf_ct_unregister_sysctl(struct ctl_table_header **header,
89148 - struct ctl_table **table,
89149 + ctl_table_no_const **table,
89150 unsigned int users)
89151 {
89152 if (users > 0)
89153 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
89154 index e7185c6..4ad6c9c 100644
89155 --- a/net/netfilter/nf_conntrack_standalone.c
89156 +++ b/net/netfilter/nf_conntrack_standalone.c
89157 @@ -470,7 +470,7 @@ static ctl_table nf_ct_netfilter_table[] = {
89158
89159 static int nf_conntrack_standalone_init_sysctl(struct net *net)
89160 {
89161 - struct ctl_table *table;
89162 + ctl_table_no_const *table;
89163
89164 if (net_eq(net, &init_net)) {
89165 nf_ct_netfilter_header =
89166 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
89167 index 7ea8026..bc9512d 100644
89168 --- a/net/netfilter/nf_conntrack_timestamp.c
89169 +++ b/net/netfilter/nf_conntrack_timestamp.c
89170 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
89171 #ifdef CONFIG_SYSCTL
89172 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
89173 {
89174 - struct ctl_table *table;
89175 + ctl_table_no_const *table;
89176
89177 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
89178 GFP_KERNEL);
89179 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
89180 index 9e31269..bc4c1b7 100644
89181 --- a/net/netfilter/nf_log.c
89182 +++ b/net/netfilter/nf_log.c
89183 @@ -215,7 +215,7 @@ static const struct file_operations nflog_file_ops = {
89184
89185 #ifdef CONFIG_SYSCTL
89186 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
89187 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
89188 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
89189 static struct ctl_table_header *nf_log_dir_header;
89190
89191 static int nf_log_proc_dostring(ctl_table *table, int write,
89192 @@ -246,14 +246,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
89193 rcu_assign_pointer(nf_loggers[tindex], logger);
89194 mutex_unlock(&nf_log_mutex);
89195 } else {
89196 + ctl_table_no_const nf_log_table = *table;
89197 +
89198 mutex_lock(&nf_log_mutex);
89199 logger = rcu_dereference_protected(nf_loggers[tindex],
89200 lockdep_is_held(&nf_log_mutex));
89201 if (!logger)
89202 - table->data = "NONE";
89203 + nf_log_table.data = "NONE";
89204 else
89205 - table->data = logger->name;
89206 - r = proc_dostring(table, write, buffer, lenp, ppos);
89207 + nf_log_table.data = logger->name;
89208 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
89209 mutex_unlock(&nf_log_mutex);
89210 }
89211
89212 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
89213 index f042ae5..30ea486 100644
89214 --- a/net/netfilter/nf_sockopt.c
89215 +++ b/net/netfilter/nf_sockopt.c
89216 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
89217 }
89218 }
89219
89220 - list_add(&reg->list, &nf_sockopts);
89221 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
89222 out:
89223 mutex_unlock(&nf_sockopt_mutex);
89224 return ret;
89225 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
89226 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
89227 {
89228 mutex_lock(&nf_sockopt_mutex);
89229 - list_del(&reg->list);
89230 + pax_list_del((struct list_head *)&reg->list);
89231 mutex_unlock(&nf_sockopt_mutex);
89232 }
89233 EXPORT_SYMBOL(nf_unregister_sockopt);
89234 diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c
89235 index 589d686..dc3fd5d 100644
89236 --- a/net/netfilter/nfnetlink_acct.c
89237 +++ b/net/netfilter/nfnetlink_acct.c
89238 @@ -49,6 +49,8 @@ nfnl_acct_new(struct sock *nfnl, struct sk_buff *skb,
89239 return -EINVAL;
89240
89241 acct_name = nla_data(tb[NFACCT_NAME]);
89242 + if (strlen(acct_name) == 0)
89243 + return -EINVAL;
89244
89245 list_for_each_entry(nfacct, &nfnl_acct_list, head) {
89246 if (strncmp(nfacct->name, acct_name, NFACCT_NAME_MAX) != 0)
89247 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
89248 index 92fd8ec..3f6ea4b 100644
89249 --- a/net/netfilter/nfnetlink_log.c
89250 +++ b/net/netfilter/nfnetlink_log.c
89251 @@ -72,7 +72,7 @@ struct nfulnl_instance {
89252 };
89253
89254 static DEFINE_SPINLOCK(instances_lock);
89255 -static atomic_t global_seq;
89256 +static atomic_unchecked_t global_seq;
89257
89258 #define INSTANCE_BUCKETS 16
89259 static struct hlist_head instance_table[INSTANCE_BUCKETS];
89260 @@ -537,7 +537,7 @@ __build_packet_message(struct nfulnl_instance *inst,
89261 /* global sequence number */
89262 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
89263 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
89264 - htonl(atomic_inc_return(&global_seq))))
89265 + htonl(atomic_inc_return_unchecked(&global_seq))))
89266 goto nla_put_failure;
89267
89268 if (data_len) {
89269 diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
89270 index 3158d87..39006c9 100644
89271 --- a/net/netfilter/nfnetlink_queue_core.c
89272 +++ b/net/netfilter/nfnetlink_queue_core.c
89273 @@ -1064,8 +1064,10 @@ static int __init nfnetlink_queue_init(void)
89274
89275 #ifdef CONFIG_PROC_FS
89276 if (!proc_create("nfnetlink_queue", 0440,
89277 - proc_net_netfilter, &nfqnl_file_ops))
89278 + proc_net_netfilter, &nfqnl_file_ops)) {
89279 + status = -ENOMEM;
89280 goto cleanup_subsys;
89281 + }
89282 #endif
89283
89284 register_netdevice_notifier(&nfqnl_dev_notifier);
89285 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
89286 new file mode 100644
89287 index 0000000..c566332
89288 --- /dev/null
89289 +++ b/net/netfilter/xt_gradm.c
89290 @@ -0,0 +1,51 @@
89291 +/*
89292 + * gradm match for netfilter
89293 + * Copyright © Zbigniew Krzystolik, 2010
89294 + *
89295 + * This program is free software; you can redistribute it and/or modify
89296 + * it under the terms of the GNU General Public License; either version
89297 + * 2 or 3 as published by the Free Software Foundation.
89298 + */
89299 +#include <linux/module.h>
89300 +#include <linux/moduleparam.h>
89301 +#include <linux/skbuff.h>
89302 +#include <linux/netfilter/x_tables.h>
89303 +#include <linux/grsecurity.h>
89304 +#include <linux/netfilter/xt_gradm.h>
89305 +
89306 +static bool
89307 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
89308 +{
89309 + const struct xt_gradm_mtinfo *info = par->matchinfo;
89310 + bool retval = false;
89311 + if (gr_acl_is_enabled())
89312 + retval = true;
89313 + return retval ^ info->invflags;
89314 +}
89315 +
89316 +static struct xt_match gradm_mt_reg __read_mostly = {
89317 + .name = "gradm",
89318 + .revision = 0,
89319 + .family = NFPROTO_UNSPEC,
89320 + .match = gradm_mt,
89321 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
89322 + .me = THIS_MODULE,
89323 +};
89324 +
89325 +static int __init gradm_mt_init(void)
89326 +{
89327 + return xt_register_match(&gradm_mt_reg);
89328 +}
89329 +
89330 +static void __exit gradm_mt_exit(void)
89331 +{
89332 + xt_unregister_match(&gradm_mt_reg);
89333 +}
89334 +
89335 +module_init(gradm_mt_init);
89336 +module_exit(gradm_mt_exit);
89337 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
89338 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
89339 +MODULE_LICENSE("GPL");
89340 +MODULE_ALIAS("ipt_gradm");
89341 +MODULE_ALIAS("ip6t_gradm");
89342 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
89343 index 4fe4fb4..87a89e5 100644
89344 --- a/net/netfilter/xt_statistic.c
89345 +++ b/net/netfilter/xt_statistic.c
89346 @@ -19,7 +19,7 @@
89347 #include <linux/module.h>
89348
89349 struct xt_statistic_priv {
89350 - atomic_t count;
89351 + atomic_unchecked_t count;
89352 } ____cacheline_aligned_in_smp;
89353
89354 MODULE_LICENSE("GPL");
89355 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
89356 break;
89357 case XT_STATISTIC_MODE_NTH:
89358 do {
89359 - oval = atomic_read(&info->master->count);
89360 + oval = atomic_read_unchecked(&info->master->count);
89361 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
89362 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
89363 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
89364 if (nval == 0)
89365 ret = !ret;
89366 break;
89367 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
89368 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
89369 if (info->master == NULL)
89370 return -ENOMEM;
89371 - atomic_set(&info->master->count, info->u.nth.count);
89372 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
89373
89374 return 0;
89375 }
89376 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
89377 index c0353d5..fcb0270 100644
89378 --- a/net/netlink/af_netlink.c
89379 +++ b/net/netlink/af_netlink.c
89380 @@ -785,7 +785,7 @@ static void netlink_overrun(struct sock *sk)
89381 sk->sk_error_report(sk);
89382 }
89383 }
89384 - atomic_inc(&sk->sk_drops);
89385 + atomic_inc_unchecked(&sk->sk_drops);
89386 }
89387
89388 static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
89389 @@ -2071,7 +2071,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
89390 sk_wmem_alloc_get(s),
89391 nlk->cb,
89392 atomic_read(&s->sk_refcnt),
89393 - atomic_read(&s->sk_drops),
89394 + atomic_read_unchecked(&s->sk_drops),
89395 sock_i_ino(s)
89396 );
89397
89398 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
89399 index 5a55be3..7630745 100644
89400 --- a/net/netlink/genetlink.c
89401 +++ b/net/netlink/genetlink.c
89402 @@ -296,18 +296,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
89403 goto errout;
89404 }
89405
89406 + pax_open_kernel();
89407 if (ops->dumpit)
89408 - ops->flags |= GENL_CMD_CAP_DUMP;
89409 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
89410 if (ops->doit)
89411 - ops->flags |= GENL_CMD_CAP_DO;
89412 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
89413 if (ops->policy)
89414 - ops->flags |= GENL_CMD_CAP_HASPOL;
89415 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
89416 + pax_close_kernel();
89417
89418 genl_lock();
89419 - list_add_tail(&ops->ops_list, &family->ops_list);
89420 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
89421 genl_unlock();
89422
89423 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
89424 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
89425 err = 0;
89426 errout:
89427 return err;
89428 @@ -337,9 +339,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
89429 genl_lock();
89430 list_for_each_entry(rc, &family->ops_list, ops_list) {
89431 if (rc == ops) {
89432 - list_del(&ops->ops_list);
89433 + pax_list_del((struct list_head *)&ops->ops_list);
89434 genl_unlock();
89435 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
89436 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
89437 return 0;
89438 }
89439 }
89440 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
89441 index 7261eb8..44e8ac6 100644
89442 --- a/net/netrom/af_netrom.c
89443 +++ b/net/netrom/af_netrom.c
89444 @@ -838,6 +838,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89445 struct sock *sk = sock->sk;
89446 struct nr_sock *nr = nr_sk(sk);
89447
89448 + memset(sax, 0, sizeof(*sax));
89449 lock_sock(sk);
89450 if (peer != 0) {
89451 if (sk->sk_state != TCP_ESTABLISHED) {
89452 @@ -852,7 +853,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89453 *uaddr_len = sizeof(struct full_sockaddr_ax25);
89454 } else {
89455 sax->fsa_ax25.sax25_family = AF_NETROM;
89456 - sax->fsa_ax25.sax25_ndigis = 0;
89457 sax->fsa_ax25.sax25_call = nr->source_addr;
89458 *uaddr_len = sizeof(struct sockaddr_ax25);
89459 }
89460 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
89461 index c111bd0..7788ff7 100644
89462 --- a/net/packet/af_packet.c
89463 +++ b/net/packet/af_packet.c
89464 @@ -1578,7 +1578,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89465
89466 spin_lock(&sk->sk_receive_queue.lock);
89467 po->stats.tp_packets++;
89468 - skb->dropcount = atomic_read(&sk->sk_drops);
89469 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
89470 __skb_queue_tail(&sk->sk_receive_queue, skb);
89471 spin_unlock(&sk->sk_receive_queue.lock);
89472 sk->sk_data_ready(sk, skb->len);
89473 @@ -1587,7 +1587,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89474 drop_n_acct:
89475 spin_lock(&sk->sk_receive_queue.lock);
89476 po->stats.tp_drops++;
89477 - atomic_inc(&sk->sk_drops);
89478 + atomic_inc_unchecked(&sk->sk_drops);
89479 spin_unlock(&sk->sk_receive_queue.lock);
89480
89481 drop_n_restore:
89482 @@ -2565,6 +2565,7 @@ out:
89483
89484 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89485 {
89486 + struct sock_extended_err ee;
89487 struct sock_exterr_skb *serr;
89488 struct sk_buff *skb, *skb2;
89489 int copied, err;
89490 @@ -2586,8 +2587,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89491 sock_recv_timestamp(msg, sk, skb);
89492
89493 serr = SKB_EXT_ERR(skb);
89494 + ee = serr->ee;
89495 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
89496 - sizeof(serr->ee), &serr->ee);
89497 + sizeof ee, &ee);
89498
89499 msg->msg_flags |= MSG_ERRQUEUE;
89500 err = copied;
89501 @@ -3212,7 +3214,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89502 case PACKET_HDRLEN:
89503 if (len > sizeof(int))
89504 len = sizeof(int);
89505 - if (copy_from_user(&val, optval, len))
89506 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
89507 return -EFAULT;
89508 switch (val) {
89509 case TPACKET_V1:
89510 @@ -3254,7 +3256,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89511 len = lv;
89512 if (put_user(len, optlen))
89513 return -EFAULT;
89514 - if (copy_to_user(optval, data, len))
89515 + if (len > sizeof(st) || copy_to_user(optval, data, len))
89516 return -EFAULT;
89517 return 0;
89518 }
89519 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
89520 index 5a940db..f0b9c12 100644
89521 --- a/net/phonet/af_phonet.c
89522 +++ b/net/phonet/af_phonet.c
89523 @@ -41,7 +41,7 @@ static struct phonet_protocol *phonet_proto_get(unsigned int protocol)
89524 {
89525 struct phonet_protocol *pp;
89526
89527 - if (protocol >= PHONET_NPROTO)
89528 + if (protocol < 0 || protocol >= PHONET_NPROTO)
89529 return NULL;
89530
89531 rcu_read_lock();
89532 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
89533 {
89534 int err = 0;
89535
89536 - if (protocol >= PHONET_NPROTO)
89537 + if (protocol < 0 || protocol >= PHONET_NPROTO)
89538 return -EINVAL;
89539
89540 err = proto_register(pp->prot, 1);
89541 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
89542 index 576f22c..bc7a71b 100644
89543 --- a/net/phonet/pep.c
89544 +++ b/net/phonet/pep.c
89545 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89546
89547 case PNS_PEP_CTRL_REQ:
89548 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
89549 - atomic_inc(&sk->sk_drops);
89550 + atomic_inc_unchecked(&sk->sk_drops);
89551 break;
89552 }
89553 __skb_pull(skb, 4);
89554 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89555 }
89556
89557 if (pn->rx_credits == 0) {
89558 - atomic_inc(&sk->sk_drops);
89559 + atomic_inc_unchecked(&sk->sk_drops);
89560 err = -ENOBUFS;
89561 break;
89562 }
89563 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
89564 }
89565
89566 if (pn->rx_credits == 0) {
89567 - atomic_inc(&sk->sk_drops);
89568 + atomic_inc_unchecked(&sk->sk_drops);
89569 err = NET_RX_DROP;
89570 break;
89571 }
89572 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
89573 index b7e9827..c264c85 100644
89574 --- a/net/phonet/socket.c
89575 +++ b/net/phonet/socket.c
89576 @@ -615,7 +615,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
89577 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
89578 sock_i_ino(sk),
89579 atomic_read(&sk->sk_refcnt), sk,
89580 - atomic_read(&sk->sk_drops), &len);
89581 + atomic_read_unchecked(&sk->sk_drops), &len);
89582 }
89583 seq_printf(seq, "%*s\n", 127 - len, "");
89584 return 0;
89585 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
89586 index d6bbbbd..61561e4 100644
89587 --- a/net/phonet/sysctl.c
89588 +++ b/net/phonet/sysctl.c
89589 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
89590 {
89591 int ret;
89592 int range[2] = {local_port_range[0], local_port_range[1]};
89593 - ctl_table tmp = {
89594 + ctl_table_no_const tmp = {
89595 .data = &range,
89596 .maxlen = sizeof(range),
89597 .mode = table->mode,
89598 diff --git a/net/rds/cong.c b/net/rds/cong.c
89599 index e5b65ac..f3b6fb7 100644
89600 --- a/net/rds/cong.c
89601 +++ b/net/rds/cong.c
89602 @@ -78,7 +78,7 @@
89603 * finds that the saved generation number is smaller than the global generation
89604 * number, it wakes up the process.
89605 */
89606 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
89607 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
89608
89609 /*
89610 * Congestion monitoring
89611 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
89612 rdsdebug("waking map %p for %pI4\n",
89613 map, &map->m_addr);
89614 rds_stats_inc(s_cong_update_received);
89615 - atomic_inc(&rds_cong_generation);
89616 + atomic_inc_unchecked(&rds_cong_generation);
89617 if (waitqueue_active(&map->m_waitq))
89618 wake_up(&map->m_waitq);
89619 if (waitqueue_active(&rds_poll_waitq))
89620 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
89621
89622 int rds_cong_updated_since(unsigned long *recent)
89623 {
89624 - unsigned long gen = atomic_read(&rds_cong_generation);
89625 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
89626
89627 if (likely(*recent == gen))
89628 return 0;
89629 diff --git a/net/rds/ib.h b/net/rds/ib.h
89630 index 7280ab8..e04f4ea 100644
89631 --- a/net/rds/ib.h
89632 +++ b/net/rds/ib.h
89633 @@ -128,7 +128,7 @@ struct rds_ib_connection {
89634 /* sending acks */
89635 unsigned long i_ack_flags;
89636 #ifdef KERNEL_HAS_ATOMIC64
89637 - atomic64_t i_ack_next; /* next ACK to send */
89638 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89639 #else
89640 spinlock_t i_ack_lock; /* protect i_ack_next */
89641 u64 i_ack_next; /* next ACK to send */
89642 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
89643 index 31b74f5..dc1fbfa 100644
89644 --- a/net/rds/ib_cm.c
89645 +++ b/net/rds/ib_cm.c
89646 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
89647 /* Clear the ACK state */
89648 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89649 #ifdef KERNEL_HAS_ATOMIC64
89650 - atomic64_set(&ic->i_ack_next, 0);
89651 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89652 #else
89653 ic->i_ack_next = 0;
89654 #endif
89655 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
89656 index 8eb9501..0c386ff 100644
89657 --- a/net/rds/ib_recv.c
89658 +++ b/net/rds/ib_recv.c
89659 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89660 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
89661 int ack_required)
89662 {
89663 - atomic64_set(&ic->i_ack_next, seq);
89664 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89665 if (ack_required) {
89666 smp_mb__before_clear_bit();
89667 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89668 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89669 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89670 smp_mb__after_clear_bit();
89671
89672 - return atomic64_read(&ic->i_ack_next);
89673 + return atomic64_read_unchecked(&ic->i_ack_next);
89674 }
89675 #endif
89676
89677 diff --git a/net/rds/iw.h b/net/rds/iw.h
89678 index 04ce3b1..48119a6 100644
89679 --- a/net/rds/iw.h
89680 +++ b/net/rds/iw.h
89681 @@ -134,7 +134,7 @@ struct rds_iw_connection {
89682 /* sending acks */
89683 unsigned long i_ack_flags;
89684 #ifdef KERNEL_HAS_ATOMIC64
89685 - atomic64_t i_ack_next; /* next ACK to send */
89686 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89687 #else
89688 spinlock_t i_ack_lock; /* protect i_ack_next */
89689 u64 i_ack_next; /* next ACK to send */
89690 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
89691 index a91e1db..cf3053f 100644
89692 --- a/net/rds/iw_cm.c
89693 +++ b/net/rds/iw_cm.c
89694 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
89695 /* Clear the ACK state */
89696 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89697 #ifdef KERNEL_HAS_ATOMIC64
89698 - atomic64_set(&ic->i_ack_next, 0);
89699 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89700 #else
89701 ic->i_ack_next = 0;
89702 #endif
89703 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
89704 index 4503335..db566b4 100644
89705 --- a/net/rds/iw_recv.c
89706 +++ b/net/rds/iw_recv.c
89707 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89708 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
89709 int ack_required)
89710 {
89711 - atomic64_set(&ic->i_ack_next, seq);
89712 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89713 if (ack_required) {
89714 smp_mb__before_clear_bit();
89715 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89716 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89717 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89718 smp_mb__after_clear_bit();
89719
89720 - return atomic64_read(&ic->i_ack_next);
89721 + return atomic64_read_unchecked(&ic->i_ack_next);
89722 }
89723 #endif
89724
89725 diff --git a/net/rds/rds.h b/net/rds/rds.h
89726 index ec1d731..90a3a8d 100644
89727 --- a/net/rds/rds.h
89728 +++ b/net/rds/rds.h
89729 @@ -449,7 +449,7 @@ struct rds_transport {
89730 void (*sync_mr)(void *trans_private, int direction);
89731 void (*free_mr)(void *trans_private, int invalidate);
89732 void (*flush_mrs)(void);
89733 -};
89734 +} __do_const;
89735
89736 struct rds_sock {
89737 struct sock rs_sk;
89738 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
89739 index edac9ef..16bcb98 100644
89740 --- a/net/rds/tcp.c
89741 +++ b/net/rds/tcp.c
89742 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
89743 int val = 1;
89744
89745 set_fs(KERNEL_DS);
89746 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
89747 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
89748 sizeof(val));
89749 set_fs(oldfs);
89750 }
89751 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
89752 index 81cf5a4..b5826ff 100644
89753 --- a/net/rds/tcp_send.c
89754 +++ b/net/rds/tcp_send.c
89755 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
89756
89757 oldfs = get_fs();
89758 set_fs(KERNEL_DS);
89759 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
89760 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
89761 sizeof(val));
89762 set_fs(oldfs);
89763 }
89764 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
89765 index 05996d0..5a1dfe0 100644
89766 --- a/net/rxrpc/af_rxrpc.c
89767 +++ b/net/rxrpc/af_rxrpc.c
89768 @@ -39,7 +39,7 @@ static const struct proto_ops rxrpc_rpc_ops;
89769 __be32 rxrpc_epoch;
89770
89771 /* current debugging ID */
89772 -atomic_t rxrpc_debug_id;
89773 +atomic_unchecked_t rxrpc_debug_id;
89774
89775 /* count of skbs currently in use */
89776 atomic_t rxrpc_n_skbs;
89777 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
89778 index e4d9cbc..b229649 100644
89779 --- a/net/rxrpc/ar-ack.c
89780 +++ b/net/rxrpc/ar-ack.c
89781 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89782
89783 _enter("{%d,%d,%d,%d},",
89784 call->acks_hard, call->acks_unacked,
89785 - atomic_read(&call->sequence),
89786 + atomic_read_unchecked(&call->sequence),
89787 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
89788
89789 stop = 0;
89790 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89791
89792 /* each Tx packet has a new serial number */
89793 sp->hdr.serial =
89794 - htonl(atomic_inc_return(&call->conn->serial));
89795 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
89796
89797 hdr = (struct rxrpc_header *) txb->head;
89798 hdr->serial = sp->hdr.serial;
89799 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
89800 */
89801 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
89802 {
89803 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
89804 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
89805 }
89806
89807 /*
89808 @@ -629,7 +629,7 @@ process_further:
89809
89810 latest = ntohl(sp->hdr.serial);
89811 hard = ntohl(ack.firstPacket);
89812 - tx = atomic_read(&call->sequence);
89813 + tx = atomic_read_unchecked(&call->sequence);
89814
89815 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89816 latest,
89817 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
89818 goto maybe_reschedule;
89819
89820 send_ACK_with_skew:
89821 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
89822 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
89823 ntohl(ack.serial));
89824 send_ACK:
89825 mtu = call->conn->trans->peer->if_mtu;
89826 @@ -1173,7 +1173,7 @@ send_ACK:
89827 ackinfo.rxMTU = htonl(5692);
89828 ackinfo.jumbo_max = htonl(4);
89829
89830 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89831 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89832 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89833 ntohl(hdr.serial),
89834 ntohs(ack.maxSkew),
89835 @@ -1191,7 +1191,7 @@ send_ACK:
89836 send_message:
89837 _debug("send message");
89838
89839 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89840 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89841 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
89842 send_message_2:
89843
89844 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
89845 index a3bbb36..3341fb9 100644
89846 --- a/net/rxrpc/ar-call.c
89847 +++ b/net/rxrpc/ar-call.c
89848 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
89849 spin_lock_init(&call->lock);
89850 rwlock_init(&call->state_lock);
89851 atomic_set(&call->usage, 1);
89852 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
89853 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89854 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
89855
89856 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
89857 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
89858 index 4106ca9..a338d7a 100644
89859 --- a/net/rxrpc/ar-connection.c
89860 +++ b/net/rxrpc/ar-connection.c
89861 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
89862 rwlock_init(&conn->lock);
89863 spin_lock_init(&conn->state_lock);
89864 atomic_set(&conn->usage, 1);
89865 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
89866 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89867 conn->avail_calls = RXRPC_MAXCALLS;
89868 conn->size_align = 4;
89869 conn->header_size = sizeof(struct rxrpc_header);
89870 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
89871 index e7ed43a..6afa140 100644
89872 --- a/net/rxrpc/ar-connevent.c
89873 +++ b/net/rxrpc/ar-connevent.c
89874 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
89875
89876 len = iov[0].iov_len + iov[1].iov_len;
89877
89878 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89879 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89880 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
89881
89882 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89883 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
89884 index 529572f..c758ca7 100644
89885 --- a/net/rxrpc/ar-input.c
89886 +++ b/net/rxrpc/ar-input.c
89887 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
89888 /* track the latest serial number on this connection for ACK packet
89889 * information */
89890 serial = ntohl(sp->hdr.serial);
89891 - hi_serial = atomic_read(&call->conn->hi_serial);
89892 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
89893 while (serial > hi_serial)
89894 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
89895 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
89896 serial);
89897
89898 /* request ACK generation for any ACK or DATA packet that requests
89899 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
89900 index a693aca..81e7293 100644
89901 --- a/net/rxrpc/ar-internal.h
89902 +++ b/net/rxrpc/ar-internal.h
89903 @@ -272,8 +272,8 @@ struct rxrpc_connection {
89904 int error; /* error code for local abort */
89905 int debug_id; /* debug ID for printks */
89906 unsigned int call_counter; /* call ID counter */
89907 - atomic_t serial; /* packet serial number counter */
89908 - atomic_t hi_serial; /* highest serial number received */
89909 + atomic_unchecked_t serial; /* packet serial number counter */
89910 + atomic_unchecked_t hi_serial; /* highest serial number received */
89911 u8 avail_calls; /* number of calls available */
89912 u8 size_align; /* data size alignment (for security) */
89913 u8 header_size; /* rxrpc + security header size */
89914 @@ -346,7 +346,7 @@ struct rxrpc_call {
89915 spinlock_t lock;
89916 rwlock_t state_lock; /* lock for state transition */
89917 atomic_t usage;
89918 - atomic_t sequence; /* Tx data packet sequence counter */
89919 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
89920 u32 abort_code; /* local/remote abort code */
89921 enum { /* current state of call */
89922 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
89923 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
89924 */
89925 extern atomic_t rxrpc_n_skbs;
89926 extern __be32 rxrpc_epoch;
89927 -extern atomic_t rxrpc_debug_id;
89928 +extern atomic_unchecked_t rxrpc_debug_id;
89929 extern struct workqueue_struct *rxrpc_workqueue;
89930
89931 /*
89932 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
89933 index 87f7135..74d3703 100644
89934 --- a/net/rxrpc/ar-local.c
89935 +++ b/net/rxrpc/ar-local.c
89936 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
89937 spin_lock_init(&local->lock);
89938 rwlock_init(&local->services_lock);
89939 atomic_set(&local->usage, 1);
89940 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
89941 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89942 memcpy(&local->srx, srx, sizeof(*srx));
89943 }
89944
89945 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
89946 index e1ac183..b43e10e 100644
89947 --- a/net/rxrpc/ar-output.c
89948 +++ b/net/rxrpc/ar-output.c
89949 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
89950 sp->hdr.cid = call->cid;
89951 sp->hdr.callNumber = call->call_id;
89952 sp->hdr.seq =
89953 - htonl(atomic_inc_return(&call->sequence));
89954 + htonl(atomic_inc_return_unchecked(&call->sequence));
89955 sp->hdr.serial =
89956 - htonl(atomic_inc_return(&conn->serial));
89957 + htonl(atomic_inc_return_unchecked(&conn->serial));
89958 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
89959 sp->hdr.userStatus = 0;
89960 sp->hdr.securityIndex = conn->security_ix;
89961 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
89962 index bebaa43..2644591 100644
89963 --- a/net/rxrpc/ar-peer.c
89964 +++ b/net/rxrpc/ar-peer.c
89965 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
89966 INIT_LIST_HEAD(&peer->error_targets);
89967 spin_lock_init(&peer->lock);
89968 atomic_set(&peer->usage, 1);
89969 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
89970 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89971 memcpy(&peer->srx, srx, sizeof(*srx));
89972
89973 rxrpc_assess_MTU_size(peer);
89974 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
89975 index 38047f7..9f48511 100644
89976 --- a/net/rxrpc/ar-proc.c
89977 +++ b/net/rxrpc/ar-proc.c
89978 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
89979 atomic_read(&conn->usage),
89980 rxrpc_conn_states[conn->state],
89981 key_serial(conn->key),
89982 - atomic_read(&conn->serial),
89983 - atomic_read(&conn->hi_serial));
89984 + atomic_read_unchecked(&conn->serial),
89985 + atomic_read_unchecked(&conn->hi_serial));
89986
89987 return 0;
89988 }
89989 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
89990 index 92df566..87ec1bf 100644
89991 --- a/net/rxrpc/ar-transport.c
89992 +++ b/net/rxrpc/ar-transport.c
89993 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
89994 spin_lock_init(&trans->client_lock);
89995 rwlock_init(&trans->conn_lock);
89996 atomic_set(&trans->usage, 1);
89997 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
89998 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89999
90000 if (peer->srx.transport.family == AF_INET) {
90001 switch (peer->srx.transport_type) {
90002 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
90003 index f226709..0e735a8 100644
90004 --- a/net/rxrpc/rxkad.c
90005 +++ b/net/rxrpc/rxkad.c
90006 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
90007
90008 len = iov[0].iov_len + iov[1].iov_len;
90009
90010 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
90011 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
90012 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
90013
90014 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
90015 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
90016
90017 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
90018
90019 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
90020 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
90021 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
90022
90023 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
90024 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
90025 index 391a245..296b3d7 100644
90026 --- a/net/sctp/ipv6.c
90027 +++ b/net/sctp/ipv6.c
90028 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
90029 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
90030 };
90031
90032 -static struct sctp_af sctp_af_inet6 = {
90033 +static struct sctp_af sctp_af_inet6 __read_only = {
90034 .sa_family = AF_INET6,
90035 .sctp_xmit = sctp_v6_xmit,
90036 .setsockopt = ipv6_setsockopt,
90037 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
90038 #endif
90039 };
90040
90041 -static struct sctp_pf sctp_pf_inet6 = {
90042 +static struct sctp_pf sctp_pf_inet6 __read_only = {
90043 .event_msgname = sctp_inet6_event_msgname,
90044 .skb_msgname = sctp_inet6_skb_msgname,
90045 .af_supported = sctp_inet6_af_supported,
90046 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
90047
90048 void sctp_v6_pf_exit(void)
90049 {
90050 - list_del(&sctp_af_inet6.list);
90051 + pax_list_del(&sctp_af_inet6.list);
90052 }
90053
90054 /* Initialize IPv6 support and register with socket layer. */
90055 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
90056 index 8c19e97..16264b8 100644
90057 --- a/net/sctp/proc.c
90058 +++ b/net/sctp/proc.c
90059 @@ -338,7 +338,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
90060 seq_printf(seq,
90061 "%8pK %8pK %-3d %-3d %-2d %-4d "
90062 "%4d %8d %8d %7d %5lu %-5d %5d ",
90063 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
90064 + assoc, sk,
90065 + sctp_sk(sk)->type, sk->sk_state,
90066 assoc->state, hash,
90067 assoc->assoc_id,
90068 assoc->sndbuf_used,
90069 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
90070 index f898b1c..a2d0fe8 100644
90071 --- a/net/sctp/protocol.c
90072 +++ b/net/sctp/protocol.c
90073 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
90074 return 0;
90075 }
90076
90077 + pax_open_kernel();
90078 INIT_LIST_HEAD(&af->list);
90079 - list_add_tail(&af->list, &sctp_address_families);
90080 + pax_close_kernel();
90081 + pax_list_add_tail(&af->list, &sctp_address_families);
90082 return 1;
90083 }
90084
90085 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
90086
90087 static struct sctp_af sctp_af_inet;
90088
90089 -static struct sctp_pf sctp_pf_inet = {
90090 +static struct sctp_pf sctp_pf_inet __read_only = {
90091 .event_msgname = sctp_inet_event_msgname,
90092 .skb_msgname = sctp_inet_skb_msgname,
90093 .af_supported = sctp_inet_af_supported,
90094 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
90095 };
90096
90097 /* IPv4 address related functions. */
90098 -static struct sctp_af sctp_af_inet = {
90099 +static struct sctp_af sctp_af_inet __read_only = {
90100 .sa_family = AF_INET,
90101 .sctp_xmit = sctp_v4_xmit,
90102 .setsockopt = ip_setsockopt,
90103 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
90104
90105 static void sctp_v4_pf_exit(void)
90106 {
90107 - list_del(&sctp_af_inet.list);
90108 + pax_list_del(&sctp_af_inet.list);
90109 }
90110
90111 static int sctp_v4_protosw_init(void)
90112 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
90113 index c957775..6d4593a 100644
90114 --- a/net/sctp/sm_sideeffect.c
90115 +++ b/net/sctp/sm_sideeffect.c
90116 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
90117 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
90118 }
90119
90120 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
90121 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
90122 NULL,
90123 sctp_generate_t1_cookie_event,
90124 sctp_generate_t1_init_event,
90125 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
90126 index 9ef5c73..1e9a9a9 100644
90127 --- a/net/sctp/socket.c
90128 +++ b/net/sctp/socket.c
90129 @@ -2166,11 +2166,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
90130 {
90131 struct sctp_association *asoc;
90132 struct sctp_ulpevent *event;
90133 + struct sctp_event_subscribe subscribe;
90134
90135 if (optlen > sizeof(struct sctp_event_subscribe))
90136 return -EINVAL;
90137 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
90138 + if (copy_from_user(&subscribe, optval, optlen))
90139 return -EFAULT;
90140 + sctp_sk(sk)->subscribe = subscribe;
90141
90142 /*
90143 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
90144 @@ -4215,13 +4217,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
90145 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
90146 int __user *optlen)
90147 {
90148 + struct sctp_event_subscribe subscribe;
90149 +
90150 if (len <= 0)
90151 return -EINVAL;
90152 if (len > sizeof(struct sctp_event_subscribe))
90153 len = sizeof(struct sctp_event_subscribe);
90154 if (put_user(len, optlen))
90155 return -EFAULT;
90156 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
90157 + subscribe = sctp_sk(sk)->subscribe;
90158 + if (copy_to_user(optval, &subscribe, len))
90159 return -EFAULT;
90160 return 0;
90161 }
90162 @@ -4239,6 +4244,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
90163 */
90164 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
90165 {
90166 + __u32 autoclose;
90167 +
90168 /* Applicable to UDP-style socket only */
90169 if (sctp_style(sk, TCP))
90170 return -EOPNOTSUPP;
90171 @@ -4247,7 +4254,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
90172 len = sizeof(int);
90173 if (put_user(len, optlen))
90174 return -EFAULT;
90175 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
90176 + autoclose = sctp_sk(sk)->autoclose;
90177 + if (copy_to_user(optval, &autoclose, sizeof(int)))
90178 return -EFAULT;
90179 return 0;
90180 }
90181 @@ -4619,12 +4627,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
90182 */
90183 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
90184 {
90185 + struct sctp_initmsg initmsg;
90186 +
90187 if (len < sizeof(struct sctp_initmsg))
90188 return -EINVAL;
90189 len = sizeof(struct sctp_initmsg);
90190 if (put_user(len, optlen))
90191 return -EFAULT;
90192 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
90193 + initmsg = sctp_sk(sk)->initmsg;
90194 + if (copy_to_user(optval, &initmsg, len))
90195 return -EFAULT;
90196 return 0;
90197 }
90198 @@ -4665,6 +4676,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
90199 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
90200 if (space_left < addrlen)
90201 return -ENOMEM;
90202 + if (addrlen > sizeof(temp) || addrlen < 0)
90203 + return -EFAULT;
90204 if (copy_to_user(to, &temp, addrlen))
90205 return -EFAULT;
90206 to += addrlen;
90207 diff --git a/net/sctp/ssnmap.c b/net/sctp/ssnmap.c
90208 index 442ad4e..825ea94 100644
90209 --- a/net/sctp/ssnmap.c
90210 +++ b/net/sctp/ssnmap.c
90211 @@ -41,8 +41,6 @@
90212 #include <net/sctp/sctp.h>
90213 #include <net/sctp/sm.h>
90214
90215 -#define MAX_KMALLOC_SIZE 131072
90216 -
90217 static struct sctp_ssnmap *sctp_ssnmap_init(struct sctp_ssnmap *map, __u16 in,
90218 __u16 out);
90219
90220 @@ -65,7 +63,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
90221 int size;
90222
90223 size = sctp_ssnmap_size(in, out);
90224 - if (size <= MAX_KMALLOC_SIZE)
90225 + if (size <= KMALLOC_MAX_SIZE)
90226 retval = kmalloc(size, gfp);
90227 else
90228 retval = (struct sctp_ssnmap *)
90229 @@ -82,7 +80,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
90230 return retval;
90231
90232 fail_map:
90233 - if (size <= MAX_KMALLOC_SIZE)
90234 + if (size <= KMALLOC_MAX_SIZE)
90235 kfree(retval);
90236 else
90237 free_pages((unsigned long)retval, get_order(size));
90238 @@ -124,7 +122,7 @@ void sctp_ssnmap_free(struct sctp_ssnmap *map)
90239 int size;
90240
90241 size = sctp_ssnmap_size(map->in.len, map->out.len);
90242 - if (size <= MAX_KMALLOC_SIZE)
90243 + if (size <= KMALLOC_MAX_SIZE)
90244 kfree(map);
90245 else
90246 free_pages((unsigned long)map, get_order(size));
90247 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
90248 index bf3c6e8..376d8d0 100644
90249 --- a/net/sctp/sysctl.c
90250 +++ b/net/sctp/sysctl.c
90251 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
90252 {
90253 struct net *net = current->nsproxy->net_ns;
90254 char tmp[8];
90255 - ctl_table tbl;
90256 + ctl_table_no_const tbl;
90257 int ret;
90258 int changed = 0;
90259 char *none = "none";
90260 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
90261
90262 int sctp_sysctl_net_register(struct net *net)
90263 {
90264 - struct ctl_table *table;
90265 + ctl_table_no_const *table;
90266 int i;
90267
90268 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
90269 diff --git a/net/socket.c b/net/socket.c
90270 index 2ca51c7..ee5feb5 100644
90271 --- a/net/socket.c
90272 +++ b/net/socket.c
90273 @@ -89,6 +89,7 @@
90274 #include <linux/magic.h>
90275 #include <linux/slab.h>
90276 #include <linux/xattr.h>
90277 +#include <linux/in.h>
90278
90279 #include <asm/uaccess.h>
90280 #include <asm/unistd.h>
90281 @@ -106,6 +107,8 @@
90282 #include <linux/sockios.h>
90283 #include <linux/atalk.h>
90284
90285 +#include <linux/grsock.h>
90286 +
90287 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
90288 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
90289 unsigned long nr_segs, loff_t pos);
90290 @@ -322,7 +325,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
90291 &sockfs_dentry_operations, SOCKFS_MAGIC);
90292 }
90293
90294 -static struct vfsmount *sock_mnt __read_mostly;
90295 +struct vfsmount *sock_mnt __read_mostly;
90296
90297 static struct file_system_type sock_fs_type = {
90298 .name = "sockfs",
90299 @@ -1270,6 +1273,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
90300 return -EAFNOSUPPORT;
90301 if (type < 0 || type >= SOCK_MAX)
90302 return -EINVAL;
90303 + if (protocol < 0)
90304 + return -EINVAL;
90305
90306 /* Compatibility.
90307
90308 @@ -1401,6 +1406,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
90309 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
90310 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
90311
90312 + if(!gr_search_socket(family, type, protocol)) {
90313 + retval = -EACCES;
90314 + goto out;
90315 + }
90316 +
90317 + if (gr_handle_sock_all(family, type, protocol)) {
90318 + retval = -EACCES;
90319 + goto out;
90320 + }
90321 +
90322 retval = sock_create(family, type, protocol, &sock);
90323 if (retval < 0)
90324 goto out;
90325 @@ -1528,6 +1543,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90326 if (sock) {
90327 err = move_addr_to_kernel(umyaddr, addrlen, &address);
90328 if (err >= 0) {
90329 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
90330 + err = -EACCES;
90331 + goto error;
90332 + }
90333 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
90334 + if (err)
90335 + goto error;
90336 +
90337 err = security_socket_bind(sock,
90338 (struct sockaddr *)&address,
90339 addrlen);
90340 @@ -1536,6 +1559,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90341 (struct sockaddr *)
90342 &address, addrlen);
90343 }
90344 +error:
90345 fput_light(sock->file, fput_needed);
90346 }
90347 return err;
90348 @@ -1559,10 +1583,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
90349 if ((unsigned int)backlog > somaxconn)
90350 backlog = somaxconn;
90351
90352 + if (gr_handle_sock_server_other(sock->sk)) {
90353 + err = -EPERM;
90354 + goto error;
90355 + }
90356 +
90357 + err = gr_search_listen(sock);
90358 + if (err)
90359 + goto error;
90360 +
90361 err = security_socket_listen(sock, backlog);
90362 if (!err)
90363 err = sock->ops->listen(sock, backlog);
90364
90365 +error:
90366 fput_light(sock->file, fput_needed);
90367 }
90368 return err;
90369 @@ -1606,6 +1640,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90370 newsock->type = sock->type;
90371 newsock->ops = sock->ops;
90372
90373 + if (gr_handle_sock_server_other(sock->sk)) {
90374 + err = -EPERM;
90375 + sock_release(newsock);
90376 + goto out_put;
90377 + }
90378 +
90379 + err = gr_search_accept(sock);
90380 + if (err) {
90381 + sock_release(newsock);
90382 + goto out_put;
90383 + }
90384 +
90385 /*
90386 * We don't need try_module_get here, as the listening socket (sock)
90387 * has the protocol module (sock->ops->owner) held.
90388 @@ -1651,6 +1697,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90389 fd_install(newfd, newfile);
90390 err = newfd;
90391
90392 + gr_attach_curr_ip(newsock->sk);
90393 +
90394 out_put:
90395 fput_light(sock->file, fput_needed);
90396 out:
90397 @@ -1683,6 +1731,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90398 int, addrlen)
90399 {
90400 struct socket *sock;
90401 + struct sockaddr *sck;
90402 struct sockaddr_storage address;
90403 int err, fput_needed;
90404
90405 @@ -1693,6 +1742,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90406 if (err < 0)
90407 goto out_put;
90408
90409 + sck = (struct sockaddr *)&address;
90410 +
90411 + if (gr_handle_sock_client(sck)) {
90412 + err = -EACCES;
90413 + goto out_put;
90414 + }
90415 +
90416 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
90417 + if (err)
90418 + goto out_put;
90419 +
90420 err =
90421 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
90422 if (err)
90423 @@ -1774,6 +1834,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
90424 * the protocol.
90425 */
90426
90427 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
90428 +
90429 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
90430 unsigned int, flags, struct sockaddr __user *, addr,
90431 int, addr_len)
90432 @@ -1840,7 +1902,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
90433 struct socket *sock;
90434 struct iovec iov;
90435 struct msghdr msg;
90436 - struct sockaddr_storage address;
90437 + struct sockaddr_storage address = { };
90438 int err, err2;
90439 int fput_needed;
90440
90441 @@ -2047,7 +2109,7 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
90442 * checking falls down on this.
90443 */
90444 if (copy_from_user(ctl_buf,
90445 - (void __user __force *)msg_sys->msg_control,
90446 + (void __force_user *)msg_sys->msg_control,
90447 ctl_len))
90448 goto out_freectl;
90449 msg_sys->msg_control = ctl_buf;
90450 @@ -2187,7 +2249,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90451 int err, total_len, len;
90452
90453 /* kernel mode address */
90454 - struct sockaddr_storage addr;
90455 + struct sockaddr_storage addr = { };
90456
90457 /* user mode address pointers */
90458 struct sockaddr __user *uaddr;
90459 @@ -2215,7 +2277,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90460 * kernel msghdr to use the kernel address space)
90461 */
90462
90463 - uaddr = (__force void __user *)msg_sys->msg_name;
90464 + uaddr = (void __force_user *)msg_sys->msg_name;
90465 uaddr_len = COMPAT_NAMELEN(msg);
90466 if (MSG_CMSG_COMPAT & flags) {
90467 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
90468 @@ -2838,7 +2900,7 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90469 }
90470
90471 ifr = compat_alloc_user_space(buf_size);
90472 - rxnfc = (void *)ifr + ALIGN(sizeof(struct ifreq), 8);
90473 + rxnfc = (void __user *)ifr + ALIGN(sizeof(struct ifreq), 8);
90474
90475 if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
90476 return -EFAULT;
90477 @@ -2862,12 +2924,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90478 offsetof(struct ethtool_rxnfc, fs.ring_cookie));
90479
90480 if (copy_in_user(rxnfc, compat_rxnfc,
90481 - (void *)(&rxnfc->fs.m_ext + 1) -
90482 - (void *)rxnfc) ||
90483 + (void __user *)(&rxnfc->fs.m_ext + 1) -
90484 + (void __user *)rxnfc) ||
90485 copy_in_user(&rxnfc->fs.ring_cookie,
90486 &compat_rxnfc->fs.ring_cookie,
90487 - (void *)(&rxnfc->fs.location + 1) -
90488 - (void *)&rxnfc->fs.ring_cookie) ||
90489 + (void __user *)(&rxnfc->fs.location + 1) -
90490 + (void __user *)&rxnfc->fs.ring_cookie) ||
90491 copy_in_user(&rxnfc->rule_cnt, &compat_rxnfc->rule_cnt,
90492 sizeof(rxnfc->rule_cnt)))
90493 return -EFAULT;
90494 @@ -2879,12 +2941,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90495
90496 if (convert_out) {
90497 if (copy_in_user(compat_rxnfc, rxnfc,
90498 - (const void *)(&rxnfc->fs.m_ext + 1) -
90499 - (const void *)rxnfc) ||
90500 + (const void __user *)(&rxnfc->fs.m_ext + 1) -
90501 + (const void __user *)rxnfc) ||
90502 copy_in_user(&compat_rxnfc->fs.ring_cookie,
90503 &rxnfc->fs.ring_cookie,
90504 - (const void *)(&rxnfc->fs.location + 1) -
90505 - (const void *)&rxnfc->fs.ring_cookie) ||
90506 + (const void __user *)(&rxnfc->fs.location + 1) -
90507 + (const void __user *)&rxnfc->fs.ring_cookie) ||
90508 copy_in_user(&compat_rxnfc->rule_cnt, &rxnfc->rule_cnt,
90509 sizeof(rxnfc->rule_cnt)))
90510 return -EFAULT;
90511 @@ -2954,7 +3016,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
90512 old_fs = get_fs();
90513 set_fs(KERNEL_DS);
90514 err = dev_ioctl(net, cmd,
90515 - (struct ifreq __user __force *) &kifr);
90516 + (struct ifreq __force_user *) &kifr);
90517 set_fs(old_fs);
90518
90519 return err;
90520 @@ -3063,7 +3125,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
90521
90522 old_fs = get_fs();
90523 set_fs(KERNEL_DS);
90524 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
90525 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
90526 set_fs(old_fs);
90527
90528 if (cmd == SIOCGIFMAP && !err) {
90529 @@ -3168,7 +3230,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
90530 ret |= __get_user(rtdev, &(ur4->rt_dev));
90531 if (rtdev) {
90532 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
90533 - r4.rt_dev = (char __user __force *)devname;
90534 + r4.rt_dev = (char __force_user *)devname;
90535 devname[15] = 0;
90536 } else
90537 r4.rt_dev = NULL;
90538 @@ -3394,8 +3456,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
90539 int __user *uoptlen;
90540 int err;
90541
90542 - uoptval = (char __user __force *) optval;
90543 - uoptlen = (int __user __force *) optlen;
90544 + uoptval = (char __force_user *) optval;
90545 + uoptlen = (int __force_user *) optlen;
90546
90547 set_fs(KERNEL_DS);
90548 if (level == SOL_SOCKET)
90549 @@ -3415,7 +3477,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
90550 char __user *uoptval;
90551 int err;
90552
90553 - uoptval = (char __user __force *) optval;
90554 + uoptval = (char __force_user *) optval;
90555
90556 set_fs(KERNEL_DS);
90557 if (level == SOL_SOCKET)
90558 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
90559 index 507b5e8..75e88ea 100644
90560 --- a/net/sunrpc/clnt.c
90561 +++ b/net/sunrpc/clnt.c
90562 @@ -303,10 +303,8 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru
90563 err = rpciod_up();
90564 if (err)
90565 goto out_no_rpciod;
90566 +
90567 err = -EINVAL;
90568 - if (!xprt)
90569 - goto out_no_xprt;
90570 -
90571 if (args->version >= program->nrvers)
90572 goto out_err;
90573 version = program->version[args->version];
90574 @@ -381,10 +379,9 @@ out_no_principal:
90575 out_no_stats:
90576 kfree(clnt);
90577 out_err:
90578 - xprt_put(xprt);
90579 -out_no_xprt:
90580 rpciod_down();
90581 out_no_rpciod:
90582 + xprt_put(xprt);
90583 return ERR_PTR(err);
90584 }
90585
90586 @@ -511,7 +508,7 @@ static struct rpc_clnt *__rpc_clone_client(struct rpc_create_args *args,
90587 new = rpc_new_client(args, xprt);
90588 if (IS_ERR(new)) {
90589 err = PTR_ERR(new);
90590 - goto out_put;
90591 + goto out_err;
90592 }
90593
90594 atomic_inc(&clnt->cl_count);
90595 @@ -524,8 +521,6 @@ static struct rpc_clnt *__rpc_clone_client(struct rpc_create_args *args,
90596 new->cl_chatty = clnt->cl_chatty;
90597 return new;
90598
90599 -out_put:
90600 - xprt_put(xprt);
90601 out_err:
90602 dprintk("RPC: %s: returned error %d\n", __func__, err);
90603 return ERR_PTR(err);
90604 @@ -1272,7 +1267,9 @@ call_start(struct rpc_task *task)
90605 (RPC_IS_ASYNC(task) ? "async" : "sync"));
90606
90607 /* Increment call count */
90608 - task->tk_msg.rpc_proc->p_count++;
90609 + pax_open_kernel();
90610 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
90611 + pax_close_kernel();
90612 clnt->cl_stats->rpccnt++;
90613 task->tk_action = call_reserve;
90614 }
90615 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
90616 index f8529fc..ce8c643 100644
90617 --- a/net/sunrpc/sched.c
90618 +++ b/net/sunrpc/sched.c
90619 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
90620 #ifdef RPC_DEBUG
90621 static void rpc_task_set_debuginfo(struct rpc_task *task)
90622 {
90623 - static atomic_t rpc_pid;
90624 + static atomic_unchecked_t rpc_pid;
90625
90626 - task->tk_pid = atomic_inc_return(&rpc_pid);
90627 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
90628 }
90629 #else
90630 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
90631 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
90632 index 2d34b6b..e2d584d 100644
90633 --- a/net/sunrpc/svc.c
90634 +++ b/net/sunrpc/svc.c
90635 @@ -1156,7 +1156,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
90636 svc_putnl(resv, RPC_SUCCESS);
90637
90638 /* Bump per-procedure stats counter */
90639 - procp->pc_count++;
90640 + pax_open_kernel();
90641 + (*(unsigned int *)&procp->pc_count)++;
90642 + pax_close_kernel();
90643
90644 /* Initialize storage for argp and resp */
90645 memset(rqstp->rq_argp, 0, procp->pc_argsize);
90646 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
90647 index 8343737..677025e 100644
90648 --- a/net/sunrpc/xprtrdma/svc_rdma.c
90649 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
90650 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
90651 static unsigned int min_max_inline = 4096;
90652 static unsigned int max_max_inline = 65536;
90653
90654 -atomic_t rdma_stat_recv;
90655 -atomic_t rdma_stat_read;
90656 -atomic_t rdma_stat_write;
90657 -atomic_t rdma_stat_sq_starve;
90658 -atomic_t rdma_stat_rq_starve;
90659 -atomic_t rdma_stat_rq_poll;
90660 -atomic_t rdma_stat_rq_prod;
90661 -atomic_t rdma_stat_sq_poll;
90662 -atomic_t rdma_stat_sq_prod;
90663 +atomic_unchecked_t rdma_stat_recv;
90664 +atomic_unchecked_t rdma_stat_read;
90665 +atomic_unchecked_t rdma_stat_write;
90666 +atomic_unchecked_t rdma_stat_sq_starve;
90667 +atomic_unchecked_t rdma_stat_rq_starve;
90668 +atomic_unchecked_t rdma_stat_rq_poll;
90669 +atomic_unchecked_t rdma_stat_rq_prod;
90670 +atomic_unchecked_t rdma_stat_sq_poll;
90671 +atomic_unchecked_t rdma_stat_sq_prod;
90672
90673 /* Temporary NFS request map and context caches */
90674 struct kmem_cache *svc_rdma_map_cachep;
90675 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
90676 len -= *ppos;
90677 if (len > *lenp)
90678 len = *lenp;
90679 - if (len && copy_to_user(buffer, str_buf, len))
90680 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
90681 return -EFAULT;
90682 *lenp = len;
90683 *ppos += len;
90684 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
90685 {
90686 .procname = "rdma_stat_read",
90687 .data = &rdma_stat_read,
90688 - .maxlen = sizeof(atomic_t),
90689 + .maxlen = sizeof(atomic_unchecked_t),
90690 .mode = 0644,
90691 .proc_handler = read_reset_stat,
90692 },
90693 {
90694 .procname = "rdma_stat_recv",
90695 .data = &rdma_stat_recv,
90696 - .maxlen = sizeof(atomic_t),
90697 + .maxlen = sizeof(atomic_unchecked_t),
90698 .mode = 0644,
90699 .proc_handler = read_reset_stat,
90700 },
90701 {
90702 .procname = "rdma_stat_write",
90703 .data = &rdma_stat_write,
90704 - .maxlen = sizeof(atomic_t),
90705 + .maxlen = sizeof(atomic_unchecked_t),
90706 .mode = 0644,
90707 .proc_handler = read_reset_stat,
90708 },
90709 {
90710 .procname = "rdma_stat_sq_starve",
90711 .data = &rdma_stat_sq_starve,
90712 - .maxlen = sizeof(atomic_t),
90713 + .maxlen = sizeof(atomic_unchecked_t),
90714 .mode = 0644,
90715 .proc_handler = read_reset_stat,
90716 },
90717 {
90718 .procname = "rdma_stat_rq_starve",
90719 .data = &rdma_stat_rq_starve,
90720 - .maxlen = sizeof(atomic_t),
90721 + .maxlen = sizeof(atomic_unchecked_t),
90722 .mode = 0644,
90723 .proc_handler = read_reset_stat,
90724 },
90725 {
90726 .procname = "rdma_stat_rq_poll",
90727 .data = &rdma_stat_rq_poll,
90728 - .maxlen = sizeof(atomic_t),
90729 + .maxlen = sizeof(atomic_unchecked_t),
90730 .mode = 0644,
90731 .proc_handler = read_reset_stat,
90732 },
90733 {
90734 .procname = "rdma_stat_rq_prod",
90735 .data = &rdma_stat_rq_prod,
90736 - .maxlen = sizeof(atomic_t),
90737 + .maxlen = sizeof(atomic_unchecked_t),
90738 .mode = 0644,
90739 .proc_handler = read_reset_stat,
90740 },
90741 {
90742 .procname = "rdma_stat_sq_poll",
90743 .data = &rdma_stat_sq_poll,
90744 - .maxlen = sizeof(atomic_t),
90745 + .maxlen = sizeof(atomic_unchecked_t),
90746 .mode = 0644,
90747 .proc_handler = read_reset_stat,
90748 },
90749 {
90750 .procname = "rdma_stat_sq_prod",
90751 .data = &rdma_stat_sq_prod,
90752 - .maxlen = sizeof(atomic_t),
90753 + .maxlen = sizeof(atomic_unchecked_t),
90754 .mode = 0644,
90755 .proc_handler = read_reset_stat,
90756 },
90757 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90758 index 0ce7552..d074459 100644
90759 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90760 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90761 @@ -501,7 +501,7 @@ next_sge:
90762 svc_rdma_put_context(ctxt, 0);
90763 goto out;
90764 }
90765 - atomic_inc(&rdma_stat_read);
90766 + atomic_inc_unchecked(&rdma_stat_read);
90767
90768 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
90769 chl_map->ch[ch_no].count -= read_wr.num_sge;
90770 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90771 dto_q);
90772 list_del_init(&ctxt->dto_q);
90773 } else {
90774 - atomic_inc(&rdma_stat_rq_starve);
90775 + atomic_inc_unchecked(&rdma_stat_rq_starve);
90776 clear_bit(XPT_DATA, &xprt->xpt_flags);
90777 ctxt = NULL;
90778 }
90779 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90780 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
90781 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
90782 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
90783 - atomic_inc(&rdma_stat_recv);
90784 + atomic_inc_unchecked(&rdma_stat_recv);
90785
90786 /* Build up the XDR from the receive buffers. */
90787 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
90788 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90789 index c1d124d..acfc59e 100644
90790 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90791 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90792 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
90793 write_wr.wr.rdma.remote_addr = to;
90794
90795 /* Post It */
90796 - atomic_inc(&rdma_stat_write);
90797 + atomic_inc_unchecked(&rdma_stat_write);
90798 if (svc_rdma_send(xprt, &write_wr))
90799 goto err;
90800 return 0;
90801 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90802 index 62e4f9b..dd3f2d7 100644
90803 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
90804 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90805 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90806 return;
90807
90808 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
90809 - atomic_inc(&rdma_stat_rq_poll);
90810 + atomic_inc_unchecked(&rdma_stat_rq_poll);
90811
90812 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
90813 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
90814 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90815 }
90816
90817 if (ctxt)
90818 - atomic_inc(&rdma_stat_rq_prod);
90819 + atomic_inc_unchecked(&rdma_stat_rq_prod);
90820
90821 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
90822 /*
90823 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90824 return;
90825
90826 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
90827 - atomic_inc(&rdma_stat_sq_poll);
90828 + atomic_inc_unchecked(&rdma_stat_sq_poll);
90829 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
90830 if (wc.status != IB_WC_SUCCESS)
90831 /* Close the transport */
90832 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90833 }
90834
90835 if (ctxt)
90836 - atomic_inc(&rdma_stat_sq_prod);
90837 + atomic_inc_unchecked(&rdma_stat_sq_prod);
90838 }
90839
90840 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
90841 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
90842 spin_lock_bh(&xprt->sc_lock);
90843 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
90844 spin_unlock_bh(&xprt->sc_lock);
90845 - atomic_inc(&rdma_stat_sq_starve);
90846 + atomic_inc_unchecked(&rdma_stat_sq_starve);
90847
90848 /* See if we can opportunistically reap SQ WR to make room */
90849 sq_cq_reap(xprt);
90850 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
90851 index 9bc6db0..47ac8c0 100644
90852 --- a/net/sysctl_net.c
90853 +++ b/net/sysctl_net.c
90854 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
90855 kgid_t root_gid = make_kgid(net->user_ns, 0);
90856
90857 /* Allow network administrator to have same access as root. */
90858 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
90859 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
90860 uid_eq(root_uid, current_uid())) {
90861 int mode = (table->mode >> 6) & 7;
90862 return (mode << 6) | (mode << 3) | mode;
90863 diff --git a/net/tipc/link.c b/net/tipc/link.c
90864 index daa6080..02d357f 100644
90865 --- a/net/tipc/link.c
90866 +++ b/net/tipc/link.c
90867 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
90868 struct tipc_msg fragm_hdr;
90869 struct sk_buff *buf, *buf_chain, *prev;
90870 u32 fragm_crs, fragm_rest, hsz, sect_rest;
90871 - const unchar *sect_crs;
90872 + const unchar __user *sect_crs;
90873 int curr_sect;
90874 u32 fragm_no;
90875
90876 @@ -1242,7 +1242,7 @@ again:
90877
90878 if (!sect_rest) {
90879 sect_rest = msg_sect[++curr_sect].iov_len;
90880 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
90881 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
90882 }
90883
90884 if (sect_rest < fragm_rest)
90885 @@ -1261,7 +1261,7 @@ error:
90886 }
90887 } else
90888 skb_copy_to_linear_data_offset(buf, fragm_crs,
90889 - sect_crs, sz);
90890 + (const void __force_kernel *)sect_crs, sz);
90891 sect_crs += sz;
90892 sect_rest -= sz;
90893 fragm_crs += sz;
90894 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
90895 index f2db8a8..9245aa4 100644
90896 --- a/net/tipc/msg.c
90897 +++ b/net/tipc/msg.c
90898 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
90899 msg_sect[cnt].iov_len);
90900 else
90901 skb_copy_to_linear_data_offset(*buf, pos,
90902 - msg_sect[cnt].iov_base,
90903 + (const void __force_kernel *)msg_sect[cnt].iov_base,
90904 msg_sect[cnt].iov_len);
90905 pos += msg_sect[cnt].iov_len;
90906 }
90907 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
90908 index 6b42d47..2ac24d5 100644
90909 --- a/net/tipc/subscr.c
90910 +++ b/net/tipc/subscr.c
90911 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
90912 {
90913 struct iovec msg_sect;
90914
90915 - msg_sect.iov_base = (void *)&sub->evt;
90916 + msg_sect.iov_base = (void __force_user *)&sub->evt;
90917 msg_sect.iov_len = sizeof(struct tipc_event);
90918
90919 sub->evt.event = htohl(event, sub->swap);
90920 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
90921 index b45eb65..bb4b223 100644
90922 --- a/net/unix/af_unix.c
90923 +++ b/net/unix/af_unix.c
90924 @@ -785,6 +785,12 @@ static struct sock *unix_find_other(struct net *net,
90925 err = -ECONNREFUSED;
90926 if (!S_ISSOCK(inode->i_mode))
90927 goto put_fail;
90928 +
90929 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
90930 + err = -EACCES;
90931 + goto put_fail;
90932 + }
90933 +
90934 u = unix_find_socket_byinode(inode);
90935 if (!u)
90936 goto put_fail;
90937 @@ -805,6 +811,13 @@ static struct sock *unix_find_other(struct net *net,
90938 if (u) {
90939 struct dentry *dentry;
90940 dentry = unix_sk(u)->path.dentry;
90941 +
90942 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
90943 + err = -EPERM;
90944 + sock_put(u);
90945 + goto fail;
90946 + }
90947 +
90948 if (dentry)
90949 touch_atime(&unix_sk(u)->path);
90950 } else
90951 @@ -838,12 +851,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
90952 */
90953 err = security_path_mknod(&path, dentry, mode, 0);
90954 if (!err) {
90955 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
90956 + err = -EACCES;
90957 + goto out;
90958 + }
90959 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
90960 if (!err) {
90961 res->mnt = mntget(path.mnt);
90962 res->dentry = dget(dentry);
90963 + gr_handle_create(dentry, path.mnt);
90964 }
90965 }
90966 +out:
90967 done_path_create(&path, dentry);
90968 return err;
90969 }
90970 @@ -1995,7 +2014,7 @@ again:
90971 if ((UNIXCB(skb).pid != siocb->scm->pid) ||
90972 (UNIXCB(skb).cred != siocb->scm->cred))
90973 break;
90974 - } else {
90975 + } else if (test_bit(SOCK_PASSCRED, &sock->flags)) {
90976 /* Copy credentials */
90977 scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).cred);
90978 check_creds = 1;
90979 @@ -2325,9 +2344,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90980 seq_puts(seq, "Num RefCount Protocol Flags Type St "
90981 "Inode Path\n");
90982 else {
90983 - struct sock *s = v;
90984 + struct sock *s = v, *peer;
90985 struct unix_sock *u = unix_sk(s);
90986 unix_state_lock(s);
90987 + peer = unix_peer(s);
90988 + unix_state_unlock(s);
90989 +
90990 + unix_state_double_lock(s, peer);
90991
90992 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
90993 s,
90994 @@ -2354,8 +2377,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90995 }
90996 for ( ; i < len; i++)
90997 seq_putc(seq, u->addr->name->sun_path[i]);
90998 - }
90999 - unix_state_unlock(s);
91000 + } else if (peer)
91001 + seq_printf(seq, " P%lu", sock_i_ino(peer));
91002 +
91003 + unix_state_double_unlock(s, peer);
91004 seq_putc(seq, '\n');
91005 }
91006
91007 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
91008 index 8800604..0526440 100644
91009 --- a/net/unix/sysctl_net_unix.c
91010 +++ b/net/unix/sysctl_net_unix.c
91011 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
91012
91013 int __net_init unix_sysctl_register(struct net *net)
91014 {
91015 - struct ctl_table *table;
91016 + ctl_table_no_const *table;
91017
91018 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
91019 if (table == NULL)
91020 diff --git a/net/wireless/trace.h b/net/wireless/trace.h
91021 index 2134576..5d71a5a 100644
91022 --- a/net/wireless/trace.h
91023 +++ b/net/wireless/trace.h
91024 @@ -27,7 +27,8 @@
91025 #define WIPHY_PR_ARG __entry->wiphy_name
91026
91027 #define WDEV_ENTRY __field(u32, id)
91028 -#define WDEV_ASSIGN (__entry->id) = (wdev ? wdev->identifier : 0)
91029 +#define WDEV_ASSIGN (__entry->id) = (!IS_ERR_OR_NULL(wdev) \
91030 + ? wdev->identifier : 0)
91031 #define WDEV_PR_FMT "wdev(%u)"
91032 #define WDEV_PR_ARG (__entry->id)
91033
91034 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
91035 index c8717c1..08539f5 100644
91036 --- a/net/wireless/wext-core.c
91037 +++ b/net/wireless/wext-core.c
91038 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
91039 */
91040
91041 /* Support for very large requests */
91042 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
91043 - (user_length > descr->max_tokens)) {
91044 + if (user_length > descr->max_tokens) {
91045 /* Allow userspace to GET more than max so
91046 * we can support any size GET requests.
91047 * There is still a limit : -ENOMEM.
91048 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
91049 }
91050 }
91051
91052 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
91053 - /*
91054 - * If this is a GET, but not NOMAX, it means that the extra
91055 - * data is not bounded by userspace, but by max_tokens. Thus
91056 - * set the length to max_tokens. This matches the extra data
91057 - * allocation.
91058 - * The driver should fill it with the number of tokens it
91059 - * provided, and it may check iwp->length rather than having
91060 - * knowledge of max_tokens. If the driver doesn't change the
91061 - * iwp->length, this ioctl just copies back max_token tokens
91062 - * filled with zeroes. Hopefully the driver isn't claiming
91063 - * them to be valid data.
91064 - */
91065 - iwp->length = descr->max_tokens;
91066 - }
91067 -
91068 err = handler(dev, info, (union iwreq_data *) iwp, extra);
91069
91070 iwp->length += essid_compat;
91071 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
91072 index 07c5857..fde4018 100644
91073 --- a/net/xfrm/xfrm_policy.c
91074 +++ b/net/xfrm/xfrm_policy.c
91075 @@ -317,7 +317,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
91076 {
91077 policy->walk.dead = 1;
91078
91079 - atomic_inc(&policy->genid);
91080 + atomic_inc_unchecked(&policy->genid);
91081
91082 if (del_timer(&policy->timer))
91083 xfrm_pol_put(policy);
91084 @@ -601,7 +601,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
91085 hlist_add_head(&policy->bydst, chain);
91086 xfrm_pol_hold(policy);
91087 net->xfrm.policy_count[dir]++;
91088 - atomic_inc(&flow_cache_genid);
91089 + atomic_inc_unchecked(&flow_cache_genid);
91090 rt_genid_bump(net);
91091 if (delpol)
91092 __xfrm_policy_unlink(delpol, dir);
91093 @@ -1550,7 +1550,7 @@ free_dst:
91094 goto out;
91095 }
91096
91097 -static int inline
91098 +static inline int
91099 xfrm_dst_alloc_copy(void **target, const void *src, int size)
91100 {
91101 if (!*target) {
91102 @@ -1562,7 +1562,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
91103 return 0;
91104 }
91105
91106 -static int inline
91107 +static inline int
91108 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
91109 {
91110 #ifdef CONFIG_XFRM_SUB_POLICY
91111 @@ -1574,7 +1574,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
91112 #endif
91113 }
91114
91115 -static int inline
91116 +static inline int
91117 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
91118 {
91119 #ifdef CONFIG_XFRM_SUB_POLICY
91120 @@ -1668,7 +1668,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
91121
91122 xdst->num_pols = num_pols;
91123 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
91124 - xdst->policy_genid = atomic_read(&pols[0]->genid);
91125 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
91126
91127 return xdst;
91128 }
91129 @@ -2369,7 +2369,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
91130 if (xdst->xfrm_genid != dst->xfrm->genid)
91131 return 0;
91132 if (xdst->num_pols > 0 &&
91133 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
91134 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
91135 return 0;
91136
91137 mtu = dst_mtu(dst->child);
91138 @@ -2457,8 +2457,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
91139 dst_ops->link_failure = xfrm_link_failure;
91140 if (likely(dst_ops->neigh_lookup == NULL))
91141 dst_ops->neigh_lookup = xfrm_neigh_lookup;
91142 - if (likely(afinfo->garbage_collect == NULL))
91143 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
91144 + if (likely(afinfo->garbage_collect == NULL)) {
91145 + pax_open_kernel();
91146 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
91147 + pax_close_kernel();
91148 + }
91149 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
91150 }
91151 spin_unlock(&xfrm_policy_afinfo_lock);
91152 @@ -2512,7 +2515,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
91153 dst_ops->check = NULL;
91154 dst_ops->negative_advice = NULL;
91155 dst_ops->link_failure = NULL;
91156 - afinfo->garbage_collect = NULL;
91157 + pax_open_kernel();
91158 + *(void **)&afinfo->garbage_collect = NULL;
91159 + pax_close_kernel();
91160 }
91161 return err;
91162 }
91163 @@ -2896,7 +2901,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
91164 sizeof(pol->xfrm_vec[i].saddr));
91165 pol->xfrm_vec[i].encap_family = mp->new_family;
91166 /* flush bundles */
91167 - atomic_inc(&pol->genid);
91168 + atomic_inc_unchecked(&pol->genid);
91169 }
91170 }
91171
91172 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
91173 index 3459692..e7cdb1a 100644
91174 --- a/net/xfrm/xfrm_state.c
91175 +++ b/net/xfrm/xfrm_state.c
91176 @@ -194,11 +194,13 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
91177
91178 if (unlikely(afinfo == NULL))
91179 return -EAFNOSUPPORT;
91180 - typemap = afinfo->type_map;
91181 + typemap = (const struct xfrm_type **)afinfo->type_map;
91182
91183 - if (likely(typemap[type->proto] == NULL))
91184 + if (likely(typemap[type->proto] == NULL)) {
91185 + pax_open_kernel();
91186 typemap[type->proto] = type;
91187 - else
91188 + pax_close_kernel();
91189 + } else
91190 err = -EEXIST;
91191 xfrm_state_unlock_afinfo(afinfo);
91192 return err;
91193 @@ -213,12 +215,15 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
91194
91195 if (unlikely(afinfo == NULL))
91196 return -EAFNOSUPPORT;
91197 - typemap = afinfo->type_map;
91198 + typemap = (const struct xfrm_type **)afinfo->type_map;
91199
91200 if (unlikely(typemap[type->proto] != type))
91201 err = -ENOENT;
91202 - else
91203 + else {
91204 + pax_open_kernel();
91205 typemap[type->proto] = NULL;
91206 + pax_close_kernel();
91207 + }
91208 xfrm_state_unlock_afinfo(afinfo);
91209 return err;
91210 }
91211 @@ -227,7 +232,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
91212 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
91213 {
91214 struct xfrm_state_afinfo *afinfo;
91215 - const struct xfrm_type **typemap;
91216 const struct xfrm_type *type;
91217 int modload_attempted = 0;
91218
91219 @@ -235,9 +239,8 @@ retry:
91220 afinfo = xfrm_state_get_afinfo(family);
91221 if (unlikely(afinfo == NULL))
91222 return NULL;
91223 - typemap = afinfo->type_map;
91224
91225 - type = typemap[proto];
91226 + type = afinfo->type_map[proto];
91227 if (unlikely(type && !try_module_get(type->owner)))
91228 type = NULL;
91229 if (!type && !modload_attempted) {
91230 @@ -270,7 +273,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
91231 return -EAFNOSUPPORT;
91232
91233 err = -EEXIST;
91234 - modemap = afinfo->mode_map;
91235 + modemap = (struct xfrm_mode **)afinfo->mode_map;
91236 if (modemap[mode->encap])
91237 goto out;
91238
91239 @@ -278,8 +281,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
91240 if (!try_module_get(afinfo->owner))
91241 goto out;
91242
91243 - mode->afinfo = afinfo;
91244 + pax_open_kernel();
91245 + *(const void **)&mode->afinfo = afinfo;
91246 modemap[mode->encap] = mode;
91247 + pax_close_kernel();
91248 err = 0;
91249
91250 out:
91251 @@ -302,9 +307,11 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
91252 return -EAFNOSUPPORT;
91253
91254 err = -ENOENT;
91255 - modemap = afinfo->mode_map;
91256 + modemap = (struct xfrm_mode **)afinfo->mode_map;
91257 if (likely(modemap[mode->encap] == mode)) {
91258 + pax_open_kernel();
91259 modemap[mode->encap] = NULL;
91260 + pax_close_kernel();
91261 module_put(mode->afinfo->owner);
91262 err = 0;
91263 }
91264 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
91265 index 05a6e3d..6716ec9 100644
91266 --- a/net/xfrm/xfrm_sysctl.c
91267 +++ b/net/xfrm/xfrm_sysctl.c
91268 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
91269
91270 int __net_init xfrm_sysctl_init(struct net *net)
91271 {
91272 - struct ctl_table *table;
91273 + ctl_table_no_const *table;
91274
91275 __xfrm_sysctl_init(net);
91276
91277 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
91278 index 0e801c3..5c8ad3b 100644
91279 --- a/scripts/Makefile.build
91280 +++ b/scripts/Makefile.build
91281 @@ -111,7 +111,7 @@ endif
91282 endif
91283
91284 # Do not include host rules unless needed
91285 -ifneq ($(hostprogs-y)$(hostprogs-m),)
91286 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
91287 include scripts/Makefile.host
91288 endif
91289
91290 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
91291 index 686cb0d..9d653bf 100644
91292 --- a/scripts/Makefile.clean
91293 +++ b/scripts/Makefile.clean
91294 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
91295 __clean-files := $(extra-y) $(always) \
91296 $(targets) $(clean-files) \
91297 $(host-progs) \
91298 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
91299 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
91300 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
91301
91302 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
91303
91304 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
91305 index 1ac414f..38575f7 100644
91306 --- a/scripts/Makefile.host
91307 +++ b/scripts/Makefile.host
91308 @@ -31,6 +31,8 @@
91309 # Note: Shared libraries consisting of C++ files are not supported
91310
91311 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
91312 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
91313 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
91314
91315 # C code
91316 # Executables compiled from a single .c file
91317 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
91318 # Shared libaries (only .c supported)
91319 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
91320 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
91321 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
91322 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
91323 # Remove .so files from "xxx-objs"
91324 host-cobjs := $(filter-out %.so,$(host-cobjs))
91325 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
91326
91327 -#Object (.o) files used by the shared libaries
91328 +# Object (.o) files used by the shared libaries
91329 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
91330 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
91331
91332 # output directory for programs/.o files
91333 # hostprogs-y := tools/build may have been specified. Retrieve directory
91334 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
91335 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
91336 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
91337 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
91338 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
91339 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
91340 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
91341 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
91342
91343 obj-dirs += $(host-objdirs)
91344 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
91345 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
91346 $(call if_changed_dep,host-cshobjs)
91347
91348 +# Compile .c file, create position independent .o file
91349 +# host-cxxshobjs -> .o
91350 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
91351 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
91352 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
91353 + $(call if_changed_dep,host-cxxshobjs)
91354 +
91355 # Link a shared library, based on position independent .o files
91356 # *.o -> .so shared library (host-cshlib)
91357 quiet_cmd_host-cshlib = HOSTLLD -shared $@
91358 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
91359 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
91360 $(call if_changed,host-cshlib)
91361
91362 +# Link a shared library, based on position independent .o files
91363 +# *.o -> .so shared library (host-cxxshlib)
91364 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
91365 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
91366 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
91367 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
91368 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
91369 + $(call if_changed,host-cxxshlib)
91370 +
91371 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
91372 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
91373 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
91374
91375 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
91376 index cb1f50c..cef2a7c 100644
91377 --- a/scripts/basic/fixdep.c
91378 +++ b/scripts/basic/fixdep.c
91379 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
91380 /*
91381 * Lookup a value in the configuration string.
91382 */
91383 -static int is_defined_config(const char *name, int len, unsigned int hash)
91384 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
91385 {
91386 struct item *aux;
91387
91388 @@ -211,10 +211,10 @@ static void clear_config(void)
91389 /*
91390 * Record the use of a CONFIG_* word.
91391 */
91392 -static void use_config(const char *m, int slen)
91393 +static void use_config(const char *m, unsigned int slen)
91394 {
91395 unsigned int hash = strhash(m, slen);
91396 - int c, i;
91397 + unsigned int c, i;
91398
91399 if (is_defined_config(m, slen, hash))
91400 return;
91401 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
91402
91403 static void parse_config_file(const char *map, size_t len)
91404 {
91405 - const int *end = (const int *) (map + len);
91406 + const unsigned int *end = (const unsigned int *) (map + len);
91407 /* start at +1, so that p can never be < map */
91408 - const int *m = (const int *) map + 1;
91409 + const unsigned int *m = (const unsigned int *) map + 1;
91410 const char *p, *q;
91411
91412 for (; m < end; m++) {
91413 @@ -406,7 +406,7 @@ static void print_deps(void)
91414 static void traps(void)
91415 {
91416 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
91417 - int *p = (int *)test;
91418 + unsigned int *p = (unsigned int *)test;
91419
91420 if (*p != INT_CONF) {
91421 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianess? %#x\n",
91422 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
91423 new file mode 100644
91424 index 0000000..5e0222d
91425 --- /dev/null
91426 +++ b/scripts/gcc-plugin.sh
91427 @@ -0,0 +1,17 @@
91428 +#!/bin/bash
91429 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
91430 +#include "gcc-plugin.h"
91431 +#include "tree.h"
91432 +#include "tm.h"
91433 +#include "rtl.h"
91434 +#ifdef ENABLE_BUILD_WITH_CXX
91435 +#warning $2
91436 +#else
91437 +#warning $1
91438 +#endif
91439 +EOF`
91440 +if [ $? -eq 0 ]
91441 +then
91442 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
91443 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
91444 +fi
91445 diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
91446 index 581ca99..a6ff02e 100644
91447 --- a/scripts/headers_install.pl
91448 +++ b/scripts/headers_install.pl
91449 @@ -35,6 +35,7 @@ foreach my $filename (@files) {
91450 $line =~ s/([\s(])__user\s/$1/g;
91451 $line =~ s/([\s(])__force\s/$1/g;
91452 $line =~ s/([\s(])__iomem\s/$1/g;
91453 + $line =~ s/(\s?)__intentional_overflow\([-\d\s,]*\)\s?/$1/g;
91454 $line =~ s/\s__attribute_const__\s/ /g;
91455 $line =~ s/\s__attribute_const__$//g;
91456 $line =~ s/\b__packed\b/__attribute__((packed))/g;
91457 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
91458 index b3d907e..a4782ab 100644
91459 --- a/scripts/link-vmlinux.sh
91460 +++ b/scripts/link-vmlinux.sh
91461 @@ -152,7 +152,7 @@ else
91462 fi;
91463
91464 # final build of init/
91465 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
91466 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
91467
91468 kallsymso=""
91469 kallsyms_vmlinux=""
91470 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
91471 index df4fc23..0ea719d 100644
91472 --- a/scripts/mod/file2alias.c
91473 +++ b/scripts/mod/file2alias.c
91474 @@ -128,7 +128,7 @@ static void device_id_check(const char *modname, const char *device_id,
91475 unsigned long size, unsigned long id_size,
91476 void *symval)
91477 {
91478 - int i;
91479 + unsigned int i;
91480
91481 if (size % id_size || size < id_size) {
91482 if (cross_build != 0)
91483 @@ -158,7 +158,7 @@ static void device_id_check(const char *modname, const char *device_id,
91484 /* USB is special because the bcdDevice can be matched against a numeric range */
91485 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
91486 static void do_usb_entry(struct usb_device_id *id,
91487 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
91488 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
91489 unsigned char range_lo, unsigned char range_hi,
91490 unsigned char max, struct module *mod)
91491 {
91492 @@ -262,7 +262,7 @@ static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod)
91493 {
91494 unsigned int devlo, devhi;
91495 unsigned char chi, clo, max;
91496 - int ndigits;
91497 + unsigned int ndigits;
91498
91499 id->match_flags = TO_NATIVE(id->match_flags);
91500 id->idVendor = TO_NATIVE(id->idVendor);
91501 @@ -507,7 +507,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
91502 for (i = 0; i < count; i++) {
91503 const char *id = (char *)devs[i].id;
91504 char acpi_id[sizeof(devs[0].id)];
91505 - int j;
91506 + unsigned int j;
91507
91508 buf_printf(&mod->dev_table_buf,
91509 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
91510 @@ -537,7 +537,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91511
91512 for (j = 0; j < PNP_MAX_DEVICES; j++) {
91513 const char *id = (char *)card->devs[j].id;
91514 - int i2, j2;
91515 + unsigned int i2, j2;
91516 int dup = 0;
91517
91518 if (!id[0])
91519 @@ -563,7 +563,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91520 /* add an individual alias for every device entry */
91521 if (!dup) {
91522 char acpi_id[sizeof(card->devs[0].id)];
91523 - int k;
91524 + unsigned int k;
91525
91526 buf_printf(&mod->dev_table_buf,
91527 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
91528 @@ -888,7 +888,7 @@ static void dmi_ascii_filter(char *d, const char *s)
91529 static int do_dmi_entry(const char *filename, struct dmi_system_id *id,
91530 char *alias)
91531 {
91532 - int i, j;
91533 + unsigned int i, j;
91534
91535 sprintf(alias, "dmi*");
91536
91537 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
91538 index ff36c50..7ab4fa9 100644
91539 --- a/scripts/mod/modpost.c
91540 +++ b/scripts/mod/modpost.c
91541 @@ -929,6 +929,7 @@ enum mismatch {
91542 ANY_INIT_TO_ANY_EXIT,
91543 ANY_EXIT_TO_ANY_INIT,
91544 EXPORT_TO_INIT_EXIT,
91545 + DATA_TO_TEXT
91546 };
91547
91548 struct sectioncheck {
91549 @@ -1043,6 +1044,12 @@ const struct sectioncheck sectioncheck[] = {
91550 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
91551 .mismatch = EXPORT_TO_INIT_EXIT,
91552 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
91553 +},
91554 +/* Do not reference code from writable data */
91555 +{
91556 + .fromsec = { DATA_SECTIONS, NULL },
91557 + .tosec = { TEXT_SECTIONS, NULL },
91558 + .mismatch = DATA_TO_TEXT
91559 }
91560 };
91561
91562 @@ -1165,10 +1172,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
91563 continue;
91564 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
91565 continue;
91566 - if (sym->st_value == addr)
91567 - return sym;
91568 /* Find a symbol nearby - addr are maybe negative */
91569 d = sym->st_value - addr;
91570 + if (d == 0)
91571 + return sym;
91572 if (d < 0)
91573 d = addr - sym->st_value;
91574 if (d < distance) {
91575 @@ -1447,6 +1454,14 @@ static void report_sec_mismatch(const char *modname,
91576 tosym, prl_to, prl_to, tosym);
91577 free(prl_to);
91578 break;
91579 + case DATA_TO_TEXT:
91580 +#if 0
91581 + fprintf(stderr,
91582 + "The %s %s:%s references\n"
91583 + "the %s %s:%s%s\n",
91584 + from, fromsec, fromsym, to, tosec, tosym, to_p);
91585 +#endif
91586 + break;
91587 }
91588 fprintf(stderr, "\n");
91589 }
91590 @@ -1681,7 +1696,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
91591 static void check_sec_ref(struct module *mod, const char *modname,
91592 struct elf_info *elf)
91593 {
91594 - int i;
91595 + unsigned int i;
91596 Elf_Shdr *sechdrs = elf->sechdrs;
91597
91598 /* Walk through all sections */
91599 @@ -1779,7 +1794,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
91600 va_end(ap);
91601 }
91602
91603 -void buf_write(struct buffer *buf, const char *s, int len)
91604 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
91605 {
91606 if (buf->size - buf->pos < len) {
91607 buf->size += len + SZ;
91608 @@ -1997,7 +2012,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
91609 if (fstat(fileno(file), &st) < 0)
91610 goto close_write;
91611
91612 - if (st.st_size != b->pos)
91613 + if (st.st_size != (off_t)b->pos)
91614 goto close_write;
91615
91616 tmp = NOFAIL(malloc(b->pos));
91617 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
91618 index 51207e4..f7d603d 100644
91619 --- a/scripts/mod/modpost.h
91620 +++ b/scripts/mod/modpost.h
91621 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
91622
91623 struct buffer {
91624 char *p;
91625 - int pos;
91626 - int size;
91627 + unsigned int pos;
91628 + unsigned int size;
91629 };
91630
91631 void __attribute__((format(printf, 2, 3)))
91632 buf_printf(struct buffer *buf, const char *fmt, ...);
91633
91634 void
91635 -buf_write(struct buffer *buf, const char *s, int len);
91636 +buf_write(struct buffer *buf, const char *s, unsigned int len);
91637
91638 struct module {
91639 struct module *next;
91640 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
91641 index 9dfcd6d..099068e 100644
91642 --- a/scripts/mod/sumversion.c
91643 +++ b/scripts/mod/sumversion.c
91644 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
91645 goto out;
91646 }
91647
91648 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
91649 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
91650 warn("writing sum in %s failed: %s\n",
91651 filename, strerror(errno));
91652 goto out;
91653 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
91654 index acb8650..b8c5f02 100644
91655 --- a/scripts/package/builddeb
91656 +++ b/scripts/package/builddeb
91657 @@ -246,6 +246,7 @@ fi
91658 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
91659 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
91660 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
91661 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
91662 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
91663 mkdir -p "$destdir"
91664 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
91665 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
91666 index 68bb4ef..2f419e1 100644
91667 --- a/scripts/pnmtologo.c
91668 +++ b/scripts/pnmtologo.c
91669 @@ -244,14 +244,14 @@ static void write_header(void)
91670 fprintf(out, " * Linux logo %s\n", logoname);
91671 fputs(" */\n\n", out);
91672 fputs("#include <linux/linux_logo.h>\n\n", out);
91673 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
91674 + fprintf(out, "static unsigned char %s_data[] = {\n",
91675 logoname);
91676 }
91677
91678 static void write_footer(void)
91679 {
91680 fputs("\n};\n\n", out);
91681 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
91682 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
91683 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
91684 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
91685 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
91686 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
91687 fputs("\n};\n\n", out);
91688
91689 /* write logo clut */
91690 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
91691 + fprintf(out, "static unsigned char %s_clut[] = {\n",
91692 logoname);
91693 write_hex_cnt = 0;
91694 for (i = 0; i < logo_clutsize; i++) {
91695 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
91696 index e4fd45b..2eeb5c4 100644
91697 --- a/scripts/sortextable.h
91698 +++ b/scripts/sortextable.h
91699 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
91700 const char *secstrtab;
91701 const char *strtab;
91702 char *extab_image;
91703 - int extab_index = 0;
91704 - int i;
91705 - int idx;
91706 + unsigned int extab_index = 0;
91707 + unsigned int i;
91708 + unsigned int idx;
91709
91710 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
91711 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
91712 diff --git a/security/Kconfig b/security/Kconfig
91713 index e9c6ac7..721e9d0 100644
91714 --- a/security/Kconfig
91715 +++ b/security/Kconfig
91716 @@ -4,6 +4,944 @@
91717
91718 menu "Security options"
91719
91720 +menu "Grsecurity"
91721 +
91722 + config ARCH_TRACK_EXEC_LIMIT
91723 + bool
91724 +
91725 + config PAX_KERNEXEC_PLUGIN
91726 + bool
91727 +
91728 + config PAX_PER_CPU_PGD
91729 + bool
91730 +
91731 + config TASK_SIZE_MAX_SHIFT
91732 + int
91733 + depends on X86_64
91734 + default 47 if !PAX_PER_CPU_PGD
91735 + default 42 if PAX_PER_CPU_PGD
91736 +
91737 + config PAX_ENABLE_PAE
91738 + bool
91739 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
91740 +
91741 + config PAX_USERCOPY_SLABS
91742 + bool
91743 +
91744 +config GRKERNSEC
91745 + bool "Grsecurity"
91746 + select CRYPTO
91747 + select CRYPTO_SHA256
91748 + select PROC_FS
91749 + select STOP_MACHINE
91750 + help
91751 + If you say Y here, you will be able to configure many features
91752 + that will enhance the security of your system. It is highly
91753 + recommended that you say Y here and read through the help
91754 + for each option so that you fully understand the features and
91755 + can evaluate their usefulness for your machine.
91756 +
91757 +choice
91758 + prompt "Configuration Method"
91759 + depends on GRKERNSEC
91760 + default GRKERNSEC_CONFIG_CUSTOM
91761 + help
91762 +
91763 +config GRKERNSEC_CONFIG_AUTO
91764 + bool "Automatic"
91765 + help
91766 + If you choose this configuration method, you'll be able to answer a small
91767 + number of simple questions about how you plan to use this kernel.
91768 + The settings of grsecurity and PaX will be automatically configured for
91769 + the highest commonly-used settings within the provided constraints.
91770 +
91771 + If you require additional configuration, custom changes can still be made
91772 + from the "custom configuration" menu.
91773 +
91774 +config GRKERNSEC_CONFIG_CUSTOM
91775 + bool "Custom"
91776 + help
91777 + If you choose this configuration method, you'll be able to configure all
91778 + grsecurity and PaX settings manually. Via this method, no options are
91779 + automatically enabled.
91780 +
91781 +endchoice
91782 +
91783 +choice
91784 + prompt "Usage Type"
91785 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91786 + default GRKERNSEC_CONFIG_SERVER
91787 + help
91788 +
91789 +config GRKERNSEC_CONFIG_SERVER
91790 + bool "Server"
91791 + help
91792 + Choose this option if you plan to use this kernel on a server.
91793 +
91794 +config GRKERNSEC_CONFIG_DESKTOP
91795 + bool "Desktop"
91796 + help
91797 + Choose this option if you plan to use this kernel on a desktop.
91798 +
91799 +endchoice
91800 +
91801 +choice
91802 + prompt "Virtualization Type"
91803 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
91804 + default GRKERNSEC_CONFIG_VIRT_NONE
91805 + help
91806 +
91807 +config GRKERNSEC_CONFIG_VIRT_NONE
91808 + bool "None"
91809 + help
91810 + Choose this option if this kernel will be run on bare metal.
91811 +
91812 +config GRKERNSEC_CONFIG_VIRT_GUEST
91813 + bool "Guest"
91814 + help
91815 + Choose this option if this kernel will be run as a VM guest.
91816 +
91817 +config GRKERNSEC_CONFIG_VIRT_HOST
91818 + bool "Host"
91819 + help
91820 + Choose this option if this kernel will be run as a VM host.
91821 +
91822 +endchoice
91823 +
91824 +choice
91825 + prompt "Virtualization Hardware"
91826 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91827 + help
91828 +
91829 +config GRKERNSEC_CONFIG_VIRT_EPT
91830 + bool "EPT/RVI Processor Support"
91831 + depends on X86
91832 + help
91833 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
91834 + hardware virtualization. This allows for additional kernel hardening protections
91835 + to operate without additional performance impact.
91836 +
91837 + To see if your Intel processor supports EPT, see:
91838 + http://ark.intel.com/Products/VirtualizationTechnology
91839 + (Most Core i3/5/7 support EPT)
91840 +
91841 + To see if your AMD processor supports RVI, see:
91842 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
91843 +
91844 +config GRKERNSEC_CONFIG_VIRT_SOFT
91845 + bool "First-gen/No Hardware Virtualization"
91846 + help
91847 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
91848 + support hardware virtualization or doesn't support the EPT/RVI extensions.
91849 +
91850 +endchoice
91851 +
91852 +choice
91853 + prompt "Virtualization Software"
91854 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91855 + help
91856 +
91857 +config GRKERNSEC_CONFIG_VIRT_XEN
91858 + bool "Xen"
91859 + help
91860 + Choose this option if this kernel is running as a Xen guest or host.
91861 +
91862 +config GRKERNSEC_CONFIG_VIRT_VMWARE
91863 + bool "VMWare"
91864 + help
91865 + Choose this option if this kernel is running as a VMWare guest or host.
91866 +
91867 +config GRKERNSEC_CONFIG_VIRT_KVM
91868 + bool "KVM"
91869 + help
91870 + Choose this option if this kernel is running as a KVM guest or host.
91871 +
91872 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
91873 + bool "VirtualBox"
91874 + help
91875 + Choose this option if this kernel is running as a VirtualBox guest or host.
91876 +
91877 +endchoice
91878 +
91879 +choice
91880 + prompt "Required Priorities"
91881 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91882 + default GRKERNSEC_CONFIG_PRIORITY_PERF
91883 + help
91884 +
91885 +config GRKERNSEC_CONFIG_PRIORITY_PERF
91886 + bool "Performance"
91887 + help
91888 + Choose this option if performance is of highest priority for this deployment
91889 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
91890 + clearing of structures intended for userland, and freed memory sanitizing will
91891 + be disabled.
91892 +
91893 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
91894 + bool "Security"
91895 + help
91896 + Choose this option if security is of highest priority for this deployment of
91897 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
91898 + for userland, and freed memory sanitizing will be enabled for this kernel.
91899 + In a worst-case scenario, these features can introduce a 20% performance hit
91900 + (UDEREF on x64 contributing half of this hit).
91901 +
91902 +endchoice
91903 +
91904 +menu "Default Special Groups"
91905 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91906 +
91907 +config GRKERNSEC_PROC_GID
91908 + int "GID exempted from /proc restrictions"
91909 + default 1001
91910 + help
91911 + Setting this GID determines which group will be exempted from
91912 + grsecurity's /proc restrictions, allowing users of the specified
91913 + group to view network statistics and the existence of other users'
91914 + processes on the system. This GID may also be chosen at boot time
91915 + via "grsec_proc_gid=" on the kernel commandline.
91916 +
91917 +config GRKERNSEC_TPE_UNTRUSTED_GID
91918 + int "GID for TPE-untrusted users"
91919 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
91920 + default 1005
91921 + help
91922 + Setting this GID determines which group untrusted users should
91923 + be added to. These users will be placed under grsecurity's Trusted Path
91924 + Execution mechanism, preventing them from executing their own binaries.
91925 + The users will only be able to execute binaries in directories owned and
91926 + writable only by the root user. If the sysctl option is enabled, a sysctl
91927 + option with name "tpe_gid" is created.
91928 +
91929 +config GRKERNSEC_TPE_TRUSTED_GID
91930 + int "GID for TPE-trusted users"
91931 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
91932 + default 1005
91933 + help
91934 + Setting this GID determines what group TPE restrictions will be
91935 + *disabled* for. If the sysctl option is enabled, a sysctl option
91936 + with name "tpe_gid" is created.
91937 +
91938 +config GRKERNSEC_SYMLINKOWN_GID
91939 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
91940 + depends on GRKERNSEC_CONFIG_SERVER
91941 + default 1006
91942 + help
91943 + Setting this GID determines what group kernel-enforced
91944 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
91945 + is enabled, a sysctl option with name "symlinkown_gid" is created.
91946 +
91947 +
91948 +endmenu
91949 +
91950 +menu "Customize Configuration"
91951 +depends on GRKERNSEC
91952 +
91953 +menu "PaX"
91954 +
91955 +config PAX
91956 + bool "Enable various PaX features"
91957 + default y if GRKERNSEC_CONFIG_AUTO
91958 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
91959 + help
91960 + This allows you to enable various PaX features. PaX adds
91961 + intrusion prevention mechanisms to the kernel that reduce
91962 + the risks posed by exploitable memory corruption bugs.
91963 +
91964 +menu "PaX Control"
91965 + depends on PAX
91966 +
91967 +config PAX_SOFTMODE
91968 + bool 'Support soft mode'
91969 + help
91970 + Enabling this option will allow you to run PaX in soft mode, that
91971 + is, PaX features will not be enforced by default, only on executables
91972 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
91973 + support as they are the only way to mark executables for soft mode use.
91974 +
91975 + Soft mode can be activated by using the "pax_softmode=1" kernel command
91976 + line option on boot. Furthermore you can control various PaX features
91977 + at runtime via the entries in /proc/sys/kernel/pax.
91978 +
91979 +config PAX_EI_PAX
91980 + bool 'Use legacy ELF header marking'
91981 + default y if GRKERNSEC_CONFIG_AUTO
91982 + help
91983 + Enabling this option will allow you to control PaX features on
91984 + a per executable basis via the 'chpax' utility available at
91985 + http://pax.grsecurity.net/. The control flags will be read from
91986 + an otherwise reserved part of the ELF header. This marking has
91987 + numerous drawbacks (no support for soft-mode, toolchain does not
91988 + know about the non-standard use of the ELF header) therefore it
91989 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
91990 + support.
91991 +
91992 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
91993 + support as well, they will override the legacy EI_PAX marks.
91994 +
91995 + If you enable none of the marking options then all applications
91996 + will run with PaX enabled on them by default.
91997 +
91998 +config PAX_PT_PAX_FLAGS
91999 + bool 'Use ELF program header marking'
92000 + default y if GRKERNSEC_CONFIG_AUTO
92001 + help
92002 + Enabling this option will allow you to control PaX features on
92003 + a per executable basis via the 'paxctl' utility available at
92004 + http://pax.grsecurity.net/. The control flags will be read from
92005 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
92006 + has the benefits of supporting both soft mode and being fully
92007 + integrated into the toolchain (the binutils patch is available
92008 + from http://pax.grsecurity.net).
92009 +
92010 + Note that if you enable the legacy EI_PAX marking support as well,
92011 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
92012 +
92013 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
92014 + must make sure that the marks are the same if a binary has both marks.
92015 +
92016 + If you enable none of the marking options then all applications
92017 + will run with PaX enabled on them by default.
92018 +
92019 +config PAX_XATTR_PAX_FLAGS
92020 + bool 'Use filesystem extended attributes marking'
92021 + default y if GRKERNSEC_CONFIG_AUTO
92022 + select CIFS_XATTR if CIFS
92023 + select EXT2_FS_XATTR if EXT2_FS
92024 + select EXT3_FS_XATTR if EXT3_FS
92025 + select EXT4_FS_XATTR if EXT4_FS
92026 + select JFFS2_FS_XATTR if JFFS2_FS
92027 + select REISERFS_FS_XATTR if REISERFS_FS
92028 + select SQUASHFS_XATTR if SQUASHFS
92029 + select TMPFS_XATTR if TMPFS
92030 + select UBIFS_FS_XATTR if UBIFS_FS
92031 + help
92032 + Enabling this option will allow you to control PaX features on
92033 + a per executable basis via the 'setfattr' utility. The control
92034 + flags will be read from the user.pax.flags extended attribute of
92035 + the file. This marking has the benefit of supporting binary-only
92036 + applications that self-check themselves (e.g., skype) and would
92037 + not tolerate chpax/paxctl changes. The main drawback is that
92038 + extended attributes are not supported by some filesystems (e.g.,
92039 + isofs, udf, vfat) so copying files through such filesystems will
92040 + lose the extended attributes and these PaX markings.
92041 +
92042 + Note that if you enable the legacy EI_PAX marking support as well,
92043 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
92044 +
92045 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
92046 + must make sure that the marks are the same if a binary has both marks.
92047 +
92048 + If you enable none of the marking options then all applications
92049 + will run with PaX enabled on them by default.
92050 +
92051 +choice
92052 + prompt 'MAC system integration'
92053 + default PAX_HAVE_ACL_FLAGS
92054 + help
92055 + Mandatory Access Control systems have the option of controlling
92056 + PaX flags on a per executable basis, choose the method supported
92057 + by your particular system.
92058 +
92059 + - "none": if your MAC system does not interact with PaX,
92060 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
92061 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
92062 +
92063 + NOTE: this option is for developers/integrators only.
92064 +
92065 + config PAX_NO_ACL_FLAGS
92066 + bool 'none'
92067 +
92068 + config PAX_HAVE_ACL_FLAGS
92069 + bool 'direct'
92070 +
92071 + config PAX_HOOK_ACL_FLAGS
92072 + bool 'hook'
92073 +endchoice
92074 +
92075 +endmenu
92076 +
92077 +menu "Non-executable pages"
92078 + depends on PAX
92079 +
92080 +config PAX_NOEXEC
92081 + bool "Enforce non-executable pages"
92082 + default y if GRKERNSEC_CONFIG_AUTO
92083 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
92084 + help
92085 + By design some architectures do not allow for protecting memory
92086 + pages against execution or even if they do, Linux does not make
92087 + use of this feature. In practice this means that if a page is
92088 + readable (such as the stack or heap) it is also executable.
92089 +
92090 + There is a well known exploit technique that makes use of this
92091 + fact and a common programming mistake where an attacker can
92092 + introduce code of his choice somewhere in the attacked program's
92093 + memory (typically the stack or the heap) and then execute it.
92094 +
92095 + If the attacked program was running with different (typically
92096 + higher) privileges than that of the attacker, then he can elevate
92097 + his own privilege level (e.g. get a root shell, write to files for
92098 + which he does not have write access to, etc).
92099 +
92100 + Enabling this option will let you choose from various features
92101 + that prevent the injection and execution of 'foreign' code in
92102 + a program.
92103 +
92104 + This will also break programs that rely on the old behaviour and
92105 + expect that dynamically allocated memory via the malloc() family
92106 + of functions is executable (which it is not). Notable examples
92107 + are the XFree86 4.x server, the java runtime and wine.
92108 +
92109 +config PAX_PAGEEXEC
92110 + bool "Paging based non-executable pages"
92111 + default y if GRKERNSEC_CONFIG_AUTO
92112 + 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)
92113 + select S390_SWITCH_AMODE if S390
92114 + select S390_EXEC_PROTECT if S390
92115 + select ARCH_TRACK_EXEC_LIMIT if X86_32
92116 + help
92117 + This implementation is based on the paging feature of the CPU.
92118 + On i386 without hardware non-executable bit support there is a
92119 + variable but usually low performance impact, however on Intel's
92120 + P4 core based CPUs it is very high so you should not enable this
92121 + for kernels meant to be used on such CPUs.
92122 +
92123 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
92124 + with hardware non-executable bit support there is no performance
92125 + impact, on ppc the impact is negligible.
92126 +
92127 + Note that several architectures require various emulations due to
92128 + badly designed userland ABIs, this will cause a performance impact
92129 + but will disappear as soon as userland is fixed. For example, ppc
92130 + userland MUST have been built with secure-plt by a recent toolchain.
92131 +
92132 +config PAX_SEGMEXEC
92133 + bool "Segmentation based non-executable pages"
92134 + default y if GRKERNSEC_CONFIG_AUTO
92135 + depends on PAX_NOEXEC && X86_32
92136 + help
92137 + This implementation is based on the segmentation feature of the
92138 + CPU and has a very small performance impact, however applications
92139 + will be limited to a 1.5 GB address space instead of the normal
92140 + 3 GB.
92141 +
92142 +config PAX_EMUTRAMP
92143 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
92144 + default y if PARISC
92145 + help
92146 + There are some programs and libraries that for one reason or
92147 + another attempt to execute special small code snippets from
92148 + non-executable memory pages. Most notable examples are the
92149 + signal handler return code generated by the kernel itself and
92150 + the GCC trampolines.
92151 +
92152 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
92153 + such programs will no longer work under your kernel.
92154 +
92155 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
92156 + utilities to enable trampoline emulation for the affected programs
92157 + yet still have the protection provided by the non-executable pages.
92158 +
92159 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
92160 + your system will not even boot.
92161 +
92162 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
92163 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
92164 + for the affected files.
92165 +
92166 + NOTE: enabling this feature *may* open up a loophole in the
92167 + protection provided by non-executable pages that an attacker
92168 + could abuse. Therefore the best solution is to not have any
92169 + files on your system that would require this option. This can
92170 + be achieved by not using libc5 (which relies on the kernel
92171 + signal handler return code) and not using or rewriting programs
92172 + that make use of the nested function implementation of GCC.
92173 + Skilled users can just fix GCC itself so that it implements
92174 + nested function calls in a way that does not interfere with PaX.
92175 +
92176 +config PAX_EMUSIGRT
92177 + bool "Automatically emulate sigreturn trampolines"
92178 + depends on PAX_EMUTRAMP && PARISC
92179 + default y
92180 + help
92181 + Enabling this option will have the kernel automatically detect
92182 + and emulate signal return trampolines executing on the stack
92183 + that would otherwise lead to task termination.
92184 +
92185 + This solution is intended as a temporary one for users with
92186 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
92187 + Modula-3 runtime, etc) or executables linked to such, basically
92188 + everything that does not specify its own SA_RESTORER function in
92189 + normal executable memory like glibc 2.1+ does.
92190 +
92191 + On parisc you MUST enable this option, otherwise your system will
92192 + not even boot.
92193 +
92194 + NOTE: this feature cannot be disabled on a per executable basis
92195 + and since it *does* open up a loophole in the protection provided
92196 + by non-executable pages, the best solution is to not have any
92197 + files on your system that would require this option.
92198 +
92199 +config PAX_MPROTECT
92200 + bool "Restrict mprotect()"
92201 + default y if GRKERNSEC_CONFIG_AUTO
92202 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
92203 + help
92204 + Enabling this option will prevent programs from
92205 + - changing the executable status of memory pages that were
92206 + not originally created as executable,
92207 + - making read-only executable pages writable again,
92208 + - creating executable pages from anonymous memory,
92209 + - making read-only-after-relocations (RELRO) data pages writable again.
92210 +
92211 + You should say Y here to complete the protection provided by
92212 + the enforcement of non-executable pages.
92213 +
92214 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
92215 + this feature on a per file basis.
92216 +
92217 +config PAX_MPROTECT_COMPAT
92218 + bool "Use legacy/compat protection demoting (read help)"
92219 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
92220 + depends on PAX_MPROTECT
92221 + help
92222 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
92223 + by sending the proper error code to the application. For some broken
92224 + userland, this can cause problems with Python or other applications. The
92225 + current implementation however allows for applications like clamav to
92226 + detect if JIT compilation/execution is allowed and to fall back gracefully
92227 + to an interpreter-based mode if it does not. While we encourage everyone
92228 + to use the current implementation as-is and push upstream to fix broken
92229 + userland (note that the RWX logging option can assist with this), in some
92230 + environments this may not be possible. Having to disable MPROTECT
92231 + completely on certain binaries reduces the security benefit of PaX,
92232 + so this option is provided for those environments to revert to the old
92233 + behavior.
92234 +
92235 +config PAX_ELFRELOCS
92236 + bool "Allow ELF text relocations (read help)"
92237 + depends on PAX_MPROTECT
92238 + default n
92239 + help
92240 + Non-executable pages and mprotect() restrictions are effective
92241 + in preventing the introduction of new executable code into an
92242 + attacked task's address space. There remain only two venues
92243 + for this kind of attack: if the attacker can execute already
92244 + existing code in the attacked task then he can either have it
92245 + create and mmap() a file containing his code or have it mmap()
92246 + an already existing ELF library that does not have position
92247 + independent code in it and use mprotect() on it to make it
92248 + writable and copy his code there. While protecting against
92249 + the former approach is beyond PaX, the latter can be prevented
92250 + by having only PIC ELF libraries on one's system (which do not
92251 + need to relocate their code). If you are sure this is your case,
92252 + as is the case with all modern Linux distributions, then leave
92253 + this option disabled. You should say 'n' here.
92254 +
92255 +config PAX_ETEXECRELOCS
92256 + bool "Allow ELF ET_EXEC text relocations"
92257 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
92258 + select PAX_ELFRELOCS
92259 + default y
92260 + help
92261 + On some architectures there are incorrectly created applications
92262 + that require text relocations and would not work without enabling
92263 + this option. If you are an alpha, ia64 or parisc user, you should
92264 + enable this option and disable it once you have made sure that
92265 + none of your applications need it.
92266 +
92267 +config PAX_EMUPLT
92268 + bool "Automatically emulate ELF PLT"
92269 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
92270 + default y
92271 + help
92272 + Enabling this option will have the kernel automatically detect
92273 + and emulate the Procedure Linkage Table entries in ELF files.
92274 + On some architectures such entries are in writable memory, and
92275 + become non-executable leading to task termination. Therefore
92276 + it is mandatory that you enable this option on alpha, parisc,
92277 + sparc and sparc64, otherwise your system would not even boot.
92278 +
92279 + NOTE: this feature *does* open up a loophole in the protection
92280 + provided by the non-executable pages, therefore the proper
92281 + solution is to modify the toolchain to produce a PLT that does
92282 + not need to be writable.
92283 +
92284 +config PAX_DLRESOLVE
92285 + bool 'Emulate old glibc resolver stub'
92286 + depends on PAX_EMUPLT && SPARC
92287 + default n
92288 + help
92289 + This option is needed if userland has an old glibc (before 2.4)
92290 + that puts a 'save' instruction into the runtime generated resolver
92291 + stub that needs special emulation.
92292 +
92293 +config PAX_KERNEXEC
92294 + bool "Enforce non-executable kernel pages"
92295 + 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))
92296 + depends on ((X86 && (!X86_32 || X86_WP_WORKS_OK)) || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
92297 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
92298 + select PAX_KERNEXEC_PLUGIN if X86_64
92299 + help
92300 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
92301 + that is, enabling this option will make it harder to inject
92302 + and execute 'foreign' code in kernel memory itself.
92303 +
92304 +choice
92305 + prompt "Return Address Instrumentation Method"
92306 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
92307 + depends on PAX_KERNEXEC_PLUGIN
92308 + help
92309 + Select the method used to instrument function pointer dereferences.
92310 + Note that binary modules cannot be instrumented by this approach.
92311 +
92312 + Note that the implementation requires a gcc with plugin support,
92313 + i.e., gcc 4.5 or newer. You may need to install the supporting
92314 + headers explicitly in addition to the normal gcc package.
92315 +
92316 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
92317 + bool "bts"
92318 + help
92319 + This method is compatible with binary only modules but has
92320 + a higher runtime overhead.
92321 +
92322 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
92323 + bool "or"
92324 + depends on !PARAVIRT
92325 + help
92326 + This method is incompatible with binary only modules but has
92327 + a lower runtime overhead.
92328 +endchoice
92329 +
92330 +config PAX_KERNEXEC_PLUGIN_METHOD
92331 + string
92332 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
92333 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
92334 + default ""
92335 +
92336 +config PAX_KERNEXEC_MODULE_TEXT
92337 + int "Minimum amount of memory reserved for module code"
92338 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
92339 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
92340 + depends on PAX_KERNEXEC && X86_32 && MODULES
92341 + help
92342 + Due to implementation details the kernel must reserve a fixed
92343 + amount of memory for module code at compile time that cannot be
92344 + changed at runtime. Here you can specify the minimum amount
92345 + in MB that will be reserved. Due to the same implementation
92346 + details this size will always be rounded up to the next 2/4 MB
92347 + boundary (depends on PAE) so the actually available memory for
92348 + module code will usually be more than this minimum.
92349 +
92350 + The default 4 MB should be enough for most users but if you have
92351 + an excessive number of modules (e.g., most distribution configs
92352 + compile many drivers as modules) or use huge modules such as
92353 + nvidia's kernel driver, you will need to adjust this amount.
92354 + A good rule of thumb is to look at your currently loaded kernel
92355 + modules and add up their sizes.
92356 +
92357 +endmenu
92358 +
92359 +menu "Address Space Layout Randomization"
92360 + depends on PAX
92361 +
92362 +config PAX_ASLR
92363 + bool "Address Space Layout Randomization"
92364 + default y if GRKERNSEC_CONFIG_AUTO
92365 + help
92366 + Many if not most exploit techniques rely on the knowledge of
92367 + certain addresses in the attacked program. The following options
92368 + will allow the kernel to apply a certain amount of randomization
92369 + to specific parts of the program thereby forcing an attacker to
92370 + guess them in most cases. Any failed guess will most likely crash
92371 + the attacked program which allows the kernel to detect such attempts
92372 + and react on them. PaX itself provides no reaction mechanisms,
92373 + instead it is strongly encouraged that you make use of Nergal's
92374 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
92375 + (http://www.grsecurity.net/) built-in crash detection features or
92376 + develop one yourself.
92377 +
92378 + By saying Y here you can choose to randomize the following areas:
92379 + - top of the task's kernel stack
92380 + - top of the task's userland stack
92381 + - base address for mmap() requests that do not specify one
92382 + (this includes all libraries)
92383 + - base address of the main executable
92384 +
92385 + It is strongly recommended to say Y here as address space layout
92386 + randomization has negligible impact on performance yet it provides
92387 + a very effective protection.
92388 +
92389 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
92390 + this feature on a per file basis.
92391 +
92392 +config PAX_RANDKSTACK
92393 + bool "Randomize kernel stack base"
92394 + default y if GRKERNSEC_CONFIG_AUTO
92395 + depends on X86_TSC && X86
92396 + help
92397 + By saying Y here the kernel will randomize every task's kernel
92398 + stack on every system call. This will not only force an attacker
92399 + to guess it but also prevent him from making use of possible
92400 + leaked information about it.
92401 +
92402 + Since the kernel stack is a rather scarce resource, randomization
92403 + may cause unexpected stack overflows, therefore you should very
92404 + carefully test your system. Note that once enabled in the kernel
92405 + configuration, this feature cannot be disabled on a per file basis.
92406 +
92407 +config PAX_RANDUSTACK
92408 + bool "Randomize user stack base"
92409 + default y if GRKERNSEC_CONFIG_AUTO
92410 + depends on PAX_ASLR
92411 + help
92412 + By saying Y here the kernel will randomize every task's userland
92413 + stack. The randomization is done in two steps where the second
92414 + one may apply a big amount of shift to the top of the stack and
92415 + cause problems for programs that want to use lots of memory (more
92416 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
92417 + For this reason the second step can be controlled by 'chpax' or
92418 + 'paxctl' on a per file basis.
92419 +
92420 +config PAX_RANDMMAP
92421 + bool "Randomize mmap() base"
92422 + default y if GRKERNSEC_CONFIG_AUTO
92423 + depends on PAX_ASLR
92424 + help
92425 + By saying Y here the kernel will use a randomized base address for
92426 + mmap() requests that do not specify one themselves. As a result
92427 + all dynamically loaded libraries will appear at random addresses
92428 + and therefore be harder to exploit by a technique where an attacker
92429 + attempts to execute library code for his purposes (e.g. spawn a
92430 + shell from an exploited program that is running at an elevated
92431 + privilege level).
92432 +
92433 + Furthermore, if a program is relinked as a dynamic ELF file, its
92434 + base address will be randomized as well, completing the full
92435 + randomization of the address space layout. Attacking such programs
92436 + becomes a guess game. You can find an example of doing this at
92437 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
92438 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
92439 +
92440 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
92441 + feature on a per file basis.
92442 +
92443 +endmenu
92444 +
92445 +menu "Miscellaneous hardening features"
92446 +
92447 +config PAX_MEMORY_SANITIZE
92448 + bool "Sanitize all freed memory"
92449 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92450 + depends on !HIBERNATION
92451 + help
92452 + By saying Y here the kernel will erase memory pages as soon as they
92453 + are freed. This in turn reduces the lifetime of data stored in the
92454 + pages, making it less likely that sensitive information such as
92455 + passwords, cryptographic secrets, etc stay in memory for too long.
92456 +
92457 + This is especially useful for programs whose runtime is short, long
92458 + lived processes and the kernel itself benefit from this as long as
92459 + they operate on whole memory pages and ensure timely freeing of pages
92460 + that may hold sensitive information.
92461 +
92462 + The tradeoff is performance impact, on a single CPU system kernel
92463 + compilation sees a 3% slowdown, other systems and workloads may vary
92464 + and you are advised to test this feature on your expected workload
92465 + before deploying it.
92466 +
92467 + Note that this feature does not protect data stored in live pages,
92468 + e.g., process memory swapped to disk may stay there for a long time.
92469 +
92470 +config PAX_MEMORY_STACKLEAK
92471 + bool "Sanitize kernel stack"
92472 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_XEN))
92473 + depends on X86
92474 + help
92475 + By saying Y here the kernel will erase the kernel stack before it
92476 + returns from a system call. This in turn reduces the information
92477 + that a kernel stack leak bug can reveal.
92478 +
92479 + Note that such a bug can still leak information that was put on
92480 + the stack by the current system call (the one eventually triggering
92481 + the bug) but traces of earlier system calls on the kernel stack
92482 + cannot leak anymore.
92483 +
92484 + The tradeoff is performance impact: on a single CPU system kernel
92485 + compilation sees a 1% slowdown, other systems and workloads may vary
92486 + and you are advised to test this feature on your expected workload
92487 + before deploying it.
92488 +
92489 + Note that the full feature requires a gcc with plugin support,
92490 + i.e., gcc 4.5 or newer. You may need to install the supporting
92491 + headers explicitly in addition to the normal gcc package. Using
92492 + older gcc versions means that functions with large enough stack
92493 + frames may leave uninitialized memory behind that may be exposed
92494 + to a later syscall leaking the stack.
92495 +
92496 +config PAX_MEMORY_STRUCTLEAK
92497 + bool "Forcibly initialize local variables copied to userland"
92498 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92499 + help
92500 + By saying Y here the kernel will zero initialize some local
92501 + variables that are going to be copied to userland. This in
92502 + turn prevents unintended information leakage from the kernel
92503 + stack should later code forget to explicitly set all parts of
92504 + the copied variable.
92505 +
92506 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
92507 + at a much smaller coverage.
92508 +
92509 + Note that the implementation requires a gcc with plugin support,
92510 + i.e., gcc 4.5 or newer. You may need to install the supporting
92511 + headers explicitly in addition to the normal gcc package.
92512 +
92513 +config PAX_MEMORY_UDEREF
92514 + bool "Prevent invalid userland pointer dereference"
92515 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
92516 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
92517 + select PAX_PER_CPU_PGD if X86_64
92518 + help
92519 + By saying Y here the kernel will be prevented from dereferencing
92520 + userland pointers in contexts where the kernel expects only kernel
92521 + pointers. This is both a useful runtime debugging feature and a
92522 + security measure that prevents exploiting a class of kernel bugs.
92523 +
92524 + The tradeoff is that some virtualization solutions may experience
92525 + a huge slowdown and therefore you should not enable this feature
92526 + for kernels meant to run in such environments. Whether a given VM
92527 + solution is affected or not is best determined by simply trying it
92528 + out, the performance impact will be obvious right on boot as this
92529 + mechanism engages from very early on. A good rule of thumb is that
92530 + VMs running on CPUs without hardware virtualization support (i.e.,
92531 + the majority of IA-32 CPUs) will likely experience the slowdown.
92532 +
92533 +config PAX_REFCOUNT
92534 + bool "Prevent various kernel object reference counter overflows"
92535 + default y if GRKERNSEC_CONFIG_AUTO
92536 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
92537 + help
92538 + By saying Y here the kernel will detect and prevent overflowing
92539 + various (but not all) kinds of object reference counters. Such
92540 + overflows can normally occur due to bugs only and are often, if
92541 + not always, exploitable.
92542 +
92543 + The tradeoff is that data structures protected by an overflowed
92544 + refcount will never be freed and therefore will leak memory. Note
92545 + that this leak also happens even without this protection but in
92546 + that case the overflow can eventually trigger the freeing of the
92547 + data structure while it is still being used elsewhere, resulting
92548 + in the exploitable situation that this feature prevents.
92549 +
92550 + Since this has a negligible performance impact, you should enable
92551 + this feature.
92552 +
92553 +config PAX_CONSTIFY_PLUGIN
92554 + bool "Automatically constify eligible structures"
92555 + default y
92556 + depends on !UML
92557 + help
92558 + By saying Y here the compiler will automatically constify a class
92559 + of types that contain only function pointers. This reduces the
92560 + kernel's attack surface and also produces a better memory layout.
92561 +
92562 + Note that the implementation requires a gcc with plugin support,
92563 + i.e., gcc 4.5 or newer. You may need to install the supporting
92564 + headers explicitly in addition to the normal gcc package.
92565 +
92566 + Note that if some code really has to modify constified variables
92567 + then the source code will have to be patched to allow it. Examples
92568 + can be found in PaX itself (the no_const attribute) and for some
92569 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
92570 +
92571 +config PAX_USERCOPY
92572 + bool "Harden heap object copies between kernel and userland"
92573 + default y if GRKERNSEC_CONFIG_AUTO
92574 + depends on ARM || IA64 || PPC || SPARC || X86
92575 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
92576 + select PAX_USERCOPY_SLABS
92577 + help
92578 + By saying Y here the kernel will enforce the size of heap objects
92579 + when they are copied in either direction between the kernel and
92580 + userland, even if only a part of the heap object is copied.
92581 +
92582 + Specifically, this checking prevents information leaking from the
92583 + kernel heap during kernel to userland copies (if the kernel heap
92584 + object is otherwise fully initialized) and prevents kernel heap
92585 + overflows during userland to kernel copies.
92586 +
92587 + Note that the current implementation provides the strictest bounds
92588 + checks for the SLUB allocator.
92589 +
92590 + Enabling this option also enables per-slab cache protection against
92591 + data in a given cache being copied into/out of via userland
92592 + accessors. Though the whitelist of regions will be reduced over
92593 + time, it notably protects important data structures like task structs.
92594 +
92595 + If frame pointers are enabled on x86, this option will also restrict
92596 + copies into and out of the kernel stack to local variables within a
92597 + single frame.
92598 +
92599 + Since this has a negligible performance impact, you should enable
92600 + this feature.
92601 +
92602 +
92603 +config PAX_USERCOPY_DEBUG
92604 + bool
92605 + depends on X86 && PAX_USERCOPY
92606 + default n
92607 +
92608 +config PAX_SIZE_OVERFLOW
92609 + bool "Prevent various integer overflows in function size parameters"
92610 + default y if GRKERNSEC_CONFIG_AUTO
92611 + depends on X86
92612 + help
92613 + By saying Y here the kernel recomputes expressions of function
92614 + arguments marked by a size_overflow attribute with double integer
92615 + precision (DImode/TImode for 32/64 bit integer types).
92616 +
92617 + The recomputed argument is checked against TYPE_MAX and an event
92618 + is logged on overflow and the triggering process is killed.
92619 +
92620 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
92621 +
92622 + Note that the implementation requires a gcc with plugin support,
92623 + i.e., gcc 4.5 or newer. You may need to install the supporting
92624 + headers explicitly in addition to the normal gcc package.
92625 +
92626 +config PAX_LATENT_ENTROPY
92627 + bool "Generate some entropy during boot"
92628 + default y if GRKERNSEC_CONFIG_AUTO
92629 + help
92630 + By saying Y here the kernel will instrument early boot code to
92631 + extract some entropy from both original and artificially created
92632 + program state. This will help especially embedded systems where
92633 + there is little 'natural' source of entropy normally. The cost
92634 + is some slowdown of the boot process.
92635 +
92636 + When pax_extra_latent_entropy is passed on the kernel command line,
92637 + entropy will be extracted from up to the first 4GB of RAM while the
92638 + runtime memory allocator is being initialized. This costs even more
92639 + slowdown of the boot process.
92640 +
92641 + Note that the implementation requires a gcc with plugin support,
92642 + i.e., gcc 4.5 or newer. You may need to install the supporting
92643 + headers explicitly in addition to the normal gcc package.
92644 +
92645 + Note that entropy extracted this way is not cryptographically
92646 + secure!
92647 +
92648 +endmenu
92649 +
92650 +endmenu
92651 +
92652 +source grsecurity/Kconfig
92653 +
92654 +endmenu
92655 +
92656 +endmenu
92657 +
92658 source security/keys/Kconfig
92659
92660 config SECURITY_DMESG_RESTRICT
92661 @@ -103,7 +1041,7 @@ config INTEL_TXT
92662 config LSM_MMAP_MIN_ADDR
92663 int "Low address space for LSM to protect from user allocation"
92664 depends on SECURITY && SECURITY_SELINUX
92665 - default 32768 if ARM
92666 + default 32768 if ALPHA || ARM || PARISC || SPARC32
92667 default 65536
92668 help
92669 This is the portion of low virtual memory which should be protected
92670 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
92671 index 8c2a7f6..b133ac9 100644
92672 --- a/security/apparmor/lsm.c
92673 +++ b/security/apparmor/lsm.c
92674 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
92675 return error;
92676 }
92677
92678 -static struct security_operations apparmor_ops = {
92679 +static struct security_operations apparmor_ops __read_only = {
92680 .name = "apparmor",
92681
92682 .ptrace_access_check = apparmor_ptrace_access_check,
92683 diff --git a/security/commoncap.c b/security/commoncap.c
92684 index 7ee08c7..8d1a9d6 100644
92685 --- a/security/commoncap.c
92686 +++ b/security/commoncap.c
92687 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
92688 return 0;
92689 }
92690
92691 +/* returns:
92692 + 1 for suid privilege
92693 + 2 for sgid privilege
92694 + 3 for fscap privilege
92695 +*/
92696 +int is_privileged_binary(const struct dentry *dentry)
92697 +{
92698 + struct cpu_vfs_cap_data capdata;
92699 + struct inode *inode = dentry->d_inode;
92700 +
92701 + if (!inode || S_ISDIR(inode->i_mode))
92702 + return 0;
92703 +
92704 + if (inode->i_mode & S_ISUID)
92705 + return 1;
92706 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
92707 + return 2;
92708 +
92709 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
92710 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
92711 + return 3;
92712 + }
92713 +
92714 + return 0;
92715 +}
92716 +
92717 /*
92718 * Attempt to get the on-exec apply capability sets for an executable file from
92719 * its xattrs and, if present, apply them to the proposed credentials being
92720 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
92721 const struct cred *cred = current_cred();
92722 kuid_t root_uid = make_kuid(cred->user_ns, 0);
92723
92724 + if (gr_acl_enable_at_secure())
92725 + return 1;
92726 +
92727 if (!uid_eq(cred->uid, root_uid)) {
92728 if (bprm->cap_effective)
92729 return 1;
92730 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
92731 index 079a85d..12e93f8 100644
92732 --- a/security/integrity/ima/ima.h
92733 +++ b/security/integrity/ima/ima.h
92734 @@ -96,8 +96,8 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
92735 extern spinlock_t ima_queue_lock;
92736
92737 struct ima_h_table {
92738 - atomic_long_t len; /* number of stored measurements in the list */
92739 - atomic_long_t violations;
92740 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
92741 + atomic_long_unchecked_t violations;
92742 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
92743 };
92744 extern struct ima_h_table ima_htable;
92745 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
92746 index 0cea3db..2f0ef77 100644
92747 --- a/security/integrity/ima/ima_api.c
92748 +++ b/security/integrity/ima/ima_api.c
92749 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
92750 int result;
92751
92752 /* can overflow, only indicator */
92753 - atomic_long_inc(&ima_htable.violations);
92754 + atomic_long_inc_unchecked(&ima_htable.violations);
92755
92756 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
92757 if (!entry) {
92758 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
92759 index 38477c9..87a60c7 100644
92760 --- a/security/integrity/ima/ima_fs.c
92761 +++ b/security/integrity/ima/ima_fs.c
92762 @@ -28,12 +28,12 @@
92763 static int valid_policy = 1;
92764 #define TMPBUFLEN 12
92765 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
92766 - loff_t *ppos, atomic_long_t *val)
92767 + loff_t *ppos, atomic_long_unchecked_t *val)
92768 {
92769 char tmpbuf[TMPBUFLEN];
92770 ssize_t len;
92771
92772 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
92773 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
92774 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
92775 }
92776
92777 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
92778 index 55a6271..ad829c3 100644
92779 --- a/security/integrity/ima/ima_queue.c
92780 +++ b/security/integrity/ima/ima_queue.c
92781 @@ -81,7 +81,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
92782 INIT_LIST_HEAD(&qe->later);
92783 list_add_tail_rcu(&qe->later, &ima_measurements);
92784
92785 - atomic_long_inc(&ima_htable.len);
92786 + atomic_long_inc_unchecked(&ima_htable.len);
92787 key = ima_hash_key(entry->digest);
92788 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
92789 return 0;
92790 diff --git a/security/keys/compat.c b/security/keys/compat.c
92791 index d65fa7f..cbfe366 100644
92792 --- a/security/keys/compat.c
92793 +++ b/security/keys/compat.c
92794 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
92795 if (ret == 0)
92796 goto no_payload_free;
92797
92798 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92799 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92800 err:
92801 if (iov != iovstack)
92802 kfree(iov);
92803 diff --git a/security/keys/key.c b/security/keys/key.c
92804 index 8fb7c7b..ba3610d 100644
92805 --- a/security/keys/key.c
92806 +++ b/security/keys/key.c
92807 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
92808
92809 atomic_set(&key->usage, 1);
92810 init_rwsem(&key->sem);
92811 - lockdep_set_class(&key->sem, &type->lock_class);
92812 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
92813 key->type = type;
92814 key->user = user;
92815 key->quotalen = quotalen;
92816 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
92817 struct key_type *p;
92818 int ret;
92819
92820 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
92821 + pax_open_kernel();
92822 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
92823 + pax_close_kernel();
92824
92825 ret = -EEXIST;
92826 down_write(&key_types_sem);
92827 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
92828 }
92829
92830 /* store the type */
92831 - list_add(&ktype->link, &key_types_list);
92832 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
92833
92834 pr_notice("Key type %s registered\n", ktype->name);
92835 ret = 0;
92836 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
92837 void unregister_key_type(struct key_type *ktype)
92838 {
92839 down_write(&key_types_sem);
92840 - list_del_init(&ktype->link);
92841 + pax_list_del_init((struct list_head *)&ktype->link);
92842 downgrade_write(&key_types_sem);
92843 key_gc_keytype(ktype);
92844 pr_notice("Key type %s unregistered\n", ktype->name);
92845 @@ -1084,10 +1086,10 @@ void __init key_init(void)
92846 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
92847
92848 /* add the special key types */
92849 - list_add_tail(&key_type_keyring.link, &key_types_list);
92850 - list_add_tail(&key_type_dead.link, &key_types_list);
92851 - list_add_tail(&key_type_user.link, &key_types_list);
92852 - list_add_tail(&key_type_logon.link, &key_types_list);
92853 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
92854 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
92855 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
92856 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
92857
92858 /* record the root user tracking */
92859 rb_link_node(&root_key_user.node,
92860 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
92861 index 4b5c948..2054dc1 100644
92862 --- a/security/keys/keyctl.c
92863 +++ b/security/keys/keyctl.c
92864 @@ -986,7 +986,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
92865 /*
92866 * Copy the iovec data from userspace
92867 */
92868 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92869 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
92870 unsigned ioc)
92871 {
92872 for (; ioc > 0; ioc--) {
92873 @@ -1008,7 +1008,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92874 * If successful, 0 will be returned.
92875 */
92876 long keyctl_instantiate_key_common(key_serial_t id,
92877 - const struct iovec *payload_iov,
92878 + const struct iovec __user *payload_iov,
92879 unsigned ioc,
92880 size_t plen,
92881 key_serial_t ringid)
92882 @@ -1103,7 +1103,7 @@ long keyctl_instantiate_key(key_serial_t id,
92883 [0].iov_len = plen
92884 };
92885
92886 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
92887 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
92888 }
92889
92890 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
92891 @@ -1136,7 +1136,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
92892 if (ret == 0)
92893 goto no_payload_free;
92894
92895 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92896 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92897 err:
92898 if (iov != iovstack)
92899 kfree(iov);
92900 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
92901 index 6ece7f2..ecdb55c 100644
92902 --- a/security/keys/keyring.c
92903 +++ b/security/keys/keyring.c
92904 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
92905 ret = -EFAULT;
92906
92907 for (loop = 0; loop < klist->nkeys; loop++) {
92908 + key_serial_t serial;
92909 key = rcu_deref_link_locked(klist, loop,
92910 keyring);
92911 + serial = key->serial;
92912
92913 tmp = sizeof(key_serial_t);
92914 if (tmp > buflen)
92915 tmp = buflen;
92916
92917 - if (copy_to_user(buffer,
92918 - &key->serial,
92919 - tmp) != 0)
92920 + if (copy_to_user(buffer, &serial, tmp))
92921 goto error;
92922
92923 buflen -= tmp;
92924 diff --git a/security/min_addr.c b/security/min_addr.c
92925 index f728728..6457a0c 100644
92926 --- a/security/min_addr.c
92927 +++ b/security/min_addr.c
92928 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
92929 */
92930 static void update_mmap_min_addr(void)
92931 {
92932 +#ifndef SPARC
92933 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
92934 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
92935 mmap_min_addr = dac_mmap_min_addr;
92936 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
92937 #else
92938 mmap_min_addr = dac_mmap_min_addr;
92939 #endif
92940 +#endif
92941 }
92942
92943 /*
92944 diff --git a/security/security.c b/security/security.c
92945 index 7b88c6a..1e3ea8f 100644
92946 --- a/security/security.c
92947 +++ b/security/security.c
92948 @@ -20,6 +20,7 @@
92949 #include <linux/ima.h>
92950 #include <linux/evm.h>
92951 #include <linux/fsnotify.h>
92952 +#include <linux/mm.h>
92953 #include <linux/mman.h>
92954 #include <linux/mount.h>
92955 #include <linux/personality.h>
92956 @@ -32,8 +33,8 @@
92957 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
92958 CONFIG_DEFAULT_SECURITY;
92959
92960 -static struct security_operations *security_ops;
92961 -static struct security_operations default_security_ops = {
92962 +static struct security_operations *security_ops __read_only;
92963 +static struct security_operations default_security_ops __read_only = {
92964 .name = "default",
92965 };
92966
92967 @@ -74,7 +75,9 @@ int __init security_init(void)
92968
92969 void reset_security_ops(void)
92970 {
92971 + pax_open_kernel();
92972 security_ops = &default_security_ops;
92973 + pax_close_kernel();
92974 }
92975
92976 /* Save user chosen LSM */
92977 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
92978 index ef26e96..642fb78 100644
92979 --- a/security/selinux/hooks.c
92980 +++ b/security/selinux/hooks.c
92981 @@ -95,8 +95,6 @@
92982
92983 #define NUM_SEL_MNT_OPTS 5
92984
92985 -extern struct security_operations *security_ops;
92986 -
92987 /* SECMARK reference count */
92988 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
92989
92990 @@ -5501,7 +5499,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
92991
92992 #endif
92993
92994 -static struct security_operations selinux_ops = {
92995 +static struct security_operations selinux_ops __read_only = {
92996 .name = "selinux",
92997
92998 .ptrace_access_check = selinux_ptrace_access_check,
92999 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
93000 index 65f67cb..3f141ef 100644
93001 --- a/security/selinux/include/xfrm.h
93002 +++ b/security/selinux/include/xfrm.h
93003 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
93004
93005 static inline void selinux_xfrm_notify_policyload(void)
93006 {
93007 - atomic_inc(&flow_cache_genid);
93008 + atomic_inc_unchecked(&flow_cache_genid);
93009 rt_genid_bump(&init_net);
93010 }
93011 #else
93012 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
93013 index 38be92c..21f49ee 100644
93014 --- a/security/smack/smack_lsm.c
93015 +++ b/security/smack/smack_lsm.c
93016 @@ -3398,7 +3398,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
93017 return 0;
93018 }
93019
93020 -struct security_operations smack_ops = {
93021 +struct security_operations smack_ops __read_only = {
93022 .name = "smack",
93023
93024 .ptrace_access_check = smack_ptrace_access_check,
93025 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
93026 index 390c646..f2f8db3 100644
93027 --- a/security/tomoyo/mount.c
93028 +++ b/security/tomoyo/mount.c
93029 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
93030 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
93031 need_dev = -1; /* dev_name is a directory */
93032 } else {
93033 + if (!capable(CAP_SYS_ADMIN)) {
93034 + error = -EPERM;
93035 + goto out;
93036 + }
93037 fstype = get_fs_type(type);
93038 if (!fstype) {
93039 error = -ENODEV;
93040 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
93041 index a2ee362..5754f34 100644
93042 --- a/security/tomoyo/tomoyo.c
93043 +++ b/security/tomoyo/tomoyo.c
93044 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
93045 * tomoyo_security_ops is a "struct security_operations" which is used for
93046 * registering TOMOYO.
93047 */
93048 -static struct security_operations tomoyo_security_ops = {
93049 +static struct security_operations tomoyo_security_ops __read_only = {
93050 .name = "tomoyo",
93051 .cred_alloc_blank = tomoyo_cred_alloc_blank,
93052 .cred_prepare = tomoyo_cred_prepare,
93053 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
93054 index 20ef514..4182bed 100644
93055 --- a/security/yama/Kconfig
93056 +++ b/security/yama/Kconfig
93057 @@ -1,6 +1,6 @@
93058 config SECURITY_YAMA
93059 bool "Yama support"
93060 - depends on SECURITY
93061 + depends on SECURITY && !GRKERNSEC
93062 select SECURITYFS
93063 select SECURITY_PATH
93064 default n
93065 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
93066 index 23414b9..f8c115e 100644
93067 --- a/security/yama/yama_lsm.c
93068 +++ b/security/yama/yama_lsm.c
93069 @@ -347,10 +347,8 @@ int yama_ptrace_traceme(struct task_struct *parent)
93070 /* Only disallow PTRACE_TRACEME on more aggressive settings. */
93071 switch (ptrace_scope) {
93072 case YAMA_SCOPE_CAPABILITY:
93073 - rcu_read_lock();
93074 - if (!ns_capable(__task_cred(parent)->user_ns, CAP_SYS_PTRACE))
93075 + if (!has_ns_capability(parent, current_user_ns(), CAP_SYS_PTRACE))
93076 rc = -EPERM;
93077 - rcu_read_unlock();
93078 break;
93079 case YAMA_SCOPE_NO_ATTACH:
93080 rc = -EPERM;
93081 @@ -367,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
93082 }
93083
93084 #ifndef CONFIG_SECURITY_YAMA_STACKED
93085 -static struct security_operations yama_ops = {
93086 +static struct security_operations yama_ops __read_only = {
93087 .name = "yama",
93088
93089 .ptrace_access_check = yama_ptrace_access_check,
93090 @@ -378,28 +376,24 @@ static struct security_operations yama_ops = {
93091 #endif
93092
93093 #ifdef CONFIG_SYSCTL
93094 +static int zero __read_only;
93095 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
93096 +
93097 static int yama_dointvec_minmax(struct ctl_table *table, int write,
93098 void __user *buffer, size_t *lenp, loff_t *ppos)
93099 {
93100 - int rc;
93101 + ctl_table_no_const yama_table;
93102
93103 if (write && !capable(CAP_SYS_PTRACE))
93104 return -EPERM;
93105
93106 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
93107 - if (rc)
93108 - return rc;
93109 -
93110 + yama_table = *table;
93111 /* Lock the max value if it ever gets set. */
93112 - if (write && *(int *)table->data == *(int *)table->extra2)
93113 - table->extra1 = table->extra2;
93114 -
93115 - return rc;
93116 + if (ptrace_scope == max_scope)
93117 + yama_table.extra1 = &max_scope;
93118 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
93119 }
93120
93121 -static int zero;
93122 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
93123 -
93124 struct ctl_path yama_sysctl_path[] = {
93125 { .procname = "kernel", },
93126 { .procname = "yama", },
93127 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
93128 index 4cedc69..e59d8a3 100644
93129 --- a/sound/aoa/codecs/onyx.c
93130 +++ b/sound/aoa/codecs/onyx.c
93131 @@ -54,7 +54,7 @@ struct onyx {
93132 spdif_locked:1,
93133 analog_locked:1,
93134 original_mute:2;
93135 - int open_count;
93136 + local_t open_count;
93137 struct codec_info *codec_info;
93138
93139 /* mutex serializes concurrent access to the device
93140 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
93141 struct onyx *onyx = cii->codec_data;
93142
93143 mutex_lock(&onyx->mutex);
93144 - onyx->open_count++;
93145 + local_inc(&onyx->open_count);
93146 mutex_unlock(&onyx->mutex);
93147
93148 return 0;
93149 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
93150 struct onyx *onyx = cii->codec_data;
93151
93152 mutex_lock(&onyx->mutex);
93153 - onyx->open_count--;
93154 - if (!onyx->open_count)
93155 + if (local_dec_and_test(&onyx->open_count))
93156 onyx->spdif_locked = onyx->analog_locked = 0;
93157 mutex_unlock(&onyx->mutex);
93158
93159 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
93160 index ffd2025..df062c9 100644
93161 --- a/sound/aoa/codecs/onyx.h
93162 +++ b/sound/aoa/codecs/onyx.h
93163 @@ -11,6 +11,7 @@
93164 #include <linux/i2c.h>
93165 #include <asm/pmac_low_i2c.h>
93166 #include <asm/prom.h>
93167 +#include <asm/local.h>
93168
93169 /* PCM3052 register definitions */
93170
93171 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
93172 index 4c1cc51..16040040 100644
93173 --- a/sound/core/oss/pcm_oss.c
93174 +++ b/sound/core/oss/pcm_oss.c
93175 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
93176 if (in_kernel) {
93177 mm_segment_t fs;
93178 fs = snd_enter_user();
93179 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
93180 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
93181 snd_leave_user(fs);
93182 } else {
93183 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
93184 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
93185 }
93186 if (ret != -EPIPE && ret != -ESTRPIPE)
93187 break;
93188 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
93189 if (in_kernel) {
93190 mm_segment_t fs;
93191 fs = snd_enter_user();
93192 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
93193 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
93194 snd_leave_user(fs);
93195 } else {
93196 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
93197 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
93198 }
93199 if (ret == -EPIPE) {
93200 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
93201 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
93202 struct snd_pcm_plugin_channel *channels;
93203 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
93204 if (!in_kernel) {
93205 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
93206 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
93207 return -EFAULT;
93208 buf = runtime->oss.buffer;
93209 }
93210 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
93211 }
93212 } else {
93213 tmp = snd_pcm_oss_write2(substream,
93214 - (const char __force *)buf,
93215 + (const char __force_kernel *)buf,
93216 runtime->oss.period_bytes, 0);
93217 if (tmp <= 0)
93218 goto err;
93219 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
93220 struct snd_pcm_runtime *runtime = substream->runtime;
93221 snd_pcm_sframes_t frames, frames1;
93222 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
93223 - char __user *final_dst = (char __force __user *)buf;
93224 + char __user *final_dst = (char __force_user *)buf;
93225 if (runtime->oss.plugin_first) {
93226 struct snd_pcm_plugin_channel *channels;
93227 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
93228 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
93229 xfer += tmp;
93230 runtime->oss.buffer_used -= tmp;
93231 } else {
93232 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
93233 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
93234 runtime->oss.period_bytes, 0);
93235 if (tmp <= 0)
93236 goto err;
93237 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
93238 size1);
93239 size1 /= runtime->channels; /* frames */
93240 fs = snd_enter_user();
93241 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
93242 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
93243 snd_leave_user(fs);
93244 }
93245 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
93246 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
93247 index af49721..e85058e 100644
93248 --- a/sound/core/pcm_compat.c
93249 +++ b/sound/core/pcm_compat.c
93250 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
93251 int err;
93252
93253 fs = snd_enter_user();
93254 - err = snd_pcm_delay(substream, &delay);
93255 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
93256 snd_leave_user(fs);
93257 if (err < 0)
93258 return err;
93259 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
93260 index 09b4286..8620fac 100644
93261 --- a/sound/core/pcm_native.c
93262 +++ b/sound/core/pcm_native.c
93263 @@ -2806,11 +2806,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
93264 switch (substream->stream) {
93265 case SNDRV_PCM_STREAM_PLAYBACK:
93266 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
93267 - (void __user *)arg);
93268 + (void __force_user *)arg);
93269 break;
93270 case SNDRV_PCM_STREAM_CAPTURE:
93271 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
93272 - (void __user *)arg);
93273 + (void __force_user *)arg);
93274 break;
93275 default:
93276 result = -EINVAL;
93277 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
93278 index 040c60e..989a19a 100644
93279 --- a/sound/core/seq/seq_device.c
93280 +++ b/sound/core/seq/seq_device.c
93281 @@ -64,7 +64,7 @@ struct ops_list {
93282 int argsize; /* argument size */
93283
93284 /* operators */
93285 - struct snd_seq_dev_ops ops;
93286 + struct snd_seq_dev_ops *ops;
93287
93288 /* registered devices */
93289 struct list_head dev_list; /* list of devices */
93290 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
93291
93292 mutex_lock(&ops->reg_mutex);
93293 /* copy driver operators */
93294 - ops->ops = *entry;
93295 + ops->ops = entry;
93296 ops->driver |= DRIVER_LOADED;
93297 ops->argsize = argsize;
93298
93299 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
93300 dev->name, ops->id, ops->argsize, dev->argsize);
93301 return -EINVAL;
93302 }
93303 - if (ops->ops.init_device(dev) >= 0) {
93304 + if (ops->ops->init_device(dev) >= 0) {
93305 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
93306 ops->num_init_devices++;
93307 } else {
93308 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
93309 dev->name, ops->id, ops->argsize, dev->argsize);
93310 return -EINVAL;
93311 }
93312 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
93313 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
93314 dev->status = SNDRV_SEQ_DEVICE_FREE;
93315 dev->driver_data = NULL;
93316 ops->num_init_devices--;
93317 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
93318 index 4e0dd22..7a1f32c 100644
93319 --- a/sound/drivers/mts64.c
93320 +++ b/sound/drivers/mts64.c
93321 @@ -29,6 +29,7 @@
93322 #include <sound/initval.h>
93323 #include <sound/rawmidi.h>
93324 #include <sound/control.h>
93325 +#include <asm/local.h>
93326
93327 #define CARD_NAME "Miditerminal 4140"
93328 #define DRIVER_NAME "MTS64"
93329 @@ -67,7 +68,7 @@ struct mts64 {
93330 struct pardevice *pardev;
93331 int pardev_claimed;
93332
93333 - int open_count;
93334 + local_t open_count;
93335 int current_midi_output_port;
93336 int current_midi_input_port;
93337 u8 mode[MTS64_NUM_INPUT_PORTS];
93338 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
93339 {
93340 struct mts64 *mts = substream->rmidi->private_data;
93341
93342 - if (mts->open_count == 0) {
93343 + if (local_read(&mts->open_count) == 0) {
93344 /* We don't need a spinlock here, because this is just called
93345 if the device has not been opened before.
93346 So there aren't any IRQs from the device */
93347 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
93348
93349 msleep(50);
93350 }
93351 - ++(mts->open_count);
93352 + local_inc(&mts->open_count);
93353
93354 return 0;
93355 }
93356 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
93357 struct mts64 *mts = substream->rmidi->private_data;
93358 unsigned long flags;
93359
93360 - --(mts->open_count);
93361 - if (mts->open_count == 0) {
93362 + if (local_dec_return(&mts->open_count) == 0) {
93363 /* We need the spinlock_irqsave here because we can still
93364 have IRQs at this point */
93365 spin_lock_irqsave(&mts->lock, flags);
93366 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
93367
93368 msleep(500);
93369
93370 - } else if (mts->open_count < 0)
93371 - mts->open_count = 0;
93372 + } else if (local_read(&mts->open_count) < 0)
93373 + local_set(&mts->open_count, 0);
93374
93375 return 0;
93376 }
93377 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
93378 index b953fb4..1999c01 100644
93379 --- a/sound/drivers/opl4/opl4_lib.c
93380 +++ b/sound/drivers/opl4/opl4_lib.c
93381 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
93382 MODULE_DESCRIPTION("OPL4 driver");
93383 MODULE_LICENSE("GPL");
93384
93385 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
93386 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
93387 {
93388 int timeout = 10;
93389 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
93390 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
93391 index 991018d..8984740 100644
93392 --- a/sound/drivers/portman2x4.c
93393 +++ b/sound/drivers/portman2x4.c
93394 @@ -48,6 +48,7 @@
93395 #include <sound/initval.h>
93396 #include <sound/rawmidi.h>
93397 #include <sound/control.h>
93398 +#include <asm/local.h>
93399
93400 #define CARD_NAME "Portman 2x4"
93401 #define DRIVER_NAME "portman"
93402 @@ -85,7 +86,7 @@ struct portman {
93403 struct pardevice *pardev;
93404 int pardev_claimed;
93405
93406 - int open_count;
93407 + local_t open_count;
93408 int mode[PORTMAN_NUM_INPUT_PORTS];
93409 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
93410 };
93411 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
93412 index ea995af..f1bfa37 100644
93413 --- a/sound/firewire/amdtp.c
93414 +++ b/sound/firewire/amdtp.c
93415 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
93416 ptr = s->pcm_buffer_pointer + data_blocks;
93417 if (ptr >= pcm->runtime->buffer_size)
93418 ptr -= pcm->runtime->buffer_size;
93419 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
93420 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
93421
93422 s->pcm_period_pointer += data_blocks;
93423 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
93424 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
93425 */
93426 void amdtp_out_stream_update(struct amdtp_out_stream *s)
93427 {
93428 - ACCESS_ONCE(s->source_node_id_field) =
93429 + ACCESS_ONCE_RW(s->source_node_id_field) =
93430 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
93431 }
93432 EXPORT_SYMBOL(amdtp_out_stream_update);
93433 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
93434 index b680c5e..061b7a0 100644
93435 --- a/sound/firewire/amdtp.h
93436 +++ b/sound/firewire/amdtp.h
93437 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
93438 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
93439 struct snd_pcm_substream *pcm)
93440 {
93441 - ACCESS_ONCE(s->pcm) = pcm;
93442 + ACCESS_ONCE_RW(s->pcm) = pcm;
93443 }
93444
93445 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
93446 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
93447 index d428ffe..751ef78 100644
93448 --- a/sound/firewire/isight.c
93449 +++ b/sound/firewire/isight.c
93450 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
93451 ptr += count;
93452 if (ptr >= runtime->buffer_size)
93453 ptr -= runtime->buffer_size;
93454 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
93455 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
93456
93457 isight->period_counter += count;
93458 if (isight->period_counter >= runtime->period_size) {
93459 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
93460 if (err < 0)
93461 return err;
93462
93463 - ACCESS_ONCE(isight->pcm_active) = true;
93464 + ACCESS_ONCE_RW(isight->pcm_active) = true;
93465
93466 return 0;
93467 }
93468 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
93469 {
93470 struct isight *isight = substream->private_data;
93471
93472 - ACCESS_ONCE(isight->pcm_active) = false;
93473 + ACCESS_ONCE_RW(isight->pcm_active) = false;
93474
93475 mutex_lock(&isight->mutex);
93476 isight_stop_streaming(isight);
93477 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
93478
93479 switch (cmd) {
93480 case SNDRV_PCM_TRIGGER_START:
93481 - ACCESS_ONCE(isight->pcm_running) = true;
93482 + ACCESS_ONCE_RW(isight->pcm_running) = true;
93483 break;
93484 case SNDRV_PCM_TRIGGER_STOP:
93485 - ACCESS_ONCE(isight->pcm_running) = false;
93486 + ACCESS_ONCE_RW(isight->pcm_running) = false;
93487 break;
93488 default:
93489 return -EINVAL;
93490 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
93491 index 844a555..985ab83 100644
93492 --- a/sound/firewire/scs1x.c
93493 +++ b/sound/firewire/scs1x.c
93494 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
93495 {
93496 struct scs *scs = stream->rmidi->private_data;
93497
93498 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
93499 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
93500 if (up) {
93501 scs->output_idle = false;
93502 tasklet_schedule(&scs->tasklet);
93503 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
93504 {
93505 struct scs *scs = stream->rmidi->private_data;
93506
93507 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
93508 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
93509 }
93510
93511 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
93512 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
93513
93514 snd_card_disconnect(scs->card);
93515
93516 - ACCESS_ONCE(scs->output) = NULL;
93517 - ACCESS_ONCE(scs->input) = NULL;
93518 + ACCESS_ONCE_RW(scs->output) = NULL;
93519 + ACCESS_ONCE_RW(scs->input) = NULL;
93520
93521 wait_event(scs->idle_wait, scs->output_idle);
93522
93523 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
93524 index 048439a..3be9f6f 100644
93525 --- a/sound/oss/sb_audio.c
93526 +++ b/sound/oss/sb_audio.c
93527 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
93528 buf16 = (signed short *)(localbuf + localoffs);
93529 while (c)
93530 {
93531 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
93532 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
93533 if (copy_from_user(lbuf8,
93534 userbuf+useroffs + p,
93535 locallen))
93536 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
93537 index 7d8803a..559f8d0 100644
93538 --- a/sound/oss/swarm_cs4297a.c
93539 +++ b/sound/oss/swarm_cs4297a.c
93540 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
93541 {
93542 struct cs4297a_state *s;
93543 u32 pwr, id;
93544 - mm_segment_t fs;
93545 int rval;
93546 #ifndef CONFIG_BCM_CS4297A_CSWARM
93547 u64 cfg;
93548 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
93549 if (!rval) {
93550 char *sb1250_duart_present;
93551
93552 +#if 0
93553 + mm_segment_t fs;
93554 fs = get_fs();
93555 set_fs(KERNEL_DS);
93556 -#if 0
93557 val = SOUND_MASK_LINE;
93558 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
93559 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
93560 val = initvol[i].vol;
93561 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
93562 }
93563 + set_fs(fs);
93564 // cs4297a_write_ac97(s, 0x18, 0x0808);
93565 #else
93566 // cs4297a_write_ac97(s, 0x5e, 0x180);
93567 cs4297a_write_ac97(s, 0x02, 0x0808);
93568 cs4297a_write_ac97(s, 0x18, 0x0808);
93569 #endif
93570 - set_fs(fs);
93571
93572 list_add(&s->list, &cs4297a_devs);
93573
93574 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
93575 index 4631a23..001ae57 100644
93576 --- a/sound/pci/ymfpci/ymfpci.h
93577 +++ b/sound/pci/ymfpci/ymfpci.h
93578 @@ -358,7 +358,7 @@ struct snd_ymfpci {
93579 spinlock_t reg_lock;
93580 spinlock_t voice_lock;
93581 wait_queue_head_t interrupt_sleep;
93582 - atomic_t interrupt_sleep_count;
93583 + atomic_unchecked_t interrupt_sleep_count;
93584 struct snd_info_entry *proc_entry;
93585 const struct firmware *dsp_microcode;
93586 const struct firmware *controller_microcode;
93587 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
93588 index 22056c5..25d3244 100644
93589 --- a/sound/pci/ymfpci/ymfpci_main.c
93590 +++ b/sound/pci/ymfpci/ymfpci_main.c
93591 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
93592 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
93593 break;
93594 }
93595 - if (atomic_read(&chip->interrupt_sleep_count)) {
93596 - atomic_set(&chip->interrupt_sleep_count, 0);
93597 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
93598 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93599 wake_up(&chip->interrupt_sleep);
93600 }
93601 __end:
93602 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
93603 continue;
93604 init_waitqueue_entry(&wait, current);
93605 add_wait_queue(&chip->interrupt_sleep, &wait);
93606 - atomic_inc(&chip->interrupt_sleep_count);
93607 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
93608 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
93609 remove_wait_queue(&chip->interrupt_sleep, &wait);
93610 }
93611 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
93612 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
93613 spin_unlock(&chip->reg_lock);
93614
93615 - if (atomic_read(&chip->interrupt_sleep_count)) {
93616 - atomic_set(&chip->interrupt_sleep_count, 0);
93617 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
93618 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93619 wake_up(&chip->interrupt_sleep);
93620 }
93621 }
93622 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
93623 spin_lock_init(&chip->reg_lock);
93624 spin_lock_init(&chip->voice_lock);
93625 init_waitqueue_head(&chip->interrupt_sleep);
93626 - atomic_set(&chip->interrupt_sleep_count, 0);
93627 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93628 chip->card = card;
93629 chip->pci = pci;
93630 chip->irq = -1;
93631 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
93632 new file mode 100644
93633 index 0000000..50f2f2f
93634 --- /dev/null
93635 +++ b/tools/gcc/.gitignore
93636 @@ -0,0 +1 @@
93637 +size_overflow_hash.h
93638 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
93639 new file mode 100644
93640 index 0000000..144dbee
93641 --- /dev/null
93642 +++ b/tools/gcc/Makefile
93643 @@ -0,0 +1,45 @@
93644 +#CC := gcc
93645 +#PLUGIN_SOURCE_FILES := pax_plugin.c
93646 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
93647 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
93648 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
93649 +
93650 +ifeq ($(PLUGINCC),$(HOSTCC))
93651 +HOSTLIBS := hostlibs
93652 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
93653 +else
93654 +HOSTLIBS := hostcxxlibs
93655 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
93656 +endif
93657 +
93658 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
93659 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
93660 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
93661 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
93662 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
93663 +$(HOSTLIBS)-y += colorize_plugin.so
93664 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
93665 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
93666 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
93667 +
93668 +always := $($(HOSTLIBS)-y)
93669 +
93670 +constify_plugin-objs := constify_plugin.o
93671 +stackleak_plugin-objs := stackleak_plugin.o
93672 +kallocstat_plugin-objs := kallocstat_plugin.o
93673 +kernexec_plugin-objs := kernexec_plugin.o
93674 +checker_plugin-objs := checker_plugin.o
93675 +colorize_plugin-objs := colorize_plugin.o
93676 +size_overflow_plugin-objs := size_overflow_plugin.o
93677 +latent_entropy_plugin-objs := latent_entropy_plugin.o
93678 +structleak_plugin-objs := structleak_plugin.o
93679 +
93680 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
93681 +
93682 +quiet_cmd_build_size_overflow_hash = GENHASH $@
93683 + cmd_build_size_overflow_hash = \
93684 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
93685 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
93686 + $(call if_changed,build_size_overflow_hash)
93687 +
93688 +targets += size_overflow_hash.h
93689 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
93690 new file mode 100644
93691 index 0000000..d41b5af
93692 --- /dev/null
93693 +++ b/tools/gcc/checker_plugin.c
93694 @@ -0,0 +1,171 @@
93695 +/*
93696 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
93697 + * Licensed under the GPL v2
93698 + *
93699 + * Note: the choice of the license means that the compilation process is
93700 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93701 + * but for the kernel it doesn't matter since it doesn't link against
93702 + * any of the gcc libraries
93703 + *
93704 + * gcc plugin to implement various sparse (source code checker) features
93705 + *
93706 + * TODO:
93707 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
93708 + *
93709 + * BUGS:
93710 + * - none known
93711 + */
93712 +#include "gcc-plugin.h"
93713 +#include "config.h"
93714 +#include "system.h"
93715 +#include "coretypes.h"
93716 +#include "tree.h"
93717 +#include "tree-pass.h"
93718 +#include "flags.h"
93719 +#include "intl.h"
93720 +#include "toplev.h"
93721 +#include "plugin.h"
93722 +//#include "expr.h" where are you...
93723 +#include "diagnostic.h"
93724 +#include "plugin-version.h"
93725 +#include "tm.h"
93726 +#include "function.h"
93727 +#include "basic-block.h"
93728 +#include "gimple.h"
93729 +#include "rtl.h"
93730 +#include "emit-rtl.h"
93731 +#include "tree-flow.h"
93732 +#include "target.h"
93733 +
93734 +extern void c_register_addr_space (const char *str, addr_space_t as);
93735 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
93736 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
93737 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
93738 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
93739 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
93740 +
93741 +extern void print_gimple_stmt(FILE *, gimple, int, int);
93742 +extern rtx emit_move_insn(rtx x, rtx y);
93743 +
93744 +int plugin_is_GPL_compatible;
93745 +
93746 +static struct plugin_info checker_plugin_info = {
93747 + .version = "201111150100",
93748 +};
93749 +
93750 +#define ADDR_SPACE_KERNEL 0
93751 +#define ADDR_SPACE_FORCE_KERNEL 1
93752 +#define ADDR_SPACE_USER 2
93753 +#define ADDR_SPACE_FORCE_USER 3
93754 +#define ADDR_SPACE_IOMEM 0
93755 +#define ADDR_SPACE_FORCE_IOMEM 0
93756 +#define ADDR_SPACE_PERCPU 0
93757 +#define ADDR_SPACE_FORCE_PERCPU 0
93758 +#define ADDR_SPACE_RCU 0
93759 +#define ADDR_SPACE_FORCE_RCU 0
93760 +
93761 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
93762 +{
93763 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
93764 +}
93765 +
93766 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
93767 +{
93768 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
93769 +}
93770 +
93771 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
93772 +{
93773 + return default_addr_space_valid_pointer_mode(mode, as);
93774 +}
93775 +
93776 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
93777 +{
93778 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
93779 +}
93780 +
93781 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
93782 +{
93783 + return default_addr_space_legitimize_address(x, oldx, mode, as);
93784 +}
93785 +
93786 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
93787 +{
93788 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
93789 + return true;
93790 +
93791 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
93792 + return true;
93793 +
93794 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
93795 + return true;
93796 +
93797 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
93798 + return true;
93799 +
93800 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
93801 + return true;
93802 +
93803 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
93804 + return true;
93805 +
93806 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
93807 + return true;
93808 +
93809 + return subset == superset;
93810 +}
93811 +
93812 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
93813 +{
93814 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
93815 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
93816 +
93817 + return op;
93818 +}
93819 +
93820 +static void register_checker_address_spaces(void *event_data, void *data)
93821 +{
93822 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
93823 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
93824 + c_register_addr_space("__user", ADDR_SPACE_USER);
93825 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
93826 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
93827 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
93828 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
93829 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
93830 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
93831 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
93832 +
93833 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
93834 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
93835 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
93836 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
93837 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
93838 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
93839 + targetm.addr_space.convert = checker_addr_space_convert;
93840 +}
93841 +
93842 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93843 +{
93844 + const char * const plugin_name = plugin_info->base_name;
93845 + const int argc = plugin_info->argc;
93846 + const struct plugin_argument * const argv = plugin_info->argv;
93847 + int i;
93848 +
93849 + if (!plugin_default_version_check(version, &gcc_version)) {
93850 + error(G_("incompatible gcc/plugin versions"));
93851 + return 1;
93852 + }
93853 +
93854 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
93855 +
93856 + for (i = 0; i < argc; ++i)
93857 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93858 +
93859 + if (TARGET_64BIT == 0)
93860 + return 0;
93861 +
93862 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
93863 +
93864 + return 0;
93865 +}
93866 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
93867 new file mode 100644
93868 index 0000000..414fe5e
93869 --- /dev/null
93870 +++ b/tools/gcc/colorize_plugin.c
93871 @@ -0,0 +1,151 @@
93872 +/*
93873 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
93874 + * Licensed under the GPL v2
93875 + *
93876 + * Note: the choice of the license means that the compilation process is
93877 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93878 + * but for the kernel it doesn't matter since it doesn't link against
93879 + * any of the gcc libraries
93880 + *
93881 + * gcc plugin to colorize diagnostic output
93882 + *
93883 + */
93884 +
93885 +#include "gcc-plugin.h"
93886 +#include "config.h"
93887 +#include "system.h"
93888 +#include "coretypes.h"
93889 +#include "tree.h"
93890 +#include "tree-pass.h"
93891 +#include "flags.h"
93892 +#include "intl.h"
93893 +#include "toplev.h"
93894 +#include "plugin.h"
93895 +#include "diagnostic.h"
93896 +#include "plugin-version.h"
93897 +#include "tm.h"
93898 +
93899 +int plugin_is_GPL_compatible;
93900 +
93901 +static struct plugin_info colorize_plugin_info = {
93902 + .version = "201302112000",
93903 + .help = NULL,
93904 +};
93905 +
93906 +#define GREEN "\033[32m\033[2m"
93907 +#define LIGHTGREEN "\033[32m\033[1m"
93908 +#define YELLOW "\033[33m\033[2m"
93909 +#define LIGHTYELLOW "\033[33m\033[1m"
93910 +#define RED "\033[31m\033[2m"
93911 +#define LIGHTRED "\033[31m\033[1m"
93912 +#define BLUE "\033[34m\033[2m"
93913 +#define LIGHTBLUE "\033[34m\033[1m"
93914 +#define BRIGHT "\033[m\033[1m"
93915 +#define NORMAL "\033[m"
93916 +
93917 +static diagnostic_starter_fn old_starter;
93918 +static diagnostic_finalizer_fn old_finalizer;
93919 +
93920 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93921 +{
93922 + const char *color;
93923 + char *newprefix;
93924 +
93925 + switch (diagnostic->kind) {
93926 + case DK_NOTE:
93927 + color = LIGHTBLUE;
93928 + break;
93929 +
93930 + case DK_PEDWARN:
93931 + case DK_WARNING:
93932 + color = LIGHTYELLOW;
93933 + break;
93934 +
93935 + case DK_ERROR:
93936 + case DK_FATAL:
93937 + case DK_ICE:
93938 + case DK_PERMERROR:
93939 + case DK_SORRY:
93940 + color = LIGHTRED;
93941 + break;
93942 +
93943 + default:
93944 + color = NORMAL;
93945 + }
93946 +
93947 + old_starter(context, diagnostic);
93948 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
93949 + return;
93950 + pp_destroy_prefix(context->printer);
93951 + pp_set_prefix(context->printer, newprefix);
93952 +}
93953 +
93954 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93955 +{
93956 + old_finalizer(context, diagnostic);
93957 +}
93958 +
93959 +static void colorize_arm(void)
93960 +{
93961 + old_starter = diagnostic_starter(global_dc);
93962 + old_finalizer = diagnostic_finalizer(global_dc);
93963 +
93964 + diagnostic_starter(global_dc) = start_colorize;
93965 + diagnostic_finalizer(global_dc) = finalize_colorize;
93966 +}
93967 +
93968 +static unsigned int execute_colorize_rearm(void)
93969 +{
93970 + if (diagnostic_starter(global_dc) == start_colorize)
93971 + return 0;
93972 +
93973 + colorize_arm();
93974 + return 0;
93975 +}
93976 +
93977 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
93978 + .pass = {
93979 + .type = SIMPLE_IPA_PASS,
93980 + .name = "colorize_rearm",
93981 +#if BUILDING_GCC_VERSION >= 4008
93982 + .optinfo_flags = OPTGROUP_NONE,
93983 +#endif
93984 + .gate = NULL,
93985 + .execute = execute_colorize_rearm,
93986 + .sub = NULL,
93987 + .next = NULL,
93988 + .static_pass_number = 0,
93989 + .tv_id = TV_NONE,
93990 + .properties_required = 0,
93991 + .properties_provided = 0,
93992 + .properties_destroyed = 0,
93993 + .todo_flags_start = 0,
93994 + .todo_flags_finish = 0
93995 + }
93996 +};
93997 +
93998 +static void colorize_start_unit(void *gcc_data, void *user_data)
93999 +{
94000 + colorize_arm();
94001 +}
94002 +
94003 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94004 +{
94005 + const char * const plugin_name = plugin_info->base_name;
94006 + struct register_pass_info colorize_rearm_pass_info = {
94007 + .pass = &pass_ipa_colorize_rearm.pass,
94008 + .reference_pass_name = "*free_lang_data",
94009 + .ref_pass_instance_number = 1,
94010 + .pos_op = PASS_POS_INSERT_AFTER
94011 + };
94012 +
94013 + if (!plugin_default_version_check(version, &gcc_version)) {
94014 + error(G_("incompatible gcc/plugin versions"));
94015 + return 1;
94016 + }
94017 +
94018 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
94019 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
94020 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
94021 + return 0;
94022 +}
94023 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
94024 new file mode 100644
94025 index 0000000..bee0acb
94026 --- /dev/null
94027 +++ b/tools/gcc/constify_plugin.c
94028 @@ -0,0 +1,518 @@
94029 +/*
94030 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
94031 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
94032 + * Licensed under the GPL v2, or (at your option) v3
94033 + *
94034 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
94035 + *
94036 + * Homepage:
94037 + * http://www.grsecurity.net/~ephox/const_plugin/
94038 + *
94039 + * Usage:
94040 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
94041 + * $ gcc -fplugin=constify_plugin.so test.c -O2
94042 + */
94043 +
94044 +#include "gcc-plugin.h"
94045 +#include "config.h"
94046 +#include "system.h"
94047 +#include "coretypes.h"
94048 +#include "tree.h"
94049 +#include "tree-pass.h"
94050 +#include "flags.h"
94051 +#include "intl.h"
94052 +#include "toplev.h"
94053 +#include "plugin.h"
94054 +#include "diagnostic.h"
94055 +#include "plugin-version.h"
94056 +#include "tm.h"
94057 +#include "function.h"
94058 +#include "basic-block.h"
94059 +#include "gimple.h"
94060 +#include "rtl.h"
94061 +#include "emit-rtl.h"
94062 +#include "tree-flow.h"
94063 +#include "target.h"
94064 +#include "langhooks.h"
94065 +
94066 +// should come from c-tree.h if only it were installed for gcc 4.5...
94067 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
94068 +
94069 +// unused type flag in all versions 4.5-4.8
94070 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
94071 +
94072 +int plugin_is_GPL_compatible;
94073 +
94074 +static struct plugin_info const_plugin_info = {
94075 + .version = "201303270300",
94076 + .help = "no-constify\tturn off constification\n",
94077 +};
94078 +
94079 +typedef struct {
94080 + bool has_fptr_field;
94081 + bool has_writable_field;
94082 + bool has_do_const_field;
94083 + bool has_no_const_field;
94084 +} constify_info;
94085 +
94086 +static const_tree get_field_type(const_tree field)
94087 +{
94088 + return strip_array_types(TREE_TYPE(field));
94089 +}
94090 +
94091 +static bool is_fptr(const_tree field)
94092 +{
94093 + const_tree ptr = get_field_type(field);
94094 +
94095 + if (TREE_CODE(ptr) != POINTER_TYPE)
94096 + return false;
94097 +
94098 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
94099 +}
94100 +
94101 +/*
94102 + * determine whether the given structure type meets the requirements for automatic constification,
94103 + * including the constification attributes on nested structure types
94104 + */
94105 +static void constifiable(const_tree node, constify_info *cinfo)
94106 +{
94107 + const_tree field;
94108 +
94109 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
94110 +
94111 + // e.g., pointer to structure fields while still constructing the structure type
94112 + if (TYPE_FIELDS(node) == NULL_TREE)
94113 + return;
94114 +
94115 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
94116 + const_tree type = get_field_type(field);
94117 + enum tree_code code = TREE_CODE(type);
94118 +
94119 + if (node == type)
94120 + continue;
94121 +
94122 + if (is_fptr(field))
94123 + cinfo->has_fptr_field = true;
94124 + else if (!TREE_READONLY(field))
94125 + cinfo->has_writable_field = true;
94126 +
94127 + if (code == RECORD_TYPE || code == UNION_TYPE) {
94128 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94129 + cinfo->has_do_const_field = true;
94130 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
94131 + cinfo->has_no_const_field = true;
94132 + else
94133 + constifiable(type, cinfo);
94134 + }
94135 + }
94136 +}
94137 +
94138 +static bool constified(const_tree node)
94139 +{
94140 + constify_info cinfo = {
94141 + .has_fptr_field = false,
94142 + .has_writable_field = false,
94143 + .has_do_const_field = false,
94144 + .has_no_const_field = false
94145 + };
94146 +
94147 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
94148 +
94149 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
94150 + gcc_assert(!TYPE_READONLY(node));
94151 + return false;
94152 + }
94153 +
94154 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
94155 + gcc_assert(TYPE_READONLY(node));
94156 + return true;
94157 + }
94158 +
94159 + constifiable(node, &cinfo);
94160 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
94161 + return false;
94162 +
94163 + return TYPE_READONLY(node);
94164 +}
94165 +
94166 +static void deconstify_tree(tree node);
94167 +
94168 +static void deconstify_type(tree type)
94169 +{
94170 + tree field;
94171 +
94172 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
94173 +
94174 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
94175 + const_tree fieldtype = get_field_type(field);
94176 +
94177 + // special case handling of simple ptr-to-same-array-type members
94178 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
94179 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
94180 +
94181 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
94182 + continue;
94183 + if (TREE_TYPE(TREE_TYPE(field)) == type)
94184 + continue;
94185 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
94186 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
94187 + TREE_TYPE(TREE_TYPE(field)) = type;
94188 + }
94189 + continue;
94190 + }
94191 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
94192 + continue;
94193 + if (!constified(fieldtype))
94194 + continue;
94195 +
94196 + deconstify_tree(field);
94197 + TREE_READONLY(field) = 0;
94198 + }
94199 + TYPE_READONLY(type) = 0;
94200 + C_TYPE_FIELDS_READONLY(type) = 0;
94201 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94202 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
94203 +}
94204 +
94205 +static void deconstify_tree(tree node)
94206 +{
94207 + tree old_type, new_type, field;
94208 +
94209 + old_type = TREE_TYPE(node);
94210 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
94211 + node = TREE_TYPE(node) = copy_node(old_type);
94212 + old_type = TREE_TYPE(old_type);
94213 + }
94214 +
94215 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
94216 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
94217 +
94218 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
94219 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
94220 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
94221 + DECL_FIELD_CONTEXT(field) = new_type;
94222 +
94223 + deconstify_type(new_type);
94224 +
94225 + TREE_TYPE(node) = new_type;
94226 +}
94227 +
94228 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94229 +{
94230 + tree type;
94231 + constify_info cinfo = {
94232 + .has_fptr_field = false,
94233 + .has_writable_field = false,
94234 + .has_do_const_field = false,
94235 + .has_no_const_field = false
94236 + };
94237 +
94238 + *no_add_attrs = true;
94239 + if (TREE_CODE(*node) == FUNCTION_DECL) {
94240 + error("%qE attribute does not apply to functions", name);
94241 + return NULL_TREE;
94242 + }
94243 +
94244 + if (TREE_CODE(*node) == PARM_DECL) {
94245 + error("%qE attribute does not apply to function parameters", name);
94246 + return NULL_TREE;
94247 + }
94248 +
94249 + if (TREE_CODE(*node) == VAR_DECL) {
94250 + error("%qE attribute does not apply to variables", name);
94251 + return NULL_TREE;
94252 + }
94253 +
94254 + if (TYPE_P(*node)) {
94255 + *no_add_attrs = false;
94256 + type = *node;
94257 + } else {
94258 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
94259 + type = TREE_TYPE(*node);
94260 + }
94261 +
94262 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
94263 + error("%qE attribute applies to struct and union types only", name);
94264 + return NULL_TREE;
94265 + }
94266 +
94267 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
94268 + error("%qE attribute is already applied to the type", name);
94269 + return NULL_TREE;
94270 + }
94271 +
94272 + if (TYPE_P(*node)) {
94273 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94274 + error("%qE attribute is incompatible with 'do_const'", name);
94275 + return NULL_TREE;
94276 + }
94277 +
94278 + constifiable(type, &cinfo);
94279 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
94280 + deconstify_tree(*node);
94281 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
94282 + return NULL_TREE;
94283 + }
94284 +
94285 + error("%qE attribute used on type that is not constified", name);
94286 + return NULL_TREE;
94287 +}
94288 +
94289 +static void constify_type(tree type)
94290 +{
94291 + TYPE_READONLY(type) = 1;
94292 + C_TYPE_FIELDS_READONLY(type) = 1;
94293 + TYPE_CONSTIFY_VISITED(type) = 1;
94294 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
94295 +}
94296 +
94297 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94298 +{
94299 + *no_add_attrs = true;
94300 + if (!TYPE_P(*node)) {
94301 + error("%qE attribute applies to types only", name);
94302 + return NULL_TREE;
94303 + }
94304 +
94305 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
94306 + error("%qE attribute applies to struct and union types only", name);
94307 + return NULL_TREE;
94308 + }
94309 +
94310 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
94311 + error("%qE attribute is already applied to the type", name);
94312 + return NULL_TREE;
94313 + }
94314 +
94315 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
94316 + error("%qE attribute is incompatible with 'no_const'", name);
94317 + return NULL_TREE;
94318 + }
94319 +
94320 + *no_add_attrs = false;
94321 + return NULL_TREE;
94322 +}
94323 +
94324 +static struct attribute_spec no_const_attr = {
94325 + .name = "no_const",
94326 + .min_length = 0,
94327 + .max_length = 0,
94328 + .decl_required = false,
94329 + .type_required = false,
94330 + .function_type_required = false,
94331 + .handler = handle_no_const_attribute,
94332 +#if BUILDING_GCC_VERSION >= 4007
94333 + .affects_type_identity = true
94334 +#endif
94335 +};
94336 +
94337 +static struct attribute_spec do_const_attr = {
94338 + .name = "do_const",
94339 + .min_length = 0,
94340 + .max_length = 0,
94341 + .decl_required = false,
94342 + .type_required = false,
94343 + .function_type_required = false,
94344 + .handler = handle_do_const_attribute,
94345 +#if BUILDING_GCC_VERSION >= 4007
94346 + .affects_type_identity = true
94347 +#endif
94348 +};
94349 +
94350 +static void register_attributes(void *event_data, void *data)
94351 +{
94352 + register_attribute(&no_const_attr);
94353 + register_attribute(&do_const_attr);
94354 +}
94355 +
94356 +static void finish_type(void *event_data, void *data)
94357 +{
94358 + tree type = (tree)event_data;
94359 + constify_info cinfo = {
94360 + .has_fptr_field = false,
94361 + .has_writable_field = false,
94362 + .has_do_const_field = false,
94363 + .has_no_const_field = false
94364 + };
94365 +
94366 + if (type == NULL_TREE || type == error_mark_node)
94367 + return;
94368 +
94369 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
94370 + return;
94371 +
94372 + constifiable(type, &cinfo);
94373 +
94374 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
94375 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94376 + return;
94377 + if (cinfo.has_writable_field)
94378 + return;
94379 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
94380 + return;
94381 + }
94382 +
94383 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
94384 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
94385 + deconstify_type(type);
94386 + TYPE_CONSTIFY_VISITED(type) = 1;
94387 + } else
94388 + error("'no_const' attribute used on type that is not constified");
94389 + return;
94390 + }
94391 +
94392 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
94393 + constify_type(type);
94394 + return;
94395 + }
94396 +
94397 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
94398 + constify_type(type);
94399 + return;
94400 + }
94401 +
94402 + deconstify_type(type);
94403 + TYPE_CONSTIFY_VISITED(type) = 1;
94404 +}
94405 +
94406 +static unsigned int check_local_variables(void)
94407 +{
94408 + unsigned int ret = 0;
94409 + tree var;
94410 +
94411 +#if BUILDING_GCC_VERSION == 4005
94412 + tree vars;
94413 +#else
94414 + unsigned int i;
94415 +#endif
94416 +
94417 +#if BUILDING_GCC_VERSION == 4005
94418 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
94419 + var = TREE_VALUE(vars);
94420 +#else
94421 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
94422 +#endif
94423 + tree type = TREE_TYPE(var);
94424 +
94425 + gcc_assert(DECL_P(var));
94426 + if (is_global_var(var))
94427 + continue;
94428 +
94429 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
94430 + continue;
94431 +
94432 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
94433 + continue;
94434 +
94435 + if (!TYPE_CONSTIFY_VISITED(type))
94436 + continue;
94437 +
94438 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
94439 + ret = 1;
94440 + }
94441 + return ret;
94442 +}
94443 +
94444 +static struct gimple_opt_pass pass_local_variable = {
94445 + {
94446 + .type = GIMPLE_PASS,
94447 + .name = "check_local_variables",
94448 +#if BUILDING_GCC_VERSION >= 4008
94449 + .optinfo_flags = OPTGROUP_NONE,
94450 +#endif
94451 + .gate = NULL,
94452 + .execute = check_local_variables,
94453 + .sub = NULL,
94454 + .next = NULL,
94455 + .static_pass_number = 0,
94456 + .tv_id = TV_NONE,
94457 + .properties_required = 0,
94458 + .properties_provided = 0,
94459 + .properties_destroyed = 0,
94460 + .todo_flags_start = 0,
94461 + .todo_flags_finish = 0
94462 + }
94463 +};
94464 +
94465 +static struct {
94466 + const char *name;
94467 + const char *asm_op;
94468 +} sections[] = {
94469 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
94470 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
94471 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
94472 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
94473 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
94474 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
94475 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
94476 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
94477 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
94478 +};
94479 +
94480 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
94481 +
94482 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
94483 +{
94484 + size_t i;
94485 +
94486 + for (i = 0; i < ARRAY_SIZE(sections); i++)
94487 + if (!strcmp(sections[i].name, name))
94488 + return 0;
94489 + return old_section_type_flags(decl, name, reloc);
94490 +}
94491 +
94492 +static void constify_start_unit(void *gcc_data, void *user_data)
94493 +{
94494 +// size_t i;
94495 +
94496 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
94497 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
94498 +// sections[i].section = get_section(sections[i].name, 0, NULL);
94499 +
94500 + old_section_type_flags = targetm.section_type_flags;
94501 + targetm.section_type_flags = constify_section_type_flags;
94502 +}
94503 +
94504 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94505 +{
94506 + const char * const plugin_name = plugin_info->base_name;
94507 + const int argc = plugin_info->argc;
94508 + const struct plugin_argument * const argv = plugin_info->argv;
94509 + int i;
94510 + bool constify = true;
94511 +
94512 + struct register_pass_info local_variable_pass_info = {
94513 + .pass = &pass_local_variable.pass,
94514 + .reference_pass_name = "ssa",
94515 + .ref_pass_instance_number = 1,
94516 + .pos_op = PASS_POS_INSERT_BEFORE
94517 + };
94518 +
94519 + if (!plugin_default_version_check(version, &gcc_version)) {
94520 + error(G_("incompatible gcc/plugin versions"));
94521 + return 1;
94522 + }
94523 +
94524 + for (i = 0; i < argc; ++i) {
94525 + if (!(strcmp(argv[i].key, "no-constify"))) {
94526 + constify = false;
94527 + continue;
94528 + }
94529 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94530 + }
94531 +
94532 + if (strcmp(lang_hooks.name, "GNU C")) {
94533 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
94534 + constify = false;
94535 + }
94536 +
94537 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
94538 + if (constify) {
94539 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
94540 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
94541 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
94542 + }
94543 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
94544 +
94545 + return 0;
94546 +}
94547 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
94548 new file mode 100644
94549 index 0000000..e518932
94550 --- /dev/null
94551 +++ b/tools/gcc/generate_size_overflow_hash.sh
94552 @@ -0,0 +1,94 @@
94553 +#!/bin/bash
94554 +
94555 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
94556 +
94557 +header1="size_overflow_hash.h"
94558 +database="size_overflow_hash.data"
94559 +n=65536
94560 +
94561 +usage() {
94562 +cat <<EOF
94563 +usage: $0 options
94564 +OPTIONS:
94565 + -h|--help help
94566 + -o header file
94567 + -d database file
94568 + -n hash array size
94569 +EOF
94570 + return 0
94571 +}
94572 +
94573 +while true
94574 +do
94575 + case "$1" in
94576 + -h|--help) usage && exit 0;;
94577 + -n) n=$2; shift 2;;
94578 + -o) header1="$2"; shift 2;;
94579 + -d) database="$2"; shift 2;;
94580 + --) shift 1; break ;;
94581 + *) break ;;
94582 + esac
94583 +done
94584 +
94585 +create_defines() {
94586 + for i in `seq 0 31`
94587 + do
94588 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
94589 + done
94590 + echo >> "$header1"
94591 +}
94592 +
94593 +create_structs() {
94594 + rm -f "$header1"
94595 +
94596 + create_defines
94597 +
94598 + cat "$database" | while read data
94599 + do
94600 + data_array=($data)
94601 + struct_hash_name="${data_array[0]}"
94602 + funcn="${data_array[1]}"
94603 + params="${data_array[2]}"
94604 + next="${data_array[4]}"
94605 +
94606 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
94607 +
94608 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
94609 + echo -en "\t.param\t= " >> "$header1"
94610 + line=
94611 + for param_num in ${params//-/ };
94612 + do
94613 + line="${line}PARAM"$param_num"|"
94614 + done
94615 +
94616 + echo -e "${line%?},\n};\n" >> "$header1"
94617 + done
94618 +}
94619 +
94620 +create_headers() {
94621 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
94622 +}
94623 +
94624 +create_array_elements() {
94625 + index=0
94626 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
94627 + do
94628 + data_array=($data)
94629 + i="${data_array[3]}"
94630 + hash="${data_array[0]}"
94631 + while [[ $index -lt $i ]]
94632 + do
94633 + echo -e "\t["$index"]\t= NULL," >> "$header1"
94634 + index=$(($index + 1))
94635 + done
94636 + index=$(($index + 1))
94637 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
94638 + done
94639 + echo '};' >> $header1
94640 +}
94641 +
94642 +create_structs
94643 +create_headers
94644 +create_array_elements
94645 +
94646 +exit 0
94647 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
94648 new file mode 100644
94649 index 0000000..568b360
94650 --- /dev/null
94651 +++ b/tools/gcc/kallocstat_plugin.c
94652 @@ -0,0 +1,170 @@
94653 +/*
94654 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
94655 + * Licensed under the GPL v2
94656 + *
94657 + * Note: the choice of the license means that the compilation process is
94658 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94659 + * but for the kernel it doesn't matter since it doesn't link against
94660 + * any of the gcc libraries
94661 + *
94662 + * gcc plugin to find the distribution of k*alloc sizes
94663 + *
94664 + * TODO:
94665 + *
94666 + * BUGS:
94667 + * - none known
94668 + */
94669 +#include "gcc-plugin.h"
94670 +#include "config.h"
94671 +#include "system.h"
94672 +#include "coretypes.h"
94673 +#include "tree.h"
94674 +#include "tree-pass.h"
94675 +#include "flags.h"
94676 +#include "intl.h"
94677 +#include "toplev.h"
94678 +#include "plugin.h"
94679 +//#include "expr.h" where are you...
94680 +#include "diagnostic.h"
94681 +#include "plugin-version.h"
94682 +#include "tm.h"
94683 +#include "function.h"
94684 +#include "basic-block.h"
94685 +#include "gimple.h"
94686 +#include "rtl.h"
94687 +#include "emit-rtl.h"
94688 +
94689 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94690 +
94691 +int plugin_is_GPL_compatible;
94692 +
94693 +static const char * const kalloc_functions[] = {
94694 + "__kmalloc",
94695 + "kmalloc",
94696 + "kmalloc_large",
94697 + "kmalloc_node",
94698 + "kmalloc_order",
94699 + "kmalloc_order_trace",
94700 + "kmalloc_slab",
94701 + "kzalloc",
94702 + "kzalloc_node",
94703 +};
94704 +
94705 +static struct plugin_info kallocstat_plugin_info = {
94706 + .version = "201302112000",
94707 +};
94708 +
94709 +static unsigned int execute_kallocstat(void);
94710 +
94711 +static struct gimple_opt_pass kallocstat_pass = {
94712 + .pass = {
94713 + .type = GIMPLE_PASS,
94714 + .name = "kallocstat",
94715 +#if BUILDING_GCC_VERSION >= 4008
94716 + .optinfo_flags = OPTGROUP_NONE,
94717 +#endif
94718 + .gate = NULL,
94719 + .execute = execute_kallocstat,
94720 + .sub = NULL,
94721 + .next = NULL,
94722 + .static_pass_number = 0,
94723 + .tv_id = TV_NONE,
94724 + .properties_required = 0,
94725 + .properties_provided = 0,
94726 + .properties_destroyed = 0,
94727 + .todo_flags_start = 0,
94728 + .todo_flags_finish = 0
94729 + }
94730 +};
94731 +
94732 +static bool is_kalloc(const char *fnname)
94733 +{
94734 + size_t i;
94735 +
94736 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
94737 + if (!strcmp(fnname, kalloc_functions[i]))
94738 + return true;
94739 + return false;
94740 +}
94741 +
94742 +static unsigned int execute_kallocstat(void)
94743 +{
94744 + basic_block bb;
94745 +
94746 + // 1. loop through BBs and GIMPLE statements
94747 + FOR_EACH_BB(bb) {
94748 + gimple_stmt_iterator gsi;
94749 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94750 + // gimple match:
94751 + tree fndecl, size;
94752 + gimple call_stmt;
94753 + const char *fnname;
94754 +
94755 + // is it a call
94756 + call_stmt = gsi_stmt(gsi);
94757 + if (!is_gimple_call(call_stmt))
94758 + continue;
94759 + fndecl = gimple_call_fndecl(call_stmt);
94760 + if (fndecl == NULL_TREE)
94761 + continue;
94762 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
94763 + continue;
94764 +
94765 + // is it a call to k*alloc
94766 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
94767 + if (!is_kalloc(fnname))
94768 + continue;
94769 +
94770 + // is the size arg the result of a simple const assignment
94771 + size = gimple_call_arg(call_stmt, 0);
94772 + while (true) {
94773 + gimple def_stmt;
94774 + expanded_location xloc;
94775 + size_t size_val;
94776 +
94777 + if (TREE_CODE(size) != SSA_NAME)
94778 + break;
94779 + def_stmt = SSA_NAME_DEF_STMT(size);
94780 + if (!def_stmt || !is_gimple_assign(def_stmt))
94781 + break;
94782 + if (gimple_num_ops(def_stmt) != 2)
94783 + break;
94784 + size = gimple_assign_rhs1(def_stmt);
94785 + if (!TREE_CONSTANT(size))
94786 + continue;
94787 + xloc = expand_location(gimple_location(def_stmt));
94788 + if (!xloc.file)
94789 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
94790 + size_val = TREE_INT_CST_LOW(size);
94791 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
94792 + break;
94793 + }
94794 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
94795 +//debug_tree(gimple_call_fn(call_stmt));
94796 +//print_node(stderr, "pax", fndecl, 4);
94797 + }
94798 + }
94799 +
94800 + return 0;
94801 +}
94802 +
94803 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94804 +{
94805 + const char * const plugin_name = plugin_info->base_name;
94806 + struct register_pass_info kallocstat_pass_info = {
94807 + .pass = &kallocstat_pass.pass,
94808 + .reference_pass_name = "ssa",
94809 + .ref_pass_instance_number = 1,
94810 + .pos_op = PASS_POS_INSERT_AFTER
94811 + };
94812 +
94813 + if (!plugin_default_version_check(version, &gcc_version)) {
94814 + error(G_("incompatible gcc/plugin versions"));
94815 + return 1;
94816 + }
94817 +
94818 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
94819 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
94820 +
94821 + return 0;
94822 +}
94823 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
94824 new file mode 100644
94825 index 0000000..0408e06
94826 --- /dev/null
94827 +++ b/tools/gcc/kernexec_plugin.c
94828 @@ -0,0 +1,465 @@
94829 +/*
94830 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
94831 + * Licensed under the GPL v2
94832 + *
94833 + * Note: the choice of the license means that the compilation process is
94834 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94835 + * but for the kernel it doesn't matter since it doesn't link against
94836 + * any of the gcc libraries
94837 + *
94838 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
94839 + *
94840 + * TODO:
94841 + *
94842 + * BUGS:
94843 + * - none known
94844 + */
94845 +#include "gcc-plugin.h"
94846 +#include "config.h"
94847 +#include "system.h"
94848 +#include "coretypes.h"
94849 +#include "tree.h"
94850 +#include "tree-pass.h"
94851 +#include "flags.h"
94852 +#include "intl.h"
94853 +#include "toplev.h"
94854 +#include "plugin.h"
94855 +//#include "expr.h" where are you...
94856 +#include "diagnostic.h"
94857 +#include "plugin-version.h"
94858 +#include "tm.h"
94859 +#include "function.h"
94860 +#include "basic-block.h"
94861 +#include "gimple.h"
94862 +#include "rtl.h"
94863 +#include "emit-rtl.h"
94864 +#include "tree-flow.h"
94865 +
94866 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94867 +extern rtx emit_move_insn(rtx x, rtx y);
94868 +
94869 +#if BUILDING_GCC_VERSION <= 4006
94870 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
94871 +#endif
94872 +
94873 +#if BUILDING_GCC_VERSION >= 4008
94874 +#define TODO_dump_func 0
94875 +#endif
94876 +
94877 +int plugin_is_GPL_compatible;
94878 +
94879 +static struct plugin_info kernexec_plugin_info = {
94880 + .version = "201302112000",
94881 + .help = "method=[bts|or]\tinstrumentation method\n"
94882 +};
94883 +
94884 +static unsigned int execute_kernexec_reload(void);
94885 +static unsigned int execute_kernexec_fptr(void);
94886 +static unsigned int execute_kernexec_retaddr(void);
94887 +static bool kernexec_cmodel_check(void);
94888 +
94889 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
94890 +static void (*kernexec_instrument_retaddr)(rtx);
94891 +
94892 +static struct gimple_opt_pass kernexec_reload_pass = {
94893 + .pass = {
94894 + .type = GIMPLE_PASS,
94895 + .name = "kernexec_reload",
94896 +#if BUILDING_GCC_VERSION >= 4008
94897 + .optinfo_flags = OPTGROUP_NONE,
94898 +#endif
94899 + .gate = kernexec_cmodel_check,
94900 + .execute = execute_kernexec_reload,
94901 + .sub = NULL,
94902 + .next = NULL,
94903 + .static_pass_number = 0,
94904 + .tv_id = TV_NONE,
94905 + .properties_required = 0,
94906 + .properties_provided = 0,
94907 + .properties_destroyed = 0,
94908 + .todo_flags_start = 0,
94909 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94910 + }
94911 +};
94912 +
94913 +static struct gimple_opt_pass kernexec_fptr_pass = {
94914 + .pass = {
94915 + .type = GIMPLE_PASS,
94916 + .name = "kernexec_fptr",
94917 +#if BUILDING_GCC_VERSION >= 4008
94918 + .optinfo_flags = OPTGROUP_NONE,
94919 +#endif
94920 + .gate = kernexec_cmodel_check,
94921 + .execute = execute_kernexec_fptr,
94922 + .sub = NULL,
94923 + .next = NULL,
94924 + .static_pass_number = 0,
94925 + .tv_id = TV_NONE,
94926 + .properties_required = 0,
94927 + .properties_provided = 0,
94928 + .properties_destroyed = 0,
94929 + .todo_flags_start = 0,
94930 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94931 + }
94932 +};
94933 +
94934 +static struct rtl_opt_pass kernexec_retaddr_pass = {
94935 + .pass = {
94936 + .type = RTL_PASS,
94937 + .name = "kernexec_retaddr",
94938 +#if BUILDING_GCC_VERSION >= 4008
94939 + .optinfo_flags = OPTGROUP_NONE,
94940 +#endif
94941 + .gate = kernexec_cmodel_check,
94942 + .execute = execute_kernexec_retaddr,
94943 + .sub = NULL,
94944 + .next = NULL,
94945 + .static_pass_number = 0,
94946 + .tv_id = TV_NONE,
94947 + .properties_required = 0,
94948 + .properties_provided = 0,
94949 + .properties_destroyed = 0,
94950 + .todo_flags_start = 0,
94951 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
94952 + }
94953 +};
94954 +
94955 +static bool kernexec_cmodel_check(void)
94956 +{
94957 + tree section;
94958 +
94959 + if (ix86_cmodel != CM_KERNEL)
94960 + return false;
94961 +
94962 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
94963 + if (!section || !TREE_VALUE(section))
94964 + return true;
94965 +
94966 + section = TREE_VALUE(TREE_VALUE(section));
94967 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
94968 + return true;
94969 +
94970 + return false;
94971 +}
94972 +
94973 +/*
94974 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
94975 + */
94976 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
94977 +{
94978 + gimple asm_movabs_stmt;
94979 +
94980 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
94981 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
94982 + gimple_asm_set_volatile(asm_movabs_stmt, true);
94983 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
94984 + update_stmt(asm_movabs_stmt);
94985 +}
94986 +
94987 +/*
94988 + * find all asm() stmts that clobber r10 and add a reload of r10
94989 + */
94990 +static unsigned int execute_kernexec_reload(void)
94991 +{
94992 + basic_block bb;
94993 +
94994 + // 1. loop through BBs and GIMPLE statements
94995 + FOR_EACH_BB(bb) {
94996 + gimple_stmt_iterator gsi;
94997 +
94998 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94999 + // gimple match: __asm__ ("" : : : "r10");
95000 + gimple asm_stmt;
95001 + size_t nclobbers;
95002 +
95003 + // is it an asm ...
95004 + asm_stmt = gsi_stmt(gsi);
95005 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
95006 + continue;
95007 +
95008 + // ... clobbering r10
95009 + nclobbers = gimple_asm_nclobbers(asm_stmt);
95010 + while (nclobbers--) {
95011 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
95012 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
95013 + continue;
95014 + kernexec_reload_fptr_mask(&gsi);
95015 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
95016 + break;
95017 + }
95018 + }
95019 + }
95020 +
95021 + return 0;
95022 +}
95023 +
95024 +/*
95025 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
95026 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
95027 + */
95028 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
95029 +{
95030 + gimple assign_intptr, assign_new_fptr, call_stmt;
95031 + tree intptr, old_fptr, new_fptr, kernexec_mask;
95032 +
95033 + call_stmt = gsi_stmt(*gsi);
95034 + old_fptr = gimple_call_fn(call_stmt);
95035 +
95036 + // create temporary unsigned long variable used for bitops and cast fptr to it
95037 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
95038 +#if BUILDING_GCC_VERSION <= 4007
95039 + add_referenced_var(intptr);
95040 + mark_sym_for_renaming(intptr);
95041 +#endif
95042 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
95043 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
95044 + update_stmt(assign_intptr);
95045 +
95046 + // apply logical or to temporary unsigned long and bitmask
95047 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
95048 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
95049 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
95050 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
95051 + update_stmt(assign_intptr);
95052 +
95053 + // cast temporary unsigned long back to a temporary fptr variable
95054 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
95055 +#if BUILDING_GCC_VERSION <= 4007
95056 + add_referenced_var(new_fptr);
95057 + mark_sym_for_renaming(new_fptr);
95058 +#endif
95059 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
95060 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
95061 + update_stmt(assign_new_fptr);
95062 +
95063 + // replace call stmt fn with the new fptr
95064 + gimple_call_set_fn(call_stmt, new_fptr);
95065 + update_stmt(call_stmt);
95066 +}
95067 +
95068 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
95069 +{
95070 + gimple asm_or_stmt, call_stmt;
95071 + tree old_fptr, new_fptr, input, output;
95072 +#if BUILDING_GCC_VERSION <= 4007
95073 + VEC(tree, gc) *inputs = NULL;
95074 + VEC(tree, gc) *outputs = NULL;
95075 +#else
95076 + vec<tree, va_gc> *inputs = NULL;
95077 + vec<tree, va_gc> *outputs = NULL;
95078 +#endif
95079 +
95080 + call_stmt = gsi_stmt(*gsi);
95081 + old_fptr = gimple_call_fn(call_stmt);
95082 +
95083 + // create temporary fptr variable
95084 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
95085 +#if BUILDING_GCC_VERSION <= 4007
95086 + add_referenced_var(new_fptr);
95087 + mark_sym_for_renaming(new_fptr);
95088 +#endif
95089 +
95090 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
95091 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
95092 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
95093 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
95094 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
95095 +#if BUILDING_GCC_VERSION <= 4007
95096 + VEC_safe_push(tree, gc, inputs, input);
95097 + VEC_safe_push(tree, gc, outputs, output);
95098 +#else
95099 + vec_safe_push(inputs, input);
95100 + vec_safe_push(outputs, output);
95101 +#endif
95102 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
95103 + gimple_asm_set_volatile(asm_or_stmt, true);
95104 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
95105 + update_stmt(asm_or_stmt);
95106 +
95107 + // replace call stmt fn with the new fptr
95108 + gimple_call_set_fn(call_stmt, new_fptr);
95109 + update_stmt(call_stmt);
95110 +}
95111 +
95112 +/*
95113 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
95114 + */
95115 +static unsigned int execute_kernexec_fptr(void)
95116 +{
95117 + basic_block bb;
95118 +
95119 + // 1. loop through BBs and GIMPLE statements
95120 + FOR_EACH_BB(bb) {
95121 + gimple_stmt_iterator gsi;
95122 +
95123 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
95124 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
95125 + tree fn;
95126 + gimple call_stmt;
95127 +
95128 + // is it a call ...
95129 + call_stmt = gsi_stmt(gsi);
95130 + if (!is_gimple_call(call_stmt))
95131 + continue;
95132 + fn = gimple_call_fn(call_stmt);
95133 + if (TREE_CODE(fn) == ADDR_EXPR)
95134 + continue;
95135 + if (TREE_CODE(fn) != SSA_NAME)
95136 + gcc_unreachable();
95137 +
95138 + // ... through a function pointer
95139 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
95140 + fn = SSA_NAME_VAR(fn);
95141 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
95142 + debug_tree(fn);
95143 + gcc_unreachable();
95144 + }
95145 + }
95146 + fn = TREE_TYPE(fn);
95147 + if (TREE_CODE(fn) != POINTER_TYPE)
95148 + continue;
95149 + fn = TREE_TYPE(fn);
95150 + if (TREE_CODE(fn) != FUNCTION_TYPE)
95151 + continue;
95152 +
95153 + kernexec_instrument_fptr(&gsi);
95154 +
95155 +//debug_tree(gimple_call_fn(call_stmt));
95156 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
95157 + }
95158 + }
95159 +
95160 + return 0;
95161 +}
95162 +
95163 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
95164 +static void kernexec_instrument_retaddr_bts(rtx insn)
95165 +{
95166 + rtx btsq;
95167 + rtvec argvec, constraintvec, labelvec;
95168 + int line;
95169 +
95170 + // create asm volatile("btsq $63,(%%rsp)":::)
95171 + argvec = rtvec_alloc(0);
95172 + constraintvec = rtvec_alloc(0);
95173 + labelvec = rtvec_alloc(0);
95174 + line = expand_location(RTL_LOCATION(insn)).line;
95175 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
95176 + MEM_VOLATILE_P(btsq) = 1;
95177 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
95178 + emit_insn_before(btsq, insn);
95179 +}
95180 +
95181 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
95182 +static void kernexec_instrument_retaddr_or(rtx insn)
95183 +{
95184 + rtx orq;
95185 + rtvec argvec, constraintvec, labelvec;
95186 + int line;
95187 +
95188 + // create asm volatile("orq %%r10,(%%rsp)":::)
95189 + argvec = rtvec_alloc(0);
95190 + constraintvec = rtvec_alloc(0);
95191 + labelvec = rtvec_alloc(0);
95192 + line = expand_location(RTL_LOCATION(insn)).line;
95193 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
95194 + MEM_VOLATILE_P(orq) = 1;
95195 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
95196 + emit_insn_before(orq, insn);
95197 +}
95198 +
95199 +/*
95200 + * find all asm level function returns and forcibly set the highest bit of the return address
95201 + */
95202 +static unsigned int execute_kernexec_retaddr(void)
95203 +{
95204 + rtx insn;
95205 +
95206 + // 1. find function returns
95207 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
95208 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
95209 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
95210 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
95211 + rtx body;
95212 +
95213 + // is it a retn
95214 + if (!JUMP_P(insn))
95215 + continue;
95216 + body = PATTERN(insn);
95217 + if (GET_CODE(body) == PARALLEL)
95218 + body = XVECEXP(body, 0, 0);
95219 + if (!ANY_RETURN_P(body))
95220 + continue;
95221 + kernexec_instrument_retaddr(insn);
95222 + }
95223 +
95224 +// print_simple_rtl(stderr, get_insns());
95225 +// print_rtl(stderr, get_insns());
95226 +
95227 + return 0;
95228 +}
95229 +
95230 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95231 +{
95232 + const char * const plugin_name = plugin_info->base_name;
95233 + const int argc = plugin_info->argc;
95234 + const struct plugin_argument * const argv = plugin_info->argv;
95235 + int i;
95236 + struct register_pass_info kernexec_reload_pass_info = {
95237 + .pass = &kernexec_reload_pass.pass,
95238 + .reference_pass_name = "ssa",
95239 + .ref_pass_instance_number = 1,
95240 + .pos_op = PASS_POS_INSERT_AFTER
95241 + };
95242 + struct register_pass_info kernexec_fptr_pass_info = {
95243 + .pass = &kernexec_fptr_pass.pass,
95244 + .reference_pass_name = "ssa",
95245 + .ref_pass_instance_number = 1,
95246 + .pos_op = PASS_POS_INSERT_AFTER
95247 + };
95248 + struct register_pass_info kernexec_retaddr_pass_info = {
95249 + .pass = &kernexec_retaddr_pass.pass,
95250 + .reference_pass_name = "pro_and_epilogue",
95251 + .ref_pass_instance_number = 1,
95252 + .pos_op = PASS_POS_INSERT_AFTER
95253 + };
95254 +
95255 + if (!plugin_default_version_check(version, &gcc_version)) {
95256 + error(G_("incompatible gcc/plugin versions"));
95257 + return 1;
95258 + }
95259 +
95260 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
95261 +
95262 + if (TARGET_64BIT == 0)
95263 + return 0;
95264 +
95265 + for (i = 0; i < argc; ++i) {
95266 + if (!strcmp(argv[i].key, "method")) {
95267 + if (!argv[i].value) {
95268 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
95269 + continue;
95270 + }
95271 + if (!strcmp(argv[i].value, "bts")) {
95272 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
95273 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
95274 + } else if (!strcmp(argv[i].value, "or")) {
95275 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
95276 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
95277 + fix_register("r10", 1, 1);
95278 + } else
95279 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
95280 + continue;
95281 + }
95282 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
95283 + }
95284 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
95285 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
95286 +
95287 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
95288 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
95289 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
95290 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
95291 +
95292 + return 0;
95293 +}
95294 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
95295 new file mode 100644
95296 index 0000000..b5395ba
95297 --- /dev/null
95298 +++ b/tools/gcc/latent_entropy_plugin.c
95299 @@ -0,0 +1,327 @@
95300 +/*
95301 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
95302 + * Licensed under the GPL v2
95303 + *
95304 + * Note: the choice of the license means that the compilation process is
95305 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95306 + * but for the kernel it doesn't matter since it doesn't link against
95307 + * any of the gcc libraries
95308 + *
95309 + * gcc plugin to help generate a little bit of entropy from program state,
95310 + * used during boot in the kernel
95311 + *
95312 + * TODO:
95313 + * - add ipa pass to identify not explicitly marked candidate functions
95314 + * - mix in more program state (function arguments/return values, loop variables, etc)
95315 + * - more instrumentation control via attribute parameters
95316 + *
95317 + * BUGS:
95318 + * - LTO needs -flto-partition=none for now
95319 + */
95320 +#include "gcc-plugin.h"
95321 +#include "config.h"
95322 +#include "system.h"
95323 +#include "coretypes.h"
95324 +#include "tree.h"
95325 +#include "tree-pass.h"
95326 +#include "flags.h"
95327 +#include "intl.h"
95328 +#include "toplev.h"
95329 +#include "plugin.h"
95330 +//#include "expr.h" where are you...
95331 +#include "diagnostic.h"
95332 +#include "plugin-version.h"
95333 +#include "tm.h"
95334 +#include "function.h"
95335 +#include "basic-block.h"
95336 +#include "gimple.h"
95337 +#include "rtl.h"
95338 +#include "emit-rtl.h"
95339 +#include "tree-flow.h"
95340 +#include "langhooks.h"
95341 +
95342 +#if BUILDING_GCC_VERSION >= 4008
95343 +#define TODO_dump_func 0
95344 +#endif
95345 +
95346 +int plugin_is_GPL_compatible;
95347 +
95348 +static tree latent_entropy_decl;
95349 +
95350 +static struct plugin_info latent_entropy_plugin_info = {
95351 + .version = "201303102320",
95352 + .help = NULL
95353 +};
95354 +
95355 +static unsigned int execute_latent_entropy(void);
95356 +static bool gate_latent_entropy(void);
95357 +
95358 +static struct gimple_opt_pass latent_entropy_pass = {
95359 + .pass = {
95360 + .type = GIMPLE_PASS,
95361 + .name = "latent_entropy",
95362 +#if BUILDING_GCC_VERSION >= 4008
95363 + .optinfo_flags = OPTGROUP_NONE,
95364 +#endif
95365 + .gate = gate_latent_entropy,
95366 + .execute = execute_latent_entropy,
95367 + .sub = NULL,
95368 + .next = NULL,
95369 + .static_pass_number = 0,
95370 + .tv_id = TV_NONE,
95371 + .properties_required = PROP_gimple_leh | PROP_cfg,
95372 + .properties_provided = 0,
95373 + .properties_destroyed = 0,
95374 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
95375 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
95376 + }
95377 +};
95378 +
95379 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
95380 +{
95381 + if (TREE_CODE(*node) != FUNCTION_DECL) {
95382 + *no_add_attrs = true;
95383 + error("%qE attribute only applies to functions", name);
95384 + }
95385 + return NULL_TREE;
95386 +}
95387 +
95388 +static struct attribute_spec latent_entropy_attr = {
95389 + .name = "latent_entropy",
95390 + .min_length = 0,
95391 + .max_length = 0,
95392 + .decl_required = true,
95393 + .type_required = false,
95394 + .function_type_required = false,
95395 + .handler = handle_latent_entropy_attribute,
95396 +#if BUILDING_GCC_VERSION >= 4007
95397 + .affects_type_identity = false
95398 +#endif
95399 +};
95400 +
95401 +static void register_attributes(void *event_data, void *data)
95402 +{
95403 + register_attribute(&latent_entropy_attr);
95404 +}
95405 +
95406 +static bool gate_latent_entropy(void)
95407 +{
95408 + tree latent_entropy_attr;
95409 +
95410 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
95411 + return latent_entropy_attr != NULL_TREE;
95412 +}
95413 +
95414 +static unsigned HOST_WIDE_INT seed;
95415 +static unsigned HOST_WIDE_INT get_random_const(void)
95416 +{
95417 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
95418 + return seed;
95419 +}
95420 +
95421 +static enum tree_code get_op(tree *rhs)
95422 +{
95423 + static enum tree_code op;
95424 + unsigned HOST_WIDE_INT random_const;
95425 +
95426 + random_const = get_random_const();
95427 +
95428 + switch (op) {
95429 + case BIT_XOR_EXPR:
95430 + op = PLUS_EXPR;
95431 + break;
95432 +
95433 + case PLUS_EXPR:
95434 + if (rhs) {
95435 + op = LROTATE_EXPR;
95436 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
95437 + break;
95438 + }
95439 +
95440 + case LROTATE_EXPR:
95441 + default:
95442 + op = BIT_XOR_EXPR;
95443 + break;
95444 + }
95445 + if (rhs)
95446 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
95447 + return op;
95448 +}
95449 +
95450 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
95451 +{
95452 + gimple_stmt_iterator gsi;
95453 + gimple assign;
95454 + tree addxorrol, rhs;
95455 + enum tree_code op;
95456 +
95457 + op = get_op(&rhs);
95458 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
95459 + assign = gimple_build_assign(local_entropy, addxorrol);
95460 +#if BUILDING_GCC_VERSION <= 4007
95461 + find_referenced_vars_in(assign);
95462 +#endif
95463 +//debug_bb(bb);
95464 + gsi = gsi_after_labels(bb);
95465 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
95466 + update_stmt(assign);
95467 +}
95468 +
95469 +static void perturb_latent_entropy(basic_block bb, tree rhs)
95470 +{
95471 + gimple_stmt_iterator gsi;
95472 + gimple assign;
95473 + tree addxorrol, temp;
95474 +
95475 + // 1. create temporary copy of latent_entropy
95476 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
95477 +#if BUILDING_GCC_VERSION <= 4007
95478 + add_referenced_var(temp);
95479 + mark_sym_for_renaming(temp);
95480 +#endif
95481 +
95482 + // 2. read...
95483 + assign = gimple_build_assign(temp, latent_entropy_decl);
95484 +#if BUILDING_GCC_VERSION <= 4007
95485 + find_referenced_vars_in(assign);
95486 +#endif
95487 + gsi = gsi_after_labels(bb);
95488 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95489 + update_stmt(assign);
95490 +
95491 + // 3. ...modify...
95492 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
95493 + assign = gimple_build_assign(temp, addxorrol);
95494 +#if BUILDING_GCC_VERSION <= 4007
95495 + find_referenced_vars_in(assign);
95496 +#endif
95497 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95498 + update_stmt(assign);
95499 +
95500 + // 4. ...write latent_entropy
95501 + assign = gimple_build_assign(latent_entropy_decl, temp);
95502 +#if BUILDING_GCC_VERSION <= 4007
95503 + find_referenced_vars_in(assign);
95504 +#endif
95505 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95506 + update_stmt(assign);
95507 +}
95508 +
95509 +static unsigned int execute_latent_entropy(void)
95510 +{
95511 + basic_block bb;
95512 + gimple assign;
95513 + gimple_stmt_iterator gsi;
95514 + tree local_entropy;
95515 +
95516 + if (!latent_entropy_decl) {
95517 + struct varpool_node *node;
95518 +
95519 +#if BUILDING_GCC_VERSION <= 4007
95520 + for (node = varpool_nodes; node; node = node->next) {
95521 + tree var = node->decl;
95522 +#else
95523 + FOR_EACH_VARIABLE(node) {
95524 + tree var = node->symbol.decl;
95525 +#endif
95526 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
95527 + continue;
95528 + latent_entropy_decl = var;
95529 +// debug_tree(var);
95530 + break;
95531 + }
95532 + if (!latent_entropy_decl) {
95533 +// debug_tree(current_function_decl);
95534 + return 0;
95535 + }
95536 + }
95537 +
95538 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
95539 +
95540 + // 1. create local entropy variable
95541 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
95542 +#if BUILDING_GCC_VERSION <= 4007
95543 + add_referenced_var(local_entropy);
95544 + mark_sym_for_renaming(local_entropy);
95545 +#endif
95546 +
95547 + // 2. initialize local entropy variable
95548 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
95549 + if (dom_info_available_p(CDI_DOMINATORS))
95550 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
95551 + gsi = gsi_start_bb(bb);
95552 +
95553 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
95554 +// gimple_set_location(assign, loc);
95555 +#if BUILDING_GCC_VERSION <= 4007
95556 + find_referenced_vars_in(assign);
95557 +#endif
95558 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95559 + update_stmt(assign);
95560 + bb = bb->next_bb;
95561 +
95562 + // 3. instrument each BB with an operation on the local entropy variable
95563 + while (bb != EXIT_BLOCK_PTR) {
95564 + perturb_local_entropy(bb, local_entropy);
95565 + bb = bb->next_bb;
95566 + };
95567 +
95568 + // 4. mix local entropy into the global entropy variable
95569 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
95570 + return 0;
95571 +}
95572 +
95573 +static void start_unit_callback(void *gcc_data, void *user_data)
95574 +{
95575 + tree latent_entropy_type;
95576 +
95577 +#if BUILDING_GCC_VERSION >= 4007
95578 + seed = get_random_seed(false);
95579 +#else
95580 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
95581 + seed *= seed;
95582 +#endif
95583 +
95584 + if (in_lto_p)
95585 + return;
95586 +
95587 + // extern volatile u64 latent_entropy
95588 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
95589 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
95590 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
95591 +
95592 + TREE_STATIC(latent_entropy_decl) = 1;
95593 + TREE_PUBLIC(latent_entropy_decl) = 1;
95594 + TREE_USED(latent_entropy_decl) = 1;
95595 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
95596 + DECL_EXTERNAL(latent_entropy_decl) = 1;
95597 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
95598 + DECL_INITIAL(latent_entropy_decl) = NULL;
95599 + lang_hooks.decls.pushdecl(latent_entropy_decl);
95600 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
95601 +// varpool_finalize_decl(latent_entropy_decl);
95602 +// varpool_mark_needed_node(latent_entropy_decl);
95603 +}
95604 +
95605 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95606 +{
95607 + const char * const plugin_name = plugin_info->base_name;
95608 + struct register_pass_info latent_entropy_pass_info = {
95609 + .pass = &latent_entropy_pass.pass,
95610 + .reference_pass_name = "optimized",
95611 + .ref_pass_instance_number = 1,
95612 + .pos_op = PASS_POS_INSERT_BEFORE
95613 + };
95614 +
95615 + if (!plugin_default_version_check(version, &gcc_version)) {
95616 + error(G_("incompatible gcc/plugin versions"));
95617 + return 1;
95618 + }
95619 +
95620 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
95621 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
95622 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
95623 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
95624 +
95625 + return 0;
95626 +}
95627 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
95628 new file mode 100644
95629 index 0000000..ddd5b2e
95630 --- /dev/null
95631 +++ b/tools/gcc/size_overflow_hash.data
95632 @@ -0,0 +1,5876 @@
95633 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
95634 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
95635 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
95636 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
95637 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
95638 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
95639 +padzero_55 padzero 1 55 &sel_read_policyvers_55
95640 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
95641 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
95642 +DepcaSignature_80 DepcaSignature 2 80 NULL nohasharray
95643 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 &DepcaSignature_80
95644 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
95645 +load_msg_95 load_msg 2 95 NULL
95646 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
95647 +init_q_132 init_q 4 132 NULL
95648 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
95649 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
95650 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
95651 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
95652 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
95653 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
95654 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
95655 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
95656 +br_port_info_size_268 br_port_info_size 0 268 NULL
95657 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
95658 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
95659 +syslog_print_307 syslog_print 2 307 NULL
95660 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
95661 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
95662 +next_node_allowed_318 next_node_allowed 1 318 NULL
95663 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
95664 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
95665 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
95666 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
95667 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
95668 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
95669 +pidlist_resize_496 pidlist_resize 2 496 NULL
95670 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
95671 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
95672 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
95673 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0-1-2 537 NULL
95674 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
95675 +dle_count_543 dle_count 0 543 NULL
95676 +devres_alloc_551 devres_alloc 2 551 NULL
95677 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
95678 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
95679 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
95680 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
95681 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
95682 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
95683 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
95684 +isp1760_register_628 isp1760_register 1-2 628 NULL
95685 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
95686 +unlink_queued_645 unlink_queued 3-4 645 NULL
95687 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
95688 +ceph_copy_user_to_page_vector_656 ceph_copy_user_to_page_vector 4-3 656 NULL
95689 +div_u64_rem_672 div_u64_rem 0 672 NULL
95690 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
95691 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
95692 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
95693 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
95694 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
95695 +wm8962_gpio_direction_out_738 wm8962_gpio_direction_out 2 738 NULL
95696 +dvb_video_write_754 dvb_video_write 3 754 NULL
95697 +iwl_read_targ_mem_772 iwl_read_targ_mem 0 772 NULL
95698 +snd_pcm_drain_811 snd_pcm_drain 0 811 NULL
95699 +if_writecmd_815 if_writecmd 2 815 NULL
95700 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
95701 +read_fifo_826 read_fifo 3 826 NULL
95702 +read_tree_block_841 read_tree_block 3 841 NULL
95703 +um_idi_read_850 um_idi_read 3 850 NULL
95704 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
95705 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
95706 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
95707 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
95708 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
95709 +readw_931 readw 0 931 NULL
95710 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
95711 +ieee80211_ie_build_vht_cap_956 ieee80211_ie_build_vht_cap 0 956 NULL nohasharray
95712 +__nodes_weight_956 __nodes_weight 2-0 956 &ieee80211_ie_build_vht_cap_956
95713 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
95714 +hdlcdev_rx_997 hdlcdev_rx 3 997 NULL
95715 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
95716 +lp872x_select_buck_vout_addr_1045 lp872x_select_buck_vout_addr 0 1045 NULL
95717 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
95718 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
95719 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
95720 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
95721 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
95722 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
95723 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
95724 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
95725 +store_risefalltime_1109 store_risefalltime 5 1109 NULL
95726 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
95727 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
95728 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
95729 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
95730 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
95731 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
95732 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
95733 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
95734 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
95735 +thin_status_1239 thin_status 5 1239 NULL
95736 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
95737 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
95738 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
95739 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
95740 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
95741 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
95742 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
95743 +ffs_1322 ffs 0 1322 NULL
95744 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
95745 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
95746 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
95747 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
95748 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
95749 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
95750 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
95751 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
95752 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
95753 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
95754 +zone_page_state_1393 zone_page_state 0 1393 NULL
95755 +file_read_actor_1401 file_read_actor 4 1401 NULL
95756 +lm3533_als_get_threshold_reg_1404 lm3533_als_get_threshold_reg 0-1 1404 NULL
95757 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
95758 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
95759 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
95760 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
95761 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
95762 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
95763 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
95764 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
95765 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
95766 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
95767 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
95768 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
95769 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
95770 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
95771 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
95772 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
95773 +rmap_add_1677 rmap_add 3 1677 NULL
95774 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
95775 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
95776 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
95777 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
95778 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
95779 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
95780 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
95781 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
95782 +cosa_write_1774 cosa_write 3 1774 NULL
95783 +update_macheader_1775 update_macheader 7 1775 NULL
95784 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
95785 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
95786 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
95787 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
95788 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
95789 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
95790 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
95791 +read_swap_header_1957 read_swap_header 0 1957 NULL
95792 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
95793 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
95794 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2 1992 NULL
95795 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
95796 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
95797 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
95798 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
95799 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
95800 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
95801 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
95802 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
95803 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
95804 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
95805 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
95806 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
95807 +get_unaligned_le32_2092 get_unaligned_le32 0 2092 NULL
95808 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
95809 +audit_expand_2098 audit_expand 2 2098 NULL
95810 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
95811 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
95812 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
95813 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
95814 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
95815 +pcf50633_write_block_2124 pcf50633_write_block 3-2 2124 NULL
95816 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
95817 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL nohasharray
95818 +multipath_status_2151 multipath_status 5 2151 &mlx4_init_icm_table_2151
95819 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
95820 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
95821 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
95822 +u32_array_read_2219 u32_array_read 3 2219 NULL
95823 +vhci_write_2224 vhci_write 3 2224 NULL
95824 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
95825 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
95826 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
95827 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
95828 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
95829 +do_update_counters_2259 do_update_counters 4 2259 NULL
95830 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
95831 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
95832 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4 2308 NULL
95833 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
95834 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
95835 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
95836 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
95837 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
95838 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
95839 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
95840 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
95841 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
95842 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
95843 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
95844 +raid1_size_2419 raid1_size 0-2 2419 NULL
95845 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
95846 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
95847 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
95848 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
95849 +nfs4_alloc_slots_2454 nfs4_alloc_slots 1 2454 NULL nohasharray
95850 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 &nfs4_alloc_slots_2454
95851 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
95852 +update_pmkid_2481 update_pmkid 4 2481 NULL
95853 +wiphy_new_2482 wiphy_new 2 2482 NULL
95854 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
95855 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
95856 +dm_write_2513 dm_write 3 2513 NULL
95857 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
95858 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
95859 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
95860 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
95861 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
95862 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
95863 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
95864 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
95865 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
95866 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
95867 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
95868 +__next_cpu_2782 __next_cpu 1 2782 NULL
95869 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
95870 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL nohasharray
95871 +snd_pcm_reset_2829 snd_pcm_reset 0 2829 &vb2_dc_get_userptr_2829
95872 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
95873 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
95874 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
95875 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
95876 +__swab64p_2875 __swab64p 0 2875 NULL
95877 +nla_padlen_2883 nla_padlen 1 2883 NULL
95878 +cmm_write_2896 cmm_write 3 2896 NULL
95879 +rbd_req_sync_read_2915 rbd_req_sync_read 4-5 2915 NULL
95880 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
95881 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
95882 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
95883 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
95884 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
95885 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
95886 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
95887 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
95888 +depth_write_3021 depth_write 3 3021 NULL
95889 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
95890 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
95891 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
95892 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
95893 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
95894 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
95895 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
95896 +free_coherent_3082 free_coherent 4-2 3082 NULL
95897 +ttusb2_msg_3100 ttusb2_msg 4 3100 NULL
95898 +rb_alloc_3102 rb_alloc 1 3102 NULL
95899 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
95900 +print_time_3132 print_time 0 3132 NULL
95901 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
95902 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
95903 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
95904 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
95905 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
95906 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
95907 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
95908 +alloc_context_3194 alloc_context 1 3194 NULL
95909 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
95910 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
95911 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
95912 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
95913 +key_key_read_3241 key_key_read 3 3241 NULL
95914 +number_3243 number 0 3243 NULL
95915 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
95916 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
95917 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
95918 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
95919 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
95920 +de600_read_byte_3332 de600_read_byte 0 3332 NULL
95921 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
95922 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
95923 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
95924 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
95925 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
95926 +scnprintf_3360 scnprintf 0-2 3360 NULL nohasharray
95927 +tps65090_clr_bits_3360 tps65090_clr_bits 2 3360 &scnprintf_3360
95928 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
95929 +send_stream_3397 send_stream 4 3397 NULL
95930 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
95931 +msix_map_region_3411 msix_map_region 3 3411 NULL
95932 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
95933 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
95934 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
95935 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
95936 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
95937 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
95938 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
95939 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
95940 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
95941 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
95942 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
95943 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
95944 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
95945 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
95946 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
95947 +evtchn_read_3569 evtchn_read 3 3569 NULL
95948 +vc_resize_3585 vc_resize 2-3 3585 NULL
95949 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
95950 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
95951 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
95952 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
95953 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
95954 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
95955 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
95956 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
95957 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
95958 +ntfs_attr_make_non_resident_3694 ntfs_attr_make_non_resident 0 3694 NULL
95959 +create_irq_3703 create_irq 0 3703 NULL nohasharray
95960 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703 nohasharray
95961 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 &btmrvl_psmode_write_3703
95962 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
95963 +lm3533_als_get_threshold_3725 lm3533_als_get_threshold 2 3725 NULL
95964 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
95965 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
95966 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
95967 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
95968 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
95969 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
95970 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
95971 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
95972 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
95973 +get_fd_set_3866 get_fd_set 1 3866 NULL
95974 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
95975 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
95976 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
95977 +nvram_write_3894 nvram_write 3 3894 NULL
95978 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
95979 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
95980 +vcs_write_3910 vcs_write 3 3910 NULL
95981 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
95982 +do_add_counters_3992 do_add_counters 3 3992 NULL
95983 +userspace_status_4004 userspace_status 4 4004 NULL
95984 +mei_write_4005 mei_write 3 4005 NULL nohasharray
95985 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
95986 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
95987 +blk_end_request_4024 blk_end_request 3 4024 NULL
95988 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
95989 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
95990 +read_file_queues_4078 read_file_queues 3 4078 NULL
95991 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
95992 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
95993 +tm6000_read_4151 tm6000_read 3 4151 NULL
95994 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
95995 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
95996 +get_alua_req_4166 get_alua_req 3 4166 NULL
95997 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
95998 +read_file_bool_4180 read_file_bool 3 4180 NULL
95999 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
96000 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
96001 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
96002 +ext4_new_inode_4247 ext4_new_inode 5 4247 NULL
96003 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
96004 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
96005 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 2-3-5 4303 NULL
96006 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
96007 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
96008 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
96009 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
96010 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
96011 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
96012 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
96013 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
96014 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
96015 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
96016 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
96017 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
96018 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
96019 +set_link_security_4502 set_link_security 4 4502 NULL
96020 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
96021 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
96022 +tty_register_device_4544 tty_register_device 2 4544 NULL
96023 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
96024 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
96025 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
96026 +bch_alloc_4593 bch_alloc 1 4593 NULL
96027 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
96028 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
96029 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
96030 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
96031 +kone_receive_4690 kone_receive 4 4690 NULL
96032 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
96033 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
96034 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
96035 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
96036 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
96037 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
96038 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
96039 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
96040 +__iio_allocate_sw_ring_buffer_4843 __iio_allocate_sw_ring_buffer 3 4843 NULL
96041 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
96042 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
96043 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
96044 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
96045 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
96046 +sys_ipc_4889 sys_ipc 3 4889 NULL
96047 +lp872x_write_byte_4914 lp872x_write_byte 2 4914 NULL
96048 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
96049 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
96050 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
96051 +da9055_reg_write_4942 da9055_reg_write 2 4942 NULL
96052 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
96053 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
96054 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
96055 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
96056 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
96057 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
96058 +lm3533_als_set_target_5010 lm3533_als_set_target 2-3 5010 NULL
96059 +do_mincore_5018 do_mincore 0-1 5018 NULL
96060 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
96061 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
96062 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
96063 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
96064 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
96065 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
96066 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
96067 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
96068 +sound_write_5102 sound_write 3 5102 NULL
96069 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
96070 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
96071 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
96072 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
96073 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
96074 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
96075 +skb_network_header_5203 skb_network_header 0 5203 NULL
96076 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
96077 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
96078 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
96079 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL
96080 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
96081 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
96082 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
96083 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
96084 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
96085 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
96086 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
96087 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
96088 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
96089 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
96090 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
96091 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
96092 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
96093 +tty_write_5494 tty_write 3 5494 NULL
96094 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
96095 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
96096 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
96097 +spidev_message_5518 spidev_message 3 5518 NULL
96098 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
96099 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
96100 +le_readq_5557 le_readq 0 5557 NULL
96101 +inw_5558 inw 0 5558 NULL
96102 +__first_dma_cap_5560 __first_dma_cap 0 5560 NULL
96103 +fir16_create_5574 fir16_create 3 5574 NULL
96104 +bioset_create_5580 bioset_create 1 5580 NULL
96105 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
96106 +do_msgrcv_5590 do_msgrcv 4 5590 NULL
96107 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
96108 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
96109 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
96110 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
96111 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
96112 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
96113 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
96114 +get_arg_5694 get_arg 3 5694 NULL
96115 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
96116 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
96117 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
96118 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
96119 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
96120 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
96121 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
96122 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
96123 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
96124 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
96125 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
96126 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
96127 +setup_req_5848 setup_req 3 5848 NULL
96128 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
96129 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
96130 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
96131 +port_show_regs_5904 port_show_regs 3 5904 NULL
96132 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
96133 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
96134 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
96135 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
96136 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
96137 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
96138 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
96139 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
96140 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
96141 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
96142 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
96143 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
96144 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
96145 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
96146 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
96147 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
96148 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
96149 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
96150 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
96151 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
96152 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
96153 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
96154 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
96155 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
96156 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
96157 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
96158 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
96159 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
96160 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 0 6282 NULL nohasharray
96161 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
96162 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
96163 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
96164 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
96165 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
96166 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
96167 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
96168 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
96169 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
96170 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2 6432 NULL
96171 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 NULL
96172 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
96173 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
96174 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
96175 +mei_read_6507 mei_read 3 6507 NULL
96176 +cpumask_next_and_6516 cpumask_next_and 1 6516 NULL
96177 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
96178 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
96179 +wdm_read_6549 wdm_read 3 6549 NULL
96180 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
96181 +usb_dump_config_descriptor_6572 usb_dump_config_descriptor 0 6572 NULL
96182 +snd_pcm_hw_refine_old_user_6586 snd_pcm_hw_refine_old_user 0 6586 NULL
96183 +usemap_size_6601 usemap_size 0-1 6601 NULL
96184 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
96185 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
96186 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
96187 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
96188 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
96189 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
96190 +ieee80211_build_preq_ies_6691 ieee80211_build_preq_ies 0-4 6691 NULL
96191 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
96192 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
96193 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
96194 +mpeg_read_6708 mpeg_read 3 6708 NULL
96195 +video_proc_write_6724 video_proc_write 3 6724 NULL
96196 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
96197 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
96198 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
96199 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
96200 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
96201 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
96202 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
96203 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
96204 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
96205 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
96206 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
96207 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
96208 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
96209 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
96210 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
96211 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
96212 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
96213 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
96214 +ieee80211_rx_mgmt_probe_resp_6918 ieee80211_rx_mgmt_probe_resp 3 6918 NULL
96215 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
96216 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
96217 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
96218 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
96219 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
96220 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
96221 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
96222 +request_key_async_6990 request_key_async 4 6990 NULL
96223 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
96224 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
96225 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
96226 +wimax_msg_7030 wimax_msg 4 7030 NULL
96227 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
96228 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
96229 +event_enable_read_7074 event_enable_read 3 7074 NULL
96230 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
96231 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
96232 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
96233 +check_header_7108 check_header 0 7108 NULL
96234 +utf16_strsize_7203 utf16_strsize 0 7203 NULL nohasharray
96235 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 &utf16_strsize_7203
96236 +sys32_ipc_7238 sys32_ipc 3-5-6-4 7238 NULL
96237 +get_param_h_7247 get_param_h 0 7247 NULL
96238 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
96239 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
96240 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
96241 +mgmt_control_7349 mgmt_control 3 7349 NULL
96242 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
96243 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
96244 +hweight_long_7388 hweight_long 0-1 7388 NULL
96245 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
96246 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
96247 +readb_7401 readb 0 7401 NULL
96248 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
96249 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
96250 +ms_rw_multi_sector_7459 ms_rw_multi_sector 3-4 7459 NULL
96251 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL nohasharray
96252 +wm8996_gpio_direction_out_7469 wm8996_gpio_direction_out 2 7469 &__mutex_lock_common_7469
96253 +garp_request_join_7471 garp_request_join 4 7471 NULL
96254 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
96255 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
96256 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
96257 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
96258 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
96259 +setup_usemap_7524 setup_usemap 3 7524 NULL
96260 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
96261 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
96262 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
96263 +groups_alloc_7614 groups_alloc 1 7614 NULL
96264 +sg_virt_7616 sg_virt 0 7616 NULL
96265 +cpumask_first_7648 cpumask_first 0 7648 NULL
96266 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
96267 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
96268 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
96269 +dev_write_7708 dev_write 3 7708 NULL
96270 +tps65090_set_bits_7709 tps65090_set_bits 2 7709 NULL
96271 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL nohasharray
96272 +dbg_check_cats_7713 dbg_check_cats 0 7713 &brcmf_sdcard_send_buf_7713
96273 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
96274 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
96275 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
96276 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
96277 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
96278 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
96279 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
96280 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
96281 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
96282 +da9052_reg_update_7858 da9052_reg_update 2 7858 NULL
96283 +tps6586x_clr_bits_7889 tps6586x_clr_bits 2 7889 NULL
96284 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
96285 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
96286 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
96287 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
96288 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
96289 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
96290 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
96291 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
96292 +sys_mbind_7990 sys_mbind 5 7990 NULL
96293 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
96294 +vcs_read_8017 vcs_read 3 8017 NULL
96295 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
96296 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
96297 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
96298 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
96299 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
96300 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
96301 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
96302 +venus_lookup_8121 venus_lookup 4 8121 NULL
96303 +lm3533_als_set_threshold_8125 lm3533_als_set_threshold 2 8125 NULL
96304 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
96305 +ext_sd_execute_write_data_8175 ext_sd_execute_write_data 9 8175 NULL
96306 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
96307 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
96308 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
96309 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
96310 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
96311 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
96312 +play_iframe_8219 play_iframe 3 8219 NULL
96313 +create_log_8225 create_log 2 8225 NULL nohasharray
96314 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
96315 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
96316 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
96317 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
96318 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
96319 +init_cdev_8274 init_cdev 1 8274 NULL
96320 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
96321 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
96322 +snd_pcm_update_state_8320 snd_pcm_update_state 0 8320 NULL
96323 +lm3533_led_get_pattern_8321 lm3533_led_get_pattern 0 8321 NULL nohasharray
96324 +construct_key_and_link_8321 construct_key_and_link 4 8321 &lm3533_led_get_pattern_8321
96325 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
96326 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
96327 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
96328 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
96329 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
96330 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
96331 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
96332 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 NULL
96333 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
96334 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
96335 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
96336 +_irq_to_enable_addr_8485 _irq_to_enable_addr 0-1 8485 NULL
96337 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
96338 +dev_config_8506 dev_config 3 8506 NULL
96339 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
96340 +utf16_strnlen_8513 utf16_strnlen 0 8513 NULL
96341 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
96342 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
96343 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
96344 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
96345 +profile_remove_8556 profile_remove 3 8556 NULL
96346 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
96347 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
96348 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
96349 +tower_write_8580 tower_write 3 8580 NULL
96350 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
96351 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
96352 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
96353 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
96354 +fuse_send_write_pages_8636 fuse_send_write_pages 0 8636 NULL
96355 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
96356 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
96357 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
96358 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
96359 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
96360 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
96361 +arcfb_write_8702 arcfb_write 3 8702 NULL
96362 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
96363 +init_header_8703 init_header 0 8703 &i_size_read_8703
96364 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
96365 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL nohasharray
96366 +snapshot_status_8729 snapshot_status 5 8729 &jffs2_acl_count_8729
96367 +f_dupfd_8730 f_dupfd 1 8730 NULL
96368 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
96369 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
96370 +sys_prctl_8766 sys_prctl 4 8766 NULL
96371 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
96372 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
96373 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
96374 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
96375 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
96376 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
96377 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
96378 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
96379 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
96380 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
96381 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
96382 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
96383 +send_pages_8872 send_pages 3 8872 NULL
96384 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
96385 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
96386 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
96387 +layout_commit_8926 layout_commit 3 8926 NULL
96388 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
96389 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
96390 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
96391 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
96392 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
96393 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
96394 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
96395 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
96396 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
96397 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
96398 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
96399 +palmas_ldo_write_9012 palmas_ldo_write 2 9012 NULL
96400 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
96401 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
96402 +nla_put_9042 nla_put 3 9042 NULL
96403 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
96404 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
96405 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
96406 +string_9080 string 0 9080 NULL
96407 +create_queues_9088 create_queues 2-3 9088 NULL
96408 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
96409 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
96410 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
96411 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
96412 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
96413 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
96414 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
96415 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
96416 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
96417 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
96418 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
96419 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
96420 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
96421 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
96422 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
96423 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
96424 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
96425 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
96426 +flakey_status_9274 flakey_status 5 9274 NULL
96427 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
96428 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
96429 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
96430 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
96431 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
96432 +read_9397 read 3 9397 NULL
96433 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
96434 +cfg80211_report_obss_beacon_9422 cfg80211_report_obss_beacon 3 9422 NULL
96435 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
96436 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
96437 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
96438 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
96439 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
96440 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
96441 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
96442 +rbd_coll_end_req_9472 rbd_coll_end_req 3 9472 NULL
96443 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
96444 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
96445 +lp_write_9511 lp_write 3 9511 NULL
96446 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
96447 +lm3533_update_9529 lm3533_update 2 9529 NULL
96448 +read_file_dma_9530 read_file_dma 3 9530 NULL
96449 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
96450 +tps65910_gpio_output_9539 tps65910_gpio_output 2 9539 NULL
96451 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
96452 +readl_9557 readl 0 9557 NULL
96453 +fw_node_create_9559 fw_node_create 2 9559 NULL
96454 +kobj_map_9566 kobj_map 2-3 9566 NULL
96455 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
96456 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
96457 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
96458 +do_sync_9604 do_sync 1 9604 NULL
96459 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
96460 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
96461 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
96462 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
96463 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
96464 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
96465 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
96466 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
96467 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
96468 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
96469 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
96470 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 NULL nohasharray
96471 +is_hole_9694 is_hole 2 9694 &x25_asy_compat_ioctl_9694
96472 +fnb_9703 fnb 2-3 9703 NULL
96473 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 NULL
96474 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
96475 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
96476 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
96477 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
96478 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
96479 +do_sigpending_9766 do_sigpending 2 9766 NULL
96480 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
96481 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
96482 +_regmap_write_9803 _regmap_write 2 9803 NULL
96483 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
96484 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
96485 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
96486 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
96487 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
96488 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
96489 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
96490 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
96491 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
96492 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
96493 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
96494 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
96495 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
96496 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
96497 +receive_DataRequest_9904 receive_DataRequest 3 9904 NULL
96498 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
96499 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
96500 +read_file_misc_9948 read_file_misc 3 9948 NULL
96501 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
96502 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
96503 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
96504 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
96505 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
96506 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
96507 +twl6040_clear_bits_9985 twl6040_clear_bits 2 9985 NULL
96508 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
96509 +handle_request_10024 handle_request 9 10024 NULL
96510 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
96511 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
96512 +rbd_coll_end_req_index_10041 rbd_coll_end_req_index 5 10041 NULL
96513 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
96514 +wm831x_gpio_direction_in_10099 wm831x_gpio_direction_in 2 10099 NULL
96515 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
96516 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
96517 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
96518 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 NULL
96519 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
96520 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
96521 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
96522 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
96523 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
96524 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
96525 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
96526 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
96527 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
96528 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
96529 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
96530 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
96531 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
96532 +lm3533_led_delay_set_10291 lm3533_led_delay_set 2 10291 NULL
96533 +read_emulate_10310 read_emulate 2-4 10310 NULL
96534 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
96535 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
96536 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
96537 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
96538 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
96539 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
96540 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
96541 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
96542 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
96543 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
96544 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
96545 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
96546 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
96547 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
96548 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
96549 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
96550 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
96551 +snd_pcm_hw_params_user_10520 snd_pcm_hw_params_user 0 10520 NULL
96552 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
96553 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
96554 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
96555 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
96556 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
96557 +otp_read_10594 otp_read 2-4-5 10594 NULL
96558 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
96559 +mc13783_set_fmt_10616 mc13783_set_fmt 3 10616 NULL
96560 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
96561 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
96562 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
96563 +parport_write_10669 parport_write 0 10669 NULL
96564 +inl_10708 inl 0 10708 NULL nohasharray
96565 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
96566 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
96567 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
96568 +spi_sync_10731 spi_sync 0 10731 NULL
96569 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
96570 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
96571 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
96572 +sys_syslog_10746 sys_syslog 3 10746 NULL
96573 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
96574 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
96575 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4 10765 NULL
96576 +sys_bind_10799 sys_bind 3 10799 NULL
96577 +compat_put_int_10828 compat_put_int 1 10828 NULL
96578 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
96579 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
96580 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
96581 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
96582 +batadv_check_unicast_packet_10866 batadv_check_unicast_packet 2 10866 NULL
96583 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
96584 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
96585 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
96586 +get_scq_10897 get_scq 2 10897 NULL
96587 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
96588 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
96589 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
96590 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
96591 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
96592 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
96593 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
96594 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
96595 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
96596 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
96597 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
96598 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
96599 +nouveau_gpio_create__11048 nouveau_gpio_create_ 4 11048 NULL
96600 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
96601 +carl9170_handle_mpdu_11056 carl9170_handle_mpdu 3 11056 NULL
96602 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
96603 +snd_pcm_delay_11081 snd_pcm_delay 0 11081 NULL
96604 +count_argc_11083 count_argc 0 11083 NULL
96605 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
96606 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
96607 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
96608 +page_offset_11120 page_offset 0 11120 NULL
96609 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL
96610 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
96611 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
96612 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
96613 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
96614 +__swab16p_11220 __swab16p 0 11220 NULL
96615 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
96616 +of_irq_count_11253 of_irq_count 0 11253 NULL
96617 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
96618 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
96619 +cru_detect_11272 cru_detect 1 11272 NULL
96620 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
96621 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
96622 +construct_key_11329 construct_key 3 11329 NULL nohasharray
96623 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
96624 +next_segment_11330 next_segment 0-2-1 11330 NULL
96625 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
96626 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
96627 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
96628 +sel_write_create_11353 sel_write_create 3 11353 NULL
96629 +handle_unit_11355 handle_unit 0-1 11355 NULL
96630 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
96631 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
96632 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
96633 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
96634 +___alloc_bootmem_11410 ___alloc_bootmem 1 11410 NULL
96635 +str_to_user_11411 str_to_user 2 11411 NULL
96636 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
96637 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
96638 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
96639 +trace_options_read_11419 trace_options_read 3 11419 NULL
96640 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
96641 +prepare_image_11424 prepare_image 0 11424 NULL
96642 +vring_size_11426 vring_size 0-1-2 11426 NULL
96643 +bttv_read_11432 bttv_read 3 11432 NULL
96644 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
96645 +swp_offset_11475 swp_offset 0 11475 NULL
96646 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
96647 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
96648 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
96649 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
96650 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
96651 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
96652 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
96653 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
96654 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
96655 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
96656 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
96657 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
96658 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
96659 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
96660 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
96661 +da9055_gpio_direction_output_11680 da9055_gpio_direction_output 2 11680 NULL
96662 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
96663 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
96664 +split_11691 split 2 11691 NULL
96665 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
96666 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
96667 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
96668 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
96669 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
96670 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
96671 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
96672 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
96673 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
96674 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2 11818 NULL
96675 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
96676 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
96677 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
96678 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
96679 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
96680 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
96681 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
96682 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
96683 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
96684 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
96685 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
96686 +kvm_set_msr_common_11953 kvm_set_msr_common 3 11953 NULL
96687 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
96688 +atmel_read16_11981 atmel_read16 0 11981 NULL
96689 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
96690 +mwifiex_cfg80211_mgmt_tx_12022 mwifiex_cfg80211_mgmt_tx 9 12022 NULL
96691 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
96692 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
96693 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
96694 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
96695 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
96696 +da9052_gpio_direction_output_12120 da9052_gpio_direction_output 2 12120 NULL
96697 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
96698 +set_powered_12129 set_powered 4 12129 NULL
96699 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
96700 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
96701 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
96702 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
96703 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
96704 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
96705 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
96706 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
96707 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
96708 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
96709 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
96710 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
96711 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
96712 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
96713 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
96714 +receive_copy_12216 receive_copy 3 12216 NULL
96715 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
96716 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 NULL
96717 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
96718 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
96719 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
96720 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
96721 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
96722 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
96723 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
96724 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
96725 +split_bvec_12312 split_bvec 6 12312 NULL
96726 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
96727 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
96728 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
96729 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
96730 +receive_packet_12367 receive_packet 2 12367 NULL
96731 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
96732 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
96733 +ntfs_get_size_for_mapping_pairs_12413 ntfs_get_size_for_mapping_pairs 0 12413 NULL
96734 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
96735 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
96736 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
96737 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
96738 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
96739 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
96740 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
96741 +arizona_gpio_direction_out_12564 arizona_gpio_direction_out 2 12564 NULL
96742 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
96743 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
96744 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
96745 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
96746 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
96747 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
96748 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
96749 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
96750 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
96751 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
96752 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
96753 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
96754 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
96755 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
96756 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
96757 +ivtv_write_12721 ivtv_write 3 12721 NULL
96758 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
96759 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
96760 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
96761 +listxattr_12769 listxattr 3 12769 NULL
96762 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
96763 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
96764 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
96765 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
96766 +readq_12825 readq 0 12825 NULL
96767 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
96768 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 NULL nohasharray
96769 +spidev_sync_12842 spidev_sync 0 12842 &ath6kl_wmi_add_wow_pattern_cmd_12842
96770 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
96771 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
96772 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
96773 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
96774 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
96775 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
96776 +tps65910_reg_update_bits_12934 tps65910_reg_update_bits 2 12934 NULL
96777 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
96778 +bm_status_write_12964 bm_status_write 3 12964 NULL
96779 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
96780 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
96781 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
96782 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
96783 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
96784 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
96785 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
96786 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
96787 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
96788 +tps6586x_set_bits_13089 tps6586x_set_bits 2 13089 NULL
96789 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
96790 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
96791 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
96792 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
96793 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
96794 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
96795 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
96796 +blk_update_request_13146 blk_update_request 3 13146 NULL
96797 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
96798 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
96799 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
96800 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
96801 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
96802 +comedi_read_13199 comedi_read 3 13199 NULL
96803 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
96804 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
96805 +get_unaligned_le64_13219 get_unaligned_le64 0 13219 NULL
96806 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
96807 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
96808 +fw_download_code_13249 fw_download_code 3 13249 NULL
96809 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
96810 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
96811 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
96812 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
96813 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
96814 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
96815 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
96816 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
96817 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
96818 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5 13337 NULL
96819 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
96820 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
96821 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
96822 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
96823 +sky2_receive_13407 sky2_receive 2 13407 NULL
96824 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
96825 +keyring_read_13438 keyring_read 3 13438 NULL
96826 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
96827 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
96828 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 7-8-9 13443 NULL
96829 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
96830 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
96831 +core_status_13515 core_status 4 13515 NULL
96832 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
96833 +bm_init_13529 bm_init 2 13529 NULL
96834 +llcp_sock_recvmsg_13556 llcp_sock_recvmsg 4 13556 NULL
96835 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
96836 +alloc_tio_13564 alloc_tio 3 13564 NULL
96837 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
96838 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
96839 +pm860x_set_bits_13582 pm860x_set_bits 2 13582 NULL
96840 +cache_write_13589 cache_write 3 13589 NULL
96841 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
96842 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
96843 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
96844 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
96845 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
96846 +wm8994_bulk_write_13615 wm8994_bulk_write 3-2 13615 NULL
96847 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
96848 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
96849 +packet_snd_13634 packet_snd 3 13634 NULL
96850 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
96851 +cache_downcall_13666 cache_downcall 3 13666 NULL
96852 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
96853 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
96854 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
96855 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
96856 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
96857 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
96858 +random_read_13815 random_read 3 13815 NULL
96859 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
96860 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
96861 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
96862 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
96863 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
96864 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
96865 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
96866 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
96867 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
96868 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
96869 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
96870 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
96871 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
96872 +com90xx_found_13974 com90xx_found 3 13974 NULL
96873 +qcam_read_13977 qcam_read 3 13977 NULL
96874 +dsp_read_13980 dsp_read 2 13980 NULL
96875 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
96876 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
96877 +ieee80211_bss_info_update_13991 ieee80211_bss_info_update 4 13991 NULL
96878 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
96879 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
96880 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
96881 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
96882 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
96883 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
96884 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
96885 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
96886 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
96887 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
96888 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
96889 +em_canid_change_14150 em_canid_change 3 14150 NULL
96890 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
96891 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
96892 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
96893 +alloc_async_14208 alloc_async 1 14208 NULL
96894 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
96895 +pool_status_14230 pool_status 5 14230 NULL
96896 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
96897 +inode_to_path_14235 inode_to_path 2 14235 NULL
96898 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
96899 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 4-2 14245 NULL
96900 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
96901 +ath6kl_connect_event_14267 ath6kl_connect_event 7-8-9 14267 NULL
96902 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
96903 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
96904 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
96905 +rr_status_14293 rr_status 5 14293 NULL
96906 +lp8788_write_byte_14299 lp8788_write_byte 2 14299 NULL
96907 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
96908 +oo_objects_14319 oo_objects 0 14319 NULL
96909 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
96910 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
96911 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
96912 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
96913 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
96914 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
96915 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
96916 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
96917 +block_size_14443 block_size 0 14443 NULL
96918 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
96919 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
96920 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
96921 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
96922 +stripe_status_14506 stripe_status 5 14506 NULL
96923 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
96924 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
96925 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
96926 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
96927 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
96928 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
96929 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
96930 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
96931 +dbJoin_14644 dbJoin 0 14644 NULL
96932 +profile_replace_14652 profile_replace 3 14652 NULL
96933 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
96934 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
96935 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
96936 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
96937 +vfd_write_14717 vfd_write 3 14717 NULL
96938 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
96939 +raid1_resize_14740 raid1_resize 2 14740 NULL
96940 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
96941 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
96942 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
96943 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
96944 +lm3533_als_get_hysteresis_14776 lm3533_als_get_hysteresis 2 14776 NULL
96945 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
96946 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
96947 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
96948 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
96949 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
96950 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
96951 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
96952 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
96953 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
96954 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
96955 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
96956 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
96957 +unifi_read_14899 unifi_read 3 14899 NULL
96958 +krealloc_14908 krealloc 2 14908 NULL
96959 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
96960 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL
96961 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
96962 +queue_cnt_14951 queue_cnt 0 14951 NULL
96963 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
96964 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
96965 +setkey_14987 setkey 3 14987 NULL nohasharray
96966 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
96967 +vmap_15025 vmap 2 15025 NULL
96968 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
96969 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
96970 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
96971 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
96972 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
96973 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
96974 +__alloc_extent_buffer_15093 __alloc_extent_buffer 3 15093 NULL
96975 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
96976 +start_port_15124 start_port 0 15124 NULL
96977 +memchr_15126 memchr 0 15126 NULL
96978 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
96979 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
96980 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
96981 +reserve_resources_15194 reserve_resources 3 15194 NULL
96982 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
96983 +variax_alloc_sysex_buffer_15237 variax_alloc_sysex_buffer 3 15237 NULL
96984 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
96985 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
96986 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
96987 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
96988 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
96989 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
96990 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
96991 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
96992 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
96993 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
96994 +ioread16_15342 ioread16 0 15342 NULL
96995 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
96996 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
96997 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
96998 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
96999 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
97000 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
97001 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
97002 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
97003 +get_modalias_15406 get_modalias 2 15406 NULL
97004 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
97005 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 0-2 15438 NULL
97006 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
97007 +memweight_15450 memweight 2 15450 NULL
97008 +vmalloc_15464 vmalloc 1 15464 NULL
97009 +insert_old_idx_znode_15500 insert_old_idx_znode 0 15500 NULL
97010 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
97011 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
97012 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
97013 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
97014 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
97015 +snd_pcm_channel_info_15572 snd_pcm_channel_info 0 15572 NULL
97016 +persistent_status_15574 persistent_status 4 15574 NULL
97017 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
97018 +vme_user_write_15587 vme_user_write 3 15587 NULL
97019 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
97020 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
97021 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
97022 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
97023 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
97024 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
97025 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
97026 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
97027 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
97028 +fs_path_add_15648 fs_path_add 3 15648 NULL
97029 +xsd_read_15653 xsd_read 3 15653 NULL
97030 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
97031 +unix_bind_15668 unix_bind 3 15668 NULL
97032 +dm_read_15674 dm_read 3 15674 NULL
97033 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
97034 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
97035 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
97036 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
97037 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
97038 +do_test_15766 do_test 1 15766 NULL
97039 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
97040 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
97041 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
97042 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
97043 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
97044 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
97045 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
97046 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
97047 +table_size_15851 table_size 0-1-2 15851 NULL
97048 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
97049 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
97050 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
97051 +ERR_PTR_15881 ERR_PTR 0 15881 NULL
97052 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
97053 +native_read_msr_15905 native_read_msr 0 15905 NULL
97054 +wm5100_gpio_direction_in_15934 wm5100_gpio_direction_in 2 15934 NULL
97055 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
97056 +power_read_15939 power_read 3 15939 NULL
97057 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
97058 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
97059 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
97060 +set_spte_15977 set_spte 7-6 15977 NULL
97061 +frame_alloc_15981 frame_alloc 4 15981 NULL
97062 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
97063 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
97064 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
97065 +got_frame_16028 got_frame 2 16028 NULL
97066 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
97067 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
97068 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
97069 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
97070 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
97071 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
97072 +fsm_init_16134 fsm_init 2 16134 NULL
97073 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
97074 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
97075 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
97076 +mapping_level_16188 mapping_level 2 16188 NULL
97077 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
97078 +create_table_16213 create_table 2 16213 NULL
97079 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
97080 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
97081 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 NULL
97082 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
97083 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
97084 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
97085 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
97086 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
97087 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
97088 +account_16283 account 0-2-4 16283 NULL nohasharray
97089 +mirror_status_16283 mirror_status 5 16283 &account_16283
97090 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
97091 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
97092 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
97093 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
97094 +tps80031_update_16360 tps80031_update 3 16360 NULL
97095 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
97096 +rbd_add_16366 rbd_add 3 16366 NULL
97097 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
97098 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
97099 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
97100 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
97101 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
97102 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
97103 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
97104 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
97105 +raid10_resize_16537 raid10_resize 2 16537 NULL
97106 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
97107 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
97108 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
97109 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
97110 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
97111 +da9052_reg_write_16685 da9052_reg_write 2 16685 NULL
97112 +em28xx_v4l2_read_16701 em28xx_v4l2_read 3 16701 NULL
97113 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
97114 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
97115 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
97116 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
97117 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
97118 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
97119 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
97120 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
97121 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
97122 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
97123 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
97124 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
97125 +st_write_16874 st_write 3 16874 NULL
97126 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
97127 +wm8350_set_bits_16911 wm8350_set_bits 2 16911 NULL
97128 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
97129 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
97130 +random32_16937 random32 0 16937 NULL
97131 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
97132 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
97133 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
97134 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
97135 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
97136 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
97137 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
97138 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
97139 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
97140 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
97141 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
97142 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
97143 +mac_address_string_17091 mac_address_string 0 17091 NULL
97144 +entry_length_17093 entry_length 0 17093 NULL
97145 +sys_preadv_17100 sys_preadv 3 17100 NULL
97146 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
97147 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
97148 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
97149 +sep_read_17161 sep_read 3 17161 NULL
97150 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
97151 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
97152 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
97153 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
97154 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
97155 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
97156 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
97157 +ms_rw_17220 ms_rw 3-4 17220 NULL
97158 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
97159 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
97160 +alloc_ep_17269 alloc_ep 1 17269 NULL
97161 +pg_read_17276 pg_read 3 17276 NULL
97162 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
97163 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
97164 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
97165 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
97166 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
97167 +skb_pad_17302 skb_pad 2 17302 NULL
97168 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
97169 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
97170 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
97171 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
97172 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
97173 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
97174 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
97175 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
97176 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
97177 +compat_cmd_17465 compat_cmd 2 17465 NULL
97178 +probe_bios_17467 probe_bios 1 17467 NULL
97179 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
97180 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
97181 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
97182 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
97183 +arizona_apply_fll_17538 arizona_apply_fll 2 17538 NULL
97184 +xlog_do_log_recovery_17550 xlog_do_log_recovery 3 17550 NULL
97185 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
97186 +copy_from_user_17559 copy_from_user 3 17559 NULL
97187 +snd_pcm_action_lock_irq_17569 snd_pcm_action_lock_irq 0 17569 NULL
97188 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
97189 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
97190 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
97191 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
97192 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
97193 +osst_execute_17607 osst_execute 7-6 17607 NULL
97194 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
97195 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
97196 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
97197 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
97198 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
97199 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
97200 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
97201 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
97202 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
97203 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
97204 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
97205 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
97206 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
97207 +get_unaligned_be64_17794 get_unaligned_be64 0 17794 NULL
97208 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
97209 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
97210 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
97211 +count_leafs_17842 count_leafs 0 17842 NULL
97212 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
97213 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
97214 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
97215 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
97216 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
97217 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
97218 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
97219 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
97220 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
97221 +wm8400_set_bits_17898 wm8400_set_bits 2 17898 NULL
97222 +recover_head_17904 recover_head 3 17904 NULL
97223 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
97224 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
97225 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
97226 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
97227 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
97228 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
97229 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
97230 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
97231 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
97232 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
97233 +prandom32_18007 prandom32 0 18007 NULL
97234 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
97235 +fill_read_18019 fill_read 0 18019 NULL
97236 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
97237 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
97238 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
97239 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
97240 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
97241 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
97242 +packet_came_18072 packet_came 3 18072 NULL
97243 +kvm_read_guest_page_18074 kvm_read_guest_page 5 18074 NULL
97244 +get_vm_area_18080 get_vm_area 1 18080 NULL
97245 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
97246 +tps65910_gpio_input_18110 tps65910_gpio_input 2 18110 NULL
97247 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
97248 +svc_getnl_18120 svc_getnl 0 18120 NULL
97249 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
97250 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
97251 +tps65910_gpio_set_18135 tps65910_gpio_set 2 18135 NULL
97252 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
97253 +is_idx_node_in_use_18165 is_idx_node_in_use 0 18165 NULL
97254 +_has_tag_18169 _has_tag 2 18169 NULL
97255 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
97256 +snd_pcm_hw_refine_user_18204 snd_pcm_hw_refine_user 0 18204 NULL
97257 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
97258 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
97259 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
97260 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
97261 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
97262 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
97263 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
97264 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
97265 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
97266 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
97267 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
97268 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
97269 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
97270 +um_idi_write_18293 um_idi_write 3 18293 NULL
97271 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
97272 +vga_r_18310 vga_r 0 18310 NULL
97273 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
97274 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
97275 +wm8994_gpio_direction_out_18337 wm8994_gpio_direction_out 2 18337 NULL
97276 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
97277 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
97278 +ep_io_18367 ep_io 0 18367 NULL
97279 +lp872x_update_bits_18368 lp872x_update_bits 2 18368 NULL
97280 +irq_find_mapping_18388 irq_find_mapping 0-2 18388 NULL
97281 +__video_register_device_18399 __video_register_device 3 18399 NULL
97282 +reada_tree_block_flagged_18402 reada_tree_block_flagged 3 18402 NULL nohasharray
97283 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &reada_tree_block_flagged_18402
97284 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
97285 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
97286 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL
97287 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
97288 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
97289 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
97290 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
97291 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
97292 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
97293 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
97294 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
97295 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
97296 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
97297 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
97298 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
97299 +debug_output_18575 debug_output 3 18575 NULL
97300 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
97301 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
97302 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
97303 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
97304 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
97305 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
97306 +from_buffer_18625 from_buffer 3 18625 NULL
97307 +f1x_map_sysaddr_to_csrow_18628 f1x_map_sysaddr_to_csrow 2 18628 NULL
97308 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
97309 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
97310 +unmap_page_18665 unmap_page 2-3 18665 NULL
97311 +edge_tty_recv_18667 edge_tty_recv 4 18667 NULL nohasharray
97312 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 &edge_tty_recv_18667
97313 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
97314 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
97315 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
97316 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
97317 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
97318 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
97319 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
97320 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
97321 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
97322 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
97323 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
97324 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
97325 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
97326 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
97327 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
97328 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
97329 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
97330 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
97331 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
97332 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
97333 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
97334 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
97335 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
97336 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
97337 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
97338 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
97339 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
97340 +alc_auto_create_extra_outs_18975 alc_auto_create_extra_outs 2 18975 NULL
97341 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
97342 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
97343 +huge_page_size_19008 huge_page_size 0 19008 NULL
97344 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
97345 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
97346 +revalidate_19043 revalidate 2 19043 NULL
97347 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
97348 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
97349 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
97350 +copy_and_check_19089 copy_and_check 3 19089 NULL
97351 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
97352 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
97353 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
97354 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
97355 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
97356 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
97357 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
97358 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
97359 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
97360 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
97361 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
97362 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
97363 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
97364 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
97365 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
97366 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
97367 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
97368 +snd_pcm_capture_rewind_19229 snd_pcm_capture_rewind 0-2 19229 NULL
97369 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
97370 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
97371 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
97372 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
97373 +qc_capture_19298 qc_capture 3 19298 NULL
97374 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
97375 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
97376 +debug_read_19322 debug_read 3 19322 NULL
97377 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
97378 +read_zero_19366 read_zero 3 19366 NULL
97379 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
97380 +get_unaligned_be16_19400 get_unaligned_be16 0 19400 NULL
97381 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
97382 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
97383 +__phys_addr_19434 __phys_addr 0 19434 NULL
97384 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
97385 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
97386 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
97387 +sky2_read16_19475 sky2_read16 0 19475 NULL
97388 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
97389 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
97390 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
97391 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
97392 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
97393 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
97394 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
97395 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
97396 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
97397 +nfsd_read_19568 nfsd_read 5 19568 NULL
97398 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
97399 +bm_status_read_19583 bm_status_read 3 19583 NULL
97400 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
97401 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
97402 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
97403 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
97404 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
97405 +read_reg_19723 read_reg 0 19723 NULL
97406 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
97407 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
97408 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
97409 +p9_client_read_19750 p9_client_read 5 19750 NULL
97410 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
97411 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
97412 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
97413 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
97414 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
97415 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
97416 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
97417 +vip_read_19832 vip_read 3 19832 NULL nohasharray
97418 +vfs_getxattr_19832 vfs_getxattr 0 19832 &vip_read_19832
97419 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
97420 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
97421 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
97422 +__nla_put_19857 __nla_put 3 19857 NULL
97423 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
97424 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
97425 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
97426 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
97427 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
97428 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
97429 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
97430 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
97431 +__be32_to_cpup_20056 __be32_to_cpup 0 20056 NULL
97432 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
97433 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
97434 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
97435 +team_options_register_20091 team_options_register 3 20091 NULL
97436 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
97437 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
97438 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
97439 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
97440 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
97441 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
97442 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
97443 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
97444 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
97445 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
97446 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
97447 +resource_size_20256 resource_size 0 20256 NULL
97448 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
97449 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
97450 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
97451 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
97452 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
97453 +snd_pcm_stop_20376 snd_pcm_stop 0 20376 NULL
97454 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
97455 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
97456 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
97457 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
97458 +pm860x_write_reg_cache_20448 pm860x_write_reg_cache 2 20448 NULL
97459 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
97460 +ip_vs_icmp_xmit_v6_20464 ip_vs_icmp_xmit_v6 4 20464 NULL
97461 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
97462 +read_buf_20469 read_buf 2 20469 NULL
97463 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
97464 +fast_user_write_20494 fast_user_write 5 20494 NULL
97465 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
97466 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
97467 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
97468 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
97469 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
97470 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
97471 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
97472 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
97473 +venus_create_20555 venus_create 4 20555 NULL
97474 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
97475 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
97476 +rc5t583_set_bits_20573 rc5t583_set_bits 2 20573 NULL
97477 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
97478 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
97479 +lirc_write_20604 lirc_write 3 20604 NULL
97480 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
97481 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
97482 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
97483 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
97484 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
97485 +ceph_osdc_new_request_20654 ceph_osdc_new_request 15-4 20654 NULL
97486 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
97487 +sec_reg_write_20667 sec_reg_write 2 20667 NULL
97488 +tps65910_reg_clear_bits_20672 tps65910_reg_clear_bits 2 20672 NULL
97489 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
97490 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 NULL
97491 +cpumask_size_20683 cpumask_size 0 20683 NULL
97492 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
97493 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
97494 +__maestro_read_20700 __maestro_read 0 20700 NULL
97495 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
97496 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
97497 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
97498 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
97499 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
97500 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
97501 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
97502 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
97503 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
97504 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
97505 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
97506 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
97507 +sys_sendto_20809 sys_sendto 6 20809 NULL
97508 +strndup_user_20819 strndup_user 2 20819 NULL
97509 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
97510 +uvc_alloc_entity_20836 uvc_alloc_entity 4-3 20836 NULL
97511 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
97512 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
97513 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
97514 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
97515 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
97516 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
97517 +htable_bits_20933 htable_bits 0 20933 NULL
97518 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
97519 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
97520 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
97521 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
97522 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
97523 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
97524 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
97525 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
97526 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
97527 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
97528 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
97529 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
97530 +multipath_status_21094 multipath_status 5 21094 NULL
97531 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
97532 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
97533 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
97534 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
97535 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
97536 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
97537 +ath6kl_mgmt_tx_21153 ath6kl_mgmt_tx 9 21153 NULL
97538 +setup_msi_irq_21169 setup_msi_irq 3 21169 NULL
97539 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
97540 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
97541 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
97542 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
97543 +input_ff_create_21240 input_ff_create 2 21240 NULL
97544 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
97545 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
97546 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
97547 +rc5t583_clear_bits_21300 rc5t583_clear_bits 2 21300 NULL
97548 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
97549 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
97550 +add_res_range_21310 add_res_range 4 21310 NULL
97551 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
97552 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
97553 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
97554 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
97555 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
97556 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
97557 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
97558 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
97559 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
97560 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
97561 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
97562 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
97563 +btrfs_iref_to_path_21445 btrfs_iref_to_path 7 21445 NULL
97564 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
97565 +concat_writev_21451 concat_writev 3 21451 NULL
97566 +extend_netdev_table_21453 extend_netdev_table 2 21453 NULL
97567 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
97568 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
97569 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
97570 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
97571 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
97572 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
97573 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
97574 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
97575 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
97576 +xlog_do_recovery_pass_21618 xlog_do_recovery_pass 3 21618 NULL
97577 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
97578 +rbd_req_sync_op_21632 rbd_req_sync_op 7-8 21632 NULL
97579 +validate_nnode_21638 validate_nnode 0 21638 NULL
97580 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
97581 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
97582 +hpet_setup_msi_irq_21662 hpet_setup_msi_irq 1 21662 NULL
97583 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
97584 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
97585 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
97586 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
97587 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
97588 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
97589 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
97590 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
97591 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
97592 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
97593 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
97594 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
97595 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
97596 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
97597 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
97598 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
97599 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
97600 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
97601 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
97602 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
97603 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
97604 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
97605 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
97606 +rbd_req_read_21952 rbd_req_read 4-5 21952 NULL
97607 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
97608 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
97609 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
97610 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
97611 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
97612 +ti_recv_22027 ti_recv 4 22027 NULL
97613 +pcf50633_irq_unmask_22034 pcf50633_irq_unmask 2 22034 NULL
97614 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
97615 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
97616 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
97617 +mem_rw_22085 mem_rw 3 22085 NULL
97618 +snd_pcm_xrun_22088 snd_pcm_xrun 0 22088 NULL
97619 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
97620 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
97621 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
97622 +compat_insn_22142 compat_insn 2 22142 NULL
97623 +pn533_dep_link_up_22154 pn533_dep_link_up 5 22154 NULL
97624 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
97625 +__kfifo_alloc_22173 __kfifo_alloc 2-3 22173 NULL
97626 +fls_22210 fls 0 22210 NULL
97627 +bio_chain_clone_22227 bio_chain_clone 4 22227 NULL
97628 +mem_write_22232 mem_write 3 22232 NULL
97629 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
97630 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
97631 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
97632 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
97633 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
97634 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
97635 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
97636 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
97637 +get_segment_base_22324 get_segment_base 0 22324 NULL
97638 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
97639 +atomic_read_22342 atomic_read 0 22342 NULL
97640 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
97641 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL
97642 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
97643 +wlcore_alloc_hw_22365 wlcore_alloc_hw 1 22365 NULL nohasharray
97644 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 &wlcore_alloc_hw_22365
97645 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
97646 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
97647 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
97648 +zoran_write_22404 zoran_write 3 22404 NULL
97649 +queue_reply_22416 queue_reply 3 22416 NULL
97650 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
97651 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
97652 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
97653 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
97654 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
97655 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
97656 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
97657 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
97658 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
97659 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
97660 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
97661 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
97662 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
97663 +snapshot_read_22601 snapshot_read 3 22601 NULL
97664 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
97665 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
97666 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
97667 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
97668 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
97669 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
97670 +fill_gap_22681 fill_gap 0 22681 NULL
97671 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
97672 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
97673 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
97674 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
97675 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
97676 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL
97677 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
97678 +print_frame_22769 print_frame 0 22769 NULL
97679 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
97680 +retu_write_22800 retu_write 2 22800 NULL
97681 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
97682 +can_nocow_odirect_22854 can_nocow_odirect 3 22854 NULL nohasharray
97683 +read_file_rcstat_22854 read_file_rcstat 3 22854 &can_nocow_odirect_22854
97684 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
97685 +nfs4_realloc_slot_table_22859 nfs4_realloc_slot_table 2 22859 NULL
97686 +create_attr_set_22861 create_attr_set 1 22861 NULL
97687 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
97688 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
97689 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
97690 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
97691 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
97692 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
97693 +vme_get_size_22964 vme_get_size 0 22964 NULL
97694 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
97695 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
97696 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
97697 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
97698 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
97699 +st_status_23032 st_status 5 23032 NULL
97700 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
97701 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
97702 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
97703 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
97704 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
97705 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
97706 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
97707 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
97708 +fls_long_23096 fls_long 0 23096 NULL
97709 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
97710 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
97711 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
97712 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
97713 +__clear_user_23118 __clear_user 0 23118 NULL
97714 +dm_write_async_23120 dm_write_async 3 23120 NULL
97715 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
97716 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
97717 +wm831x_set_bits_23158 wm831x_set_bits 2 23158 NULL
97718 +read_file_ani_23161 read_file_ani 3 23161 NULL
97719 +ioremap_23172 ioremap 1-2 23172 NULL
97720 +usblp_write_23178 usblp_write 3 23178 NULL
97721 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
97722 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
97723 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
97724 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
97725 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
97726 +__next_dma_cap_23195 __next_dma_cap 1 23195 NULL
97727 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
97728 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
97729 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
97730 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
97731 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
97732 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
97733 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
97734 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
97735 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
97736 +doc_probe_23285 doc_probe 1 23285 NULL
97737 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
97738 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
97739 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
97740 +page_readlink_23346 page_readlink 3 23346 NULL
97741 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
97742 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
97743 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
97744 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
97745 +__cxio_init_resource_fifo_23447 __cxio_init_resource_fifo 3 23447 NULL nohasharray
97746 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 &__cxio_init_resource_fifo_23447
97747 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
97748 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
97749 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
97750 +event_filter_read_23494 event_filter_read 3 23494 NULL
97751 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
97752 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
97753 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
97754 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
97755 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
97756 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
97757 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
97758 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
97759 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
97760 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
97761 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
97762 +sInW_23663 sInW 0 23663 NULL
97763 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
97764 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
97765 +cx18_read_23699 cx18_read 3 23699 NULL
97766 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
97767 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
97768 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
97769 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
97770 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
97771 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
97772 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
97773 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2 23824 NULL
97774 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
97775 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
97776 +p54_init_common_23850 p54_init_common 1 23850 NULL
97777 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
97778 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
97779 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
97780 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
97781 +ieee80211_if_read_channel_type_23884 ieee80211_if_read_channel_type 3 23884 NULL
97782 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
97783 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
97784 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
97785 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
97786 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
97787 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
97788 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
97789 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
97790 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
97791 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
97792 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
97793 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
97794 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
97795 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
97796 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
97797 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
97798 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
97799 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
97800 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
97801 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
97802 +ieee80211_send_auth_24121 ieee80211_send_auth 5 24121 NULL
97803 +mpu401_read_24126 mpu401_read 3 24126 NULL
97804 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
97805 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
97806 +adu_read_24177 adu_read 3 24177 NULL
97807 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
97808 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
97809 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
97810 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
97811 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
97812 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
97813 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
97814 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
97815 +thin_status_24278 thin_status 5 24278 NULL
97816 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
97817 +msg_size_24288 msg_size 0 24288 NULL
97818 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
97819 +map_page_24298 map_page 3-4 24298 NULL
97820 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
97821 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
97822 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
97823 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
97824 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
97825 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
97826 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
97827 +igetword_24373 igetword 0 24373 NULL
97828 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
97829 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
97830 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
97831 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
97832 +ieee80211_rx_mgmt_beacon_24430 ieee80211_rx_mgmt_beacon 3 24430 NULL
97833 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
97834 +smk_user_access_24440 smk_user_access 3 24440 NULL
97835 +page_address_24444 page_address 0 24444 NULL
97836 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
97837 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
97838 +pd_video_read_24510 pd_video_read 3 24510 NULL
97839 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
97840 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
97841 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
97842 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
97843 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
97844 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
97845 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
97846 +palmas_smps_write_24600 palmas_smps_write 2 24600 NULL nohasharray
97847 +count_preds_24600 count_preds 0 24600 &palmas_smps_write_24600
97848 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
97849 +context_alloc_24645 context_alloc 3 24645 NULL
97850 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
97851 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
97852 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
97853 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
97854 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
97855 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
97856 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
97857 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
97858 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
97859 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
97860 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
97861 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
97862 +cache_read_24790 cache_read 3 24790 NULL
97863 +unpack_str_24798 unpack_str 0 24798 NULL
97864 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
97865 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
97866 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
97867 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
97868 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
97869 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
97870 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
97871 +queues_read_24877 queues_read 3 24877 NULL
97872 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
97873 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
97874 +next_token_24929 next_token 0 24929 NULL
97875 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
97876 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
97877 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
97878 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
97879 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
97880 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
97881 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
97882 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
97883 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
97884 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
97885 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
97886 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
97887 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
97888 +gfs2_iter_unstuffed_25099 gfs2_iter_unstuffed 0 25099 NULL
97889 +cxio_hal_init_rhdl_resource_25104 cxio_hal_init_rhdl_resource 1 25104 NULL
97890 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
97891 +fs32_to_cpu_25143 fs32_to_cpu 0 25143 NULL
97892 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
97893 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
97894 +mmu_set_spte_25177 mmu_set_spte 8-9 25177 NULL
97895 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
97896 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
97897 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
97898 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
97899 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
97900 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
97901 +stripe_status_25259 stripe_status 5 25259 NULL
97902 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
97903 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
97904 +vfs_writev_25278 vfs_writev 3 25278 NULL
97905 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
97906 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
97907 +help_25316 help 5 25316 NULL nohasharray
97908 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
97909 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
97910 +i915_gem_execbuffer_relocate_slow_25355 i915_gem_execbuffer_relocate_slow 7 25355 NULL
97911 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
97912 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
97913 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
97914 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
97915 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
97916 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
97917 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
97918 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
97919 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
97920 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
97921 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
97922 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
97923 +sb_permission_25523 sb_permission 0 25523 NULL
97924 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
97925 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
97926 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
97927 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
97928 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
97929 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
97930 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
97931 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
97932 +__get_user_pages_25628 __get_user_pages 0 25628 NULL nohasharray
97933 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
97934 +__direct_map_25647 __direct_map 5-6 25647 NULL
97935 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
97936 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
97937 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
97938 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
97939 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
97940 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
97941 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
97942 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2 25726 &sel_write_context_25726
97943 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
97944 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
97945 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
97946 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
97947 +sg_read_25799 sg_read 3 25799 NULL
97948 +sys32_rt_sigpending_25814 sys32_rt_sigpending 2 25814 NULL
97949 +system_enable_read_25815 system_enable_read 3 25815 NULL
97950 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
97951 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
97952 +parport_read_25855 parport_read 0 25855 NULL
97953 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
97954 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
97955 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
97956 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
97957 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
97958 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
97959 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
97960 +utf16_strlen_25913 utf16_strlen 0 25913 NULL
97961 +rcname_read_25919 rcname_read 3 25919 NULL
97962 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
97963 +key_flags_read_25931 key_flags_read 3 25931 NULL
97964 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
97965 +tps80031_clr_bits_25942 tps80031_clr_bits 3 25942 NULL
97966 +flush_25957 flush 2 25957 NULL
97967 +video_register_device_25971 video_register_device 3 25971 NULL
97968 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
97969 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
97970 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
97971 +mirror_status_26010 mirror_status 5 26010 NULL
97972 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
97973 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
97974 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
97975 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
97976 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
97977 +tun_do_read_26047 tun_do_read 5 26047 NULL
97978 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
97979 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
97980 +cpumask_next_26096 cpumask_next 1 26096 NULL
97981 +skb_cow_26138 skb_cow 2 26138 NULL
97982 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
97983 +__fswab64_26155 __fswab64 0 26155 NULL
97984 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
97985 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
97986 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
97987 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
97988 +disk_devt_26180 disk_devt 0 26180 NULL
97989 +get_registers_26187 get_registers 3 26187 NULL
97990 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
97991 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
97992 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
97993 +mce_write_26201 mce_write 3 26201 NULL
97994 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
97995 +cxio_num_stags_26233 cxio_num_stags 0 26233 NULL
97996 +bio_split_26235 bio_split 2 26235 NULL
97997 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
97998 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
97999 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
98000 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
98001 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
98002 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
98003 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
98004 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
98005 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
98006 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
98007 +virtio_has_feature_26467 virtio_has_feature 0 26467 NULL
98008 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
98009 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
98010 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
98011 +read_vmcore_26501 read_vmcore 3 26501 NULL
98012 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
98013 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
98014 +rds_message_inc_copy_to_user_26540 rds_message_inc_copy_to_user 3 26540 NULL
98015 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
98016 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
98017 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
98018 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
98019 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
98020 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
98021 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
98022 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
98023 +mmap_region_26649 mmap_region 0-2 26649 NULL
98024 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
98025 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
98026 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
98027 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
98028 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
98029 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
98030 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
98031 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
98032 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
98033 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
98034 +ntfs_are_rl_mergeable_26777 ntfs_are_rl_mergeable 0 26777 NULL
98035 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
98036 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
98037 +smk_write_load_26829 smk_write_load 3 26829 NULL
98038 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
98039 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
98040 +scnprint_id_26842 scnprint_id 3 26842 NULL
98041 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
98042 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
98043 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
98044 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
98045 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
98046 +wm8994_reg_write_26919 wm8994_reg_write 2 26919 NULL
98047 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
98048 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
98049 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
98050 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
98051 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
98052 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
98053 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
98054 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
98055 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
98056 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
98057 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
98058 +rbd_do_op_27025 rbd_do_op 7-8 27025 NULL
98059 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
98060 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
98061 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
98062 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
98063 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
98064 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
98065 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
98066 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
98067 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
98068 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
98069 +pms_capture_27142 pms_capture 4 27142 NULL
98070 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
98071 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
98072 +mc13xxx_irq_handle_27166 mc13xxx_irq_handle 3 27166 NULL
98073 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
98074 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
98075 +get_unaligned_be32_27184 get_unaligned_be32 0 27184 NULL
98076 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
98077 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
98078 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
98079 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
98080 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
98081 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
98082 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
98083 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 NULL
98084 +rbd_req_sync_exec_27320 rbd_req_sync_exec 8 27320 NULL
98085 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
98086 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
98087 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
98088 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
98089 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
98090 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
98091 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
98092 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
98093 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
98094 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
98095 +tps65910_reg_set_bits_27468 tps65910_reg_set_bits 2 27468 NULL
98096 +rtsx_write_cfg_seq_27485 rtsx_write_cfg_seq 5-3 27485 NULL
98097 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
98098 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
98099 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
98100 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
98101 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
98102 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
98103 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
98104 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
98105 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
98106 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
98107 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
98108 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
98109 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
98110 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
98111 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
98112 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
98113 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
98114 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
98115 +qword_get_27670 qword_get 0 27670 NULL
98116 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
98117 +__tty_buffer_request_room_27700 __tty_buffer_request_room 2 27700 NULL
98118 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
98119 +evm_write_key_27715 evm_write_key 3 27715 NULL
98120 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
98121 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
98122 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
98123 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
98124 +kcalloc_27770 kcalloc 1-2 27770 NULL
98125 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
98126 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
98127 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
98128 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
98129 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
98130 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
98131 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
98132 +read_profile_27859 read_profile 3 27859 NULL
98133 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
98134 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
98135 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
98136 +gluebi_write_27905 gluebi_write 3 27905 NULL
98137 +mc13783_set_sysclk_27914 mc13783_set_sysclk 5 27914 NULL
98138 +bm_find_next_27929 bm_find_next 2 27929 NULL
98139 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
98140 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
98141 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
98142 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
98143 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
98144 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
98145 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
98146 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
98147 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
98148 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
98149 +pool_status_28055 pool_status 5 28055 NULL
98150 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
98151 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
98152 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
98153 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
98154 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
98155 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
98156 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
98157 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
98158 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
98159 +video_read_28148 video_read 3 28148 NULL
98160 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
98161 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
98162 +vread_28173 vread 0 28173 NULL
98163 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
98164 +d_path_28198 d_path 0 28198 NULL
98165 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
98166 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
98167 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
98168 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
98169 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
98170 +usemap_size_28281 usemap_size 0 28281 NULL
98171 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
98172 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
98173 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
98174 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
98175 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
98176 +snapshot_write_28351 snapshot_write 3 28351 NULL
98177 +__next_wq_cpu_28352 __next_wq_cpu 1 28352 NULL
98178 +sys_writev_28384 sys_writev 3 28384 NULL
98179 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
98180 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
98181 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
98182 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
98183 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
98184 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
98185 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
98186 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
98187 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
98188 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
98189 +max_response_pages_28492 max_response_pages 0 28492 NULL
98190 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
98191 +__next_node_28521 __next_node 1 28521 NULL
98192 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
98193 +early_init_dt_alloc_memory_arch_28528 early_init_dt_alloc_memory_arch 1 28528 NULL
98194 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
98195 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
98196 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
98197 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
98198 +i2o_msg_post_wait_mem_28558 i2o_msg_post_wait_mem 0 28558 NULL
98199 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
98200 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
98201 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
98202 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
98203 +wm8350_clear_bits_28596 wm8350_clear_bits 2 28596 NULL
98204 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
98205 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
98206 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
98207 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
98208 +_set_range_28627 _set_range 3 28627 NULL
98209 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
98210 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
98211 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
98212 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
98213 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
98214 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
98215 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
98216 +spi_execute_28736 spi_execute 5 28736 NULL
98217 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
98218 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
98219 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
98220 +cxio_init_resource_fifo_28764 cxio_init_resource_fifo 3 28764 NULL
98221 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
98222 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
98223 +sel_write_member_28800 sel_write_member 3 28800 NULL
98224 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
98225 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0-8-3 28809 NULL
98226 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
98227 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
98228 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
98229 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
98230 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
98231 +tps6586x_update_28898 tps6586x_update 2 28898 NULL
98232 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
98233 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
98234 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
98235 +push_rx_28939 push_rx 3 28939 NULL
98236 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
98237 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
98238 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
98239 +bin_uuid_28999 bin_uuid 3 28999 NULL
98240 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
98241 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
98242 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
98243 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
98244 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
98245 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
98246 +ieee80211_probereq_get_29069 ieee80211_probereq_get 4-6 29069 NULL
98247 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
98248 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
98249 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
98250 +snprintf_29125 snprintf 0 29125 NULL
98251 +iov_shorten_29130 iov_shorten 0 29130 NULL
98252 +pm860x_reg_write_29141 pm860x_reg_write 2 29141 NULL
98253 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
98254 +reshape_ring_29147 reshape_ring 2 29147 NULL
98255 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
98256 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
98257 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
98258 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
98259 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
98260 +rds_iw_inc_copy_to_user_29214 rds_iw_inc_copy_to_user 3 29214 NULL
98261 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
98262 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
98263 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
98264 +recover_peb_29238 recover_peb 6-7 29238 NULL
98265 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
98266 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
98267 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
98268 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
98269 +fd_do_writev_29329 fd_do_writev 3 29329 NULL
98270 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
98271 +tun_put_user_29337 tun_put_user 5 29337 NULL
98272 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
98273 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
98274 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
98275 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
98276 +mempool_create_29437 mempool_create 1 29437 NULL
98277 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
98278 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
98279 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
98280 +do_register_entry_29478 do_register_entry 4 29478 NULL
98281 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
98282 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
98283 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
98284 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
98285 +ftrace_write_29551 ftrace_write 3 29551 NULL
98286 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
98287 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
98288 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
98289 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
98290 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
98291 +wm8903_gpio_set_29597 wm8903_gpio_set 2 29597 NULL
98292 +slots_per_page_29601 slots_per_page 0 29601 NULL
98293 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
98294 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
98295 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
98296 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
98297 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
98298 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
98299 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
98300 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
98301 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
98302 +probes_write_29711 probes_write 3 29711 NULL
98303 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
98304 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
98305 +da9055_gpio_direction_input_29742 da9055_gpio_direction_input 2 29742 NULL
98306 +cxio_hal_init_resource_29771 cxio_hal_init_resource 2-6-7 29771 NULL nohasharray
98307 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 &cxio_hal_init_resource_29771
98308 +dbAlloc_29794 dbAlloc 0 29794 NULL
98309 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
98310 +arizona_gpio_set_29823 arizona_gpio_set 2 29823 NULL
98311 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
98312 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
98313 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
98314 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
98315 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
98316 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
98317 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
98318 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
98319 +tps6586x_write_29894 tps6586x_write 2 29894 NULL
98320 +check586_29914 check586 2 29914 NULL
98321 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
98322 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
98323 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
98324 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
98325 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
98326 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
98327 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
98328 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
98329 +drp_wmove_30043 drp_wmove 4 30043 NULL
98330 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
98331 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
98332 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
98333 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL
98334 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
98335 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
98336 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
98337 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
98338 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
98339 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
98340 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
98341 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
98342 +snd_pcm_playback_forward_30201 snd_pcm_playback_forward 0-2 30201 NULL
98343 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
98344 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
98345 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
98346 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
98347 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
98348 +compat_readv_30273 compat_readv 3 30273 NULL
98349 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
98350 +__be64_to_cpup_30283 __be64_to_cpup 0 30283 NULL
98351 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
98352 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
98353 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
98354 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
98355 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
98356 +resource_from_user_30341 resource_from_user 3 30341 NULL
98357 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
98358 +sys_get_mempolicy_30379 sys_get_mempolicy 3 30379 NULL
98359 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
98360 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
98361 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
98362 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
98363 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
98364 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
98365 +enable_write_30456 enable_write 3 30456 NULL
98366 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
98367 +urandom_read_30462 urandom_read 3 30462 NULL
98368 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
98369 +write_head_30481 write_head 4 30481 NULL
98370 +adu_write_30487 adu_write 3 30487 NULL
98371 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
98372 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
98373 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
98374 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
98375 +set_le_30581 set_le 4 30581 NULL
98376 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
98377 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
98378 +sgl_map_user_pages_30610 sgl_map_user_pages 2 30610 NULL
98379 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
98380 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
98381 +nfsd_nrpools_30651 nfsd_nrpools 0 30651 NULL
98382 +agp_remap_30665 agp_remap 2 30665 NULL
98383 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
98384 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
98385 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
98386 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
98387 +snapshot_status_30744 snapshot_status 5 30744 NULL
98388 +max77693_update_reg_30747 max77693_update_reg 2 30747 NULL
98389 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
98390 +wm8350_read_auxadc_30780 wm8350_read_auxadc 2 30780 NULL
98391 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
98392 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
98393 +create_subvol_30836 create_subvol 4 30836 NULL
98394 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
98395 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL nohasharray
98396 +twl6040_set_bits_30844 twl6040_set_bits 2 30844 &cfg80211_rx_mgmt_30844
98397 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
98398 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
98399 +f1x_match_to_this_node_30888 f1x_match_to_this_node 3 30888 NULL
98400 +regmap_update_bits_check_30894 regmap_update_bits_check 2 30894 NULL
98401 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
98402 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
98403 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
98404 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
98405 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
98406 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
98407 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
98408 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
98409 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
98410 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
98411 +sys_mincore_31079 sys_mincore 1 31079 NULL
98412 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
98413 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
98414 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3 31109 NULL
98415 +depth_read_31112 depth_read 3 31112 NULL
98416 +ssb_read16_31139 ssb_read16 0 31139 NULL
98417 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
98418 +size_inside_page_31141 size_inside_page 0 31141 NULL
98419 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
98420 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
98421 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
98422 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
98423 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
98424 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
98425 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
98426 +__read_reg_31216 __read_reg 0 31216 NULL
98427 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
98428 +cyy_readb_31240 cyy_readb 0 31240 NULL
98429 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
98430 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
98431 +ceph_copy_page_vector_to_user_31270 ceph_copy_page_vector_to_user 3-4 31270 NULL
98432 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
98433 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
98434 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
98435 +futex_uaddr_31316 futex_uaddr 2 31316 NULL
98436 +command_file_write_31318 command_file_write 3 31318 NULL
98437 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
98438 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
98439 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3 31374 NULL
98440 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
98441 +inb_31388 inb 0 31388 NULL
98442 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
98443 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
98444 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
98445 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
98446 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
98447 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
98448 +_regmap_update_bits_31456 _regmap_update_bits 2 31456 NULL
98449 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
98450 +do_fcntl_31468 do_fcntl 3 31468 NULL
98451 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
98452 +alg_setkey_31485 alg_setkey 3 31485 NULL
98453 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
98454 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
98455 +__alloc_bootmem_31498 __alloc_bootmem 1 31498 NULL
98456 +hidraw_write_31536 hidraw_write 3 31536 NULL
98457 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
98458 +usbvision_read_31555 usbvision_read 3 31555 NULL
98459 +normalize_31566 normalize 0-1-2 31566 NULL
98460 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
98461 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
98462 +osst_write_31581 osst_write 3 31581 NULL
98463 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
98464 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
98465 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
98466 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
98467 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
98468 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
98469 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
98470 +__lgread_31668 __lgread 4 31668 NULL
98471 +symbol_string_31670 symbol_string 0 31670 NULL
98472 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
98473 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
98474 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
98475 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
98476 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL
98477 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
98478 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
98479 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
98480 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
98481 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
98482 +lm3533_led_get_pattern_reg_31752 lm3533_led_get_pattern_reg 0-2 31752 NULL
98483 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
98484 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
98485 +get_count_order_31800 get_count_order 0 31800 NULL
98486 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
98487 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
98488 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
98489 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
98490 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
98491 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
98492 +xattr_permission_31907 xattr_permission 0 31907 NULL
98493 +new_dir_31919 new_dir 3 31919 NULL
98494 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
98495 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
98496 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
98497 +vb2_write_31948 vb2_write 3 31948 NULL
98498 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
98499 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
98500 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
98501 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
98502 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
98503 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
98504 +calc_hmac_32010 calc_hmac 3 32010 NULL
98505 +aead_len_32021 aead_len 0 32021 NULL
98506 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
98507 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
98508 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
98509 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
98510 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
98511 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
98512 +bio_alloc_32095 bio_alloc 2 32095 NULL
98513 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
98514 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
98515 +disk_status_32120 disk_status 4 32120 NULL
98516 +rc5t583_write_32124 rc5t583_write 2 32124 NULL
98517 +venus_link_32165 venus_link 5 32165 NULL
98518 +drbd_new_dev_size_32171 drbd_new_dev_size 0 32171 NULL
98519 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
98520 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
98521 +load_header_32183 load_header 0 32183 NULL
98522 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
98523 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
98524 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
98525 +lm3533_write_32236 lm3533_write 2 32236 NULL
98526 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
98527 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
98528 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
98529 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
98530 +hex_string_32310 hex_string 0 32310 NULL
98531 +flakey_status_32315 flakey_status 5 32315 NULL
98532 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
98533 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
98534 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
98535 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
98536 +f1x_translate_sysaddr_to_cs_32359 f1x_translate_sysaddr_to_cs 2 32359 NULL
98537 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
98538 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
98539 +variax_set_raw2_32374 variax_set_raw2 4 32374 NULL
98540 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
98541 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
98542 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
98543 +log_text_32428 log_text 0 32428 NULL
98544 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
98545 +hid_input_report_32458 hid_input_report 4 32458 NULL
98546 +snd_pcm_sync_ptr_32461 snd_pcm_sync_ptr 0 32461 NULL
98547 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
98548 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
98549 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
98550 +disconnect_32521 disconnect 4 32521 NULL
98551 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
98552 +ilo_read_32531 ilo_read 3 32531 NULL
98553 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL nohasharray
98554 +crypt_status_32533 crypt_status 5 32533 &ieee80211_if_read_estab_plinks_32533
98555 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
98556 +__first_node_32558 __first_node 0 32558 NULL
98557 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
98558 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
98559 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
98560 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
98561 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
98562 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
98563 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
98564 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
98565 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
98566 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
98567 +kvmalloc_32646 kvmalloc 1 32646 NULL
98568 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
98569 +generic_readlink_32654 generic_readlink 3 32654 NULL
98570 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
98571 +tps80031_set_bits_32686 tps80031_set_bits 3 32686 NULL
98572 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
98573 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
98574 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
98575 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
98576 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
98577 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
98578 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
98579 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
98580 +vga_rseq_32848 vga_rseq 0 32848 NULL
98581 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
98582 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
98583 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
98584 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
98585 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
98586 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
98587 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
98588 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
98589 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
98590 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
98591 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
98592 +compat_filldir_32999 compat_filldir 3 32999 NULL
98593 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL
98594 +snd_pcm_prepare_33036 snd_pcm_prepare 0 33036 NULL
98595 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
98596 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
98597 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
98598 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
98599 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
98600 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
98601 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
98602 +write_node_33121 write_node 4 33121 NULL
98603 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
98604 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
98605 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
98606 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
98607 +pp_read_33210 pp_read 3 33210 NULL
98608 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
98609 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
98610 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
98611 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
98612 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
98613 +pcf50633_irq_mask_33280 pcf50633_irq_mask 2 33280 NULL
98614 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
98615 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
98616 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
98617 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
98618 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
98619 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
98620 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
98621 +ceph_osdc_writepages_33375 ceph_osdc_writepages 5 33375 NULL
98622 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
98623 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
98624 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
98625 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
98626 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
98627 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
98628 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
98629 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
98630 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
98631 +create_entry_33479 create_entry 2 33479 NULL
98632 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
98633 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
98634 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
98635 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
98636 +res_counter_read_33499 res_counter_read 4 33499 NULL
98637 +fb_read_33506 fb_read 3 33506 NULL
98638 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
98639 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
98640 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
98641 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
98642 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
98643 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
98644 +dup_array_33551 dup_array 3 33551 NULL
98645 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
98646 +count_subheaders_33591 count_subheaders 0 33591 NULL
98647 +scsi_execute_33596 scsi_execute 5 33596 NULL
98648 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
98649 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
98650 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
98651 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 NULL
98652 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
98653 +inw_p_33668 inw_p 0 33668 NULL
98654 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
98655 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
98656 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
98657 +rbd_alloc_coll_33678 rbd_alloc_coll 1 33678 NULL
98658 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
98659 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
98660 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
98661 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
98662 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
98663 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
98664 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
98665 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
98666 +Read_hfc_33755 Read_hfc 0 33755 NULL
98667 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
98668 +hashtab_create_33769 hashtab_create 3 33769 NULL
98669 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
98670 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
98671 +find_next_offset_33804 find_next_offset 3 33804 NULL
98672 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
98673 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
98674 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
98675 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
98676 +snd_pcm_action_nonatomic_33844 snd_pcm_action_nonatomic 0 33844 NULL
98677 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
98678 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
98679 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
98680 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
98681 +config_proc_write_33878 config_proc_write 3 33878 NULL
98682 +get_user_pages_33908 get_user_pages 0 33908 NULL
98683 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
98684 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
98685 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
98686 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
98687 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
98688 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
98689 +ppp_write_34034 ppp_write 3 34034 NULL
98690 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
98691 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
98692 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
98693 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
98694 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
98695 +show_risefalltime_34084 show_risefalltime 4 34084 NULL
98696 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
98697 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
98698 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
98699 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
98700 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
98701 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
98702 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
98703 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
98704 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
98705 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
98706 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
98707 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
98708 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
98709 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
98710 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
98711 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
98712 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
98713 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
98714 +ea_read_34378 ea_read 0 34378 NULL
98715 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
98716 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
98717 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
98718 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 NULL nohasharray
98719 +iwl_calib_set_34400 iwl_calib_set 3 34400 &ivtv_read_pos_34400
98720 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
98721 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
98722 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
98723 +line6_dumpreq_init_34473 line6_dumpreq_init 3 34473 NULL
98724 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
98725 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
98726 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
98727 +alloc_buf_34532 alloc_buf 1 34532 NULL
98728 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
98729 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
98730 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
98731 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
98732 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
98733 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
98734 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
98735 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
98736 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
98737 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
98738 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
98739 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
98740 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
98741 +port_print_34704 port_print 3 34704 NULL
98742 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
98743 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
98744 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
98745 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
98746 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
98747 +ssd1307fb_write_array_34779 ssd1307fb_write_array 4 34779 NULL
98748 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
98749 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
98750 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
98751 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
98752 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
98753 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
98754 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
98755 +lm3533_ctrlbank_get_reg_34886 lm3533_ctrlbank_get_reg 0-2 34886 NULL
98756 +msg_print_text_34889 msg_print_text 0 34889 NULL
98757 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
98758 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
98759 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
98760 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
98761 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL
98762 +Realloc_34961 Realloc 2 34961 NULL
98763 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
98764 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
98765 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
98766 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
98767 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
98768 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
98769 +store_ifalias_35088 store_ifalias 4 35088 NULL
98770 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
98771 +capi_write_35104 capi_write 3 35104 NULL nohasharray
98772 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
98773 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
98774 +pointer_35138 pointer 0 35138 NULL
98775 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
98776 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
98777 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
98778 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
98779 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
98780 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
98781 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
98782 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 NULL nohasharray
98783 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 &video_register_device_no_warn_35226
98784 +set_fd_set_35249 set_fd_set 1 35249 NULL
98785 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
98786 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
98787 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
98788 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
98789 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
98790 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
98791 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
98792 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
98793 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
98794 +new_bind_ctl_35324 new_bind_ctl 2 35324 NULL
98795 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
98796 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
98797 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
98798 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
98799 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
98800 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
98801 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
98802 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
98803 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
98804 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
98805 +rdev_get_id_35454 rdev_get_id 0 35454 NULL
98806 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
98807 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
98808 +async_setkey_35521 async_setkey 3 35521 NULL
98809 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
98810 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
98811 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
98812 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
98813 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
98814 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
98815 +ReadZReg_35604 ReadZReg 0 35604 NULL
98816 +kernel_readv_35617 kernel_readv 3 35617 NULL
98817 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
98818 +scrub_stripe_35637 scrub_stripe 4-3 35637 NULL
98819 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
98820 +store_debug_level_35652 store_debug_level 3 35652 NULL
98821 +regmap_update_bits_35668 regmap_update_bits 2 35668 NULL
98822 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
98823 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
98824 +dm_table_create_35687 dm_table_create 3 35687 NULL
98825 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
98826 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
98827 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
98828 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
98829 +read_file_stations_35795 read_file_stations 3 35795 NULL
98830 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
98831 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
98832 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
98833 +fls64_35862 fls64 0 35862 NULL
98834 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
98835 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
98836 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
98837 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
98838 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
98839 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
98840 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
98841 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
98842 +wm8350_reg_write_35967 wm8350_reg_write 2 35967 NULL
98843 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
98844 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
98845 +acl_alloc_35979 acl_alloc 1 35979 NULL
98846 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
98847 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
98848 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
98849 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
98850 +sys_init_module_36047 sys_init_module 2 36047 NULL
98851 +account_shadowed_36048 account_shadowed 2 36048 NULL
98852 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
98853 +snd_pcm_playback_hw_avail_36061 snd_pcm_playback_hw_avail 0 36061 NULL
98854 +write_emulate_36065 write_emulate 2-4 36065 NULL
98855 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
98856 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
98857 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
98858 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
98859 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
98860 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
98861 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
98862 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
98863 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
98864 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
98865 +iwl_trans_txq_alloc_36147 iwl_trans_txq_alloc 3 36147 NULL
98866 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
98867 +twl_set_36154 twl_set 2 36154 NULL
98868 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
98869 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
98870 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
98871 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
98872 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
98873 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
98874 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
98875 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
98876 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
98877 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
98878 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
98879 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
98880 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
98881 +readahead_tree_block_36285 readahead_tree_block 3 36285 NULL
98882 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
98883 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
98884 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
98885 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
98886 +lc_create_36332 lc_create 4 36332 NULL
98887 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
98888 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
98889 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
98890 +to_sector_36361 to_sector 0-1 36361 NULL
98891 +tunables_read_36385 tunables_read 3 36385 NULL
98892 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
98893 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
98894 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
98895 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
98896 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
98897 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
98898 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
98899 +get_param_l_36518 get_param_l 0 36518 NULL
98900 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
98901 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
98902 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
98903 +ssd1307fb_write_data_array_36538 ssd1307fb_write_data_array 3 36538 NULL
98904 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
98905 +get_entry_len_36549 get_entry_len 0 36549 NULL
98906 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
98907 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
98908 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
98909 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
98910 +__erst_read_36579 __erst_read 0 36579 NULL
98911 +put_cmsg_36589 put_cmsg 4 36589 NULL
98912 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
98913 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
98914 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
98915 +format_decode_36638 format_decode 0 36638 NULL
98916 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
98917 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
98918 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
98919 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
98920 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
98921 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
98922 +snd_soc_update_bits_36714 snd_soc_update_bits 2 36714 NULL
98923 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
98924 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
98925 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
98926 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
98927 +snd_soc_update_bits_locked_36766 snd_soc_update_bits_locked 2 36766 NULL
98928 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
98929 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
98930 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
98931 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
98932 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
98933 +pcf50633_reg_write_36841 pcf50633_reg_write 2 36841 NULL nohasharray
98934 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 &pcf50633_reg_write_36841
98935 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
98936 +cm_write_36858 cm_write 3 36858 NULL
98937 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
98938 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
98939 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
98940 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
98941 +lm3533_als_get_target_36905 lm3533_als_get_target 2-3 36905 NULL
98942 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
98943 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
98944 +div_u64_36951 div_u64 0 36951 NULL
98945 +write_leb_36957 write_leb 5 36957 NULL
98946 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
98947 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
98948 +mc13xxx_reg_rmw_36997 mc13xxx_reg_rmw 2 36997 NULL
98949 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
98950 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
98951 +setxattr_37006 setxattr 4 37006 NULL
98952 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 NULL
98953 +parse_command_37079 parse_command 2 37079 NULL
98954 +wm8994_gpio_set_37082 wm8994_gpio_set 2 37082 NULL
98955 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
98956 +tun_get_user_37094 tun_get_user 5 37094 NULL
98957 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
98958 +msg_word_37164 msg_word 0 37164 NULL
98959 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
98960 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
98961 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
98962 +__do_replace_37227 __do_replace 5 37227 NULL
98963 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
98964 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
98965 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
98966 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
98967 +c101_run_37279 c101_run 2 37279 NULL
98968 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
98969 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
98970 +send_msg_37323 send_msg 4 37323 NULL
98971 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
98972 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
98973 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
98974 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
98975 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
98976 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
98977 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
98978 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
98979 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
98980 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
98981 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
98982 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
98983 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
98984 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
98985 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
98986 +get_est_timing_37484 get_est_timing 0 37484 NULL
98987 +xfs_trans_read_buf_map_37487 xfs_trans_read_buf_map 5 37487 NULL
98988 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
98989 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
98990 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
98991 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
98992 +hdr_size_37536 hdr_size 0 37536 NULL
98993 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
98994 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
98995 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
98996 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
98997 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6 37611 NULL
98998 +alloc_fd_37637 alloc_fd 1 37637 NULL
98999 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
99000 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
99001 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
99002 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
99003 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
99004 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
99005 +nametbl_header_37698 nametbl_header 2 37698 NULL
99006 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
99007 +soc_widget_update_bits_locked_37715 soc_widget_update_bits_locked 2 37715 NULL
99008 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
99009 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
99010 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
99011 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
99012 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
99013 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
99014 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
99015 +deny_write_access_37813 deny_write_access 0 37813 NULL
99016 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
99017 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
99018 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
99019 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
99020 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
99021 +lm3533_als_get_target_reg_37881 lm3533_als_get_target_reg 0-1-2 37881 NULL
99022 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
99023 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
99024 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
99025 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
99026 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
99027 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
99028 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
99029 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
99030 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
99031 +vfs_readv_38011 vfs_readv 3 38011 NULL
99032 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
99033 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
99034 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
99035 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL
99036 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
99037 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
99038 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
99039 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
99040 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
99041 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
99042 +ep0_read_38095 ep0_read 3 38095 NULL
99043 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
99044 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
99045 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
99046 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
99047 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
99048 +cdev_add_38176 cdev_add 2-3 38176 NULL
99049 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
99050 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
99051 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
99052 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
99053 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
99054 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
99055 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
99056 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
99057 +snd_pcm_playback_rewind_38249 snd_pcm_playback_rewind 0-2 38249 NULL
99058 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
99059 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
99060 +verity_status_38273 verity_status 5 38273 NULL
99061 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
99062 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
99063 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
99064 +ieee80211_send_probe_req_38307 ieee80211_send_probe_req 6-4 38307 NULL
99065 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
99066 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
99067 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
99068 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
99069 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
99070 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
99071 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
99072 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
99073 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
99074 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
99075 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
99076 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
99077 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
99078 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
99079 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
99080 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
99081 +dev_names_read_38509 dev_names_read 3 38509 NULL
99082 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
99083 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
99084 +set_queue_count_38519 set_queue_count 0 38519 NULL
99085 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
99086 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
99087 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
99088 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
99089 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
99090 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
99091 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
99092 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
99093 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
99094 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
99095 +delay_status_38606 delay_status 5 38606 NULL
99096 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
99097 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
99098 +cma_create_area_38642 cma_create_area 2 38642 NULL
99099 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
99100 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
99101 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
99102 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
99103 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
99104 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
99105 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
99106 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
99107 +udf_readpages_38761 udf_readpages 4 38761 NULL
99108 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
99109 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
99110 +err_decode_38804 err_decode 2 38804 NULL
99111 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
99112 +sys_select_38827 sys_select 1 38827 NULL
99113 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
99114 +direct_entry_38836 direct_entry 3 38836 NULL
99115 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
99116 +interfaces_38859 interfaces 2 38859 NULL
99117 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
99118 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
99119 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
99120 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
99121 +__fswab16_38898 __fswab16 0 38898 NULL
99122 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
99123 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
99124 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
99125 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
99126 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL
99127 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
99128 +udf_new_block_38999 udf_new_block 4 38999 NULL
99129 +get_nodes_39012 get_nodes 3 39012 NULL
99130 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
99131 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
99132 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
99133 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
99134 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
99135 +tun_get_user_39099 tun_get_user 4 39099 NULL
99136 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
99137 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
99138 +ea_foreach_39133 ea_foreach 0 39133 NULL
99139 +generic_permission_39150 generic_permission 0 39150 NULL
99140 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
99141 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
99142 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
99143 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
99144 +init_list_set_39188 init_list_set 2-3 39188 NULL
99145 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
99146 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
99147 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
99148 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
99149 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
99150 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
99151 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
99152 +drm_order_39244 drm_order 0 39244 NULL
99153 +snd_pcm_capture_forward_39248 snd_pcm_capture_forward 0-2 39248 NULL
99154 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
99155 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
99156 +__skb_cow_39254 __skb_cow 2 39254 NULL
99157 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
99158 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
99159 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
99160 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
99161 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
99162 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
99163 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
99164 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
99165 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
99166 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
99167 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
99168 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
99169 +__send_to_port_39386 __send_to_port 3 39386 NULL
99170 +user_power_read_39414 user_power_read 3 39414 NULL
99171 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
99172 +sys_semop_39457 sys_semop 3 39457 NULL
99173 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
99174 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
99175 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
99176 +int_proc_write_39542 int_proc_write 3 39542 NULL
99177 +pp_write_39554 pp_write 3 39554 NULL
99178 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
99179 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
99180 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
99181 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
99182 +adau1373_set_pll_39593 adau1373_set_pll 2 39593 NULL
99183 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
99184 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
99185 +ext_depth_39607 ext_depth 0 39607 NULL
99186 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
99187 +sdio_readb_39618 sdio_readb 0 39618 NULL
99188 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
99189 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
99190 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
99191 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
99192 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
99193 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
99194 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
99195 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
99196 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
99197 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
99198 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
99199 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
99200 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
99201 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
99202 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
99203 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
99204 +pkt_add_39897 pkt_add 3 39897 NULL
99205 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
99206 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
99207 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
99208 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
99209 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
99210 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
99211 +__spi_async_39932 __spi_async 0 39932 NULL
99212 +__get_order_39935 __get_order 0 39935 NULL
99213 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
99214 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
99215 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
99216 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
99217 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
99218 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
99219 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
99220 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
99221 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
99222 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
99223 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
99224 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
99225 +add_tty_40055 add_tty 1 40055 NULL nohasharray
99226 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
99227 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
99228 +snd_pcm_sw_params_user_40095 snd_pcm_sw_params_user 0 40095 NULL
99229 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
99230 +rbd_do_op_40128 rbd_do_op 4-5 40128 NULL
99231 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
99232 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
99233 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
99234 +pt_write_40159 pt_write 3 40159 NULL
99235 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
99236 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
99237 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
99238 +allocate_probes_40204 allocate_probes 1 40204 NULL
99239 +acpi_system_write_alarm_40205 acpi_system_write_alarm 3 40205 NULL
99240 +compat_put_long_40214 compat_put_long 1 40214 NULL
99241 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
99242 +xfs_buf_read_map_40226 xfs_buf_read_map 3 40226 NULL
99243 +osst_read_40237 osst_read 3 40237 NULL
99244 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
99245 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
99246 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
99247 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
99248 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
99249 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
99250 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
99251 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
99252 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
99253 +mmio_read_40348 mmio_read 4 40348 NULL
99254 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
99255 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
99256 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
99257 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
99258 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
99259 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
99260 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
99261 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
99262 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
99263 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
99264 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
99265 +tty_write_room_40495 tty_write_room 0 40495 NULL
99266 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
99267 +sg_phys_40507 sg_phys 0 40507 NULL
99268 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
99269 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
99270 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
99271 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
99272 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
99273 +arch_setup_hpet_msi_40584 arch_setup_hpet_msi 1 40584 NULL
99274 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
99275 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
99276 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
99277 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
99278 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
99279 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
99280 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
99281 +fops_read_40672 fops_read 3 40672 NULL
99282 +tps80031_write_40678 tps80031_write 3 40678 NULL
99283 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
99284 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
99285 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
99286 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
99287 +tps65910_irq_map_40748 tps65910_irq_map 2 40748 NULL
99288 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
99289 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
99290 +card_send_command_40757 card_send_command 3 40757 NULL
99291 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
99292 +pg_write_40766 pg_write 3 40766 NULL
99293 +show_list_40775 show_list 3 40775 NULL
99294 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
99295 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
99296 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
99297 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
99298 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
99299 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
99300 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
99301 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
99302 +read_file_queue_40895 read_file_queue 3 40895 NULL
99303 +waiters_read_40902 waiters_read 3 40902 NULL
99304 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
99305 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
99306 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
99307 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
99308 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
99309 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
99310 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
99311 +insert_old_idx_40987 insert_old_idx 0 40987 NULL
99312 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
99313 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
99314 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
99315 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
99316 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
99317 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
99318 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
99319 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
99320 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
99321 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
99322 +dma_attach_41094 dma_attach 5-6 41094 NULL
99323 +provide_user_output_41105 provide_user_output 3 41105 NULL
99324 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
99325 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
99326 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
99327 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
99328 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
99329 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
99330 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
99331 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
99332 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
99333 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
99334 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
99335 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
99336 +erst_read_41260 erst_read 0 41260 NULL
99337 +__fprog_create_41263 __fprog_create 2 41263 NULL
99338 +alloc_context_41283 alloc_context 1 41283 NULL
99339 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
99340 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
99341 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
99342 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
99343 +kmp_init_41373 kmp_init 2 41373 NULL
99344 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
99345 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
99346 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
99347 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
99348 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
99349 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
99350 +ext4_trim_extent_41436 ext4_trim_extent 4 41436 NULL
99351 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
99352 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
99353 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
99354 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
99355 +snd_pcm_status_41472 snd_pcm_status 0 41472 NULL
99356 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
99357 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
99358 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
99359 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
99360 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
99361 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
99362 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
99363 +gserial_setup_41558 gserial_setup 2 41558 NULL
99364 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
99365 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
99366 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
99367 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
99368 +vga_io_r_41609 vga_io_r 0 41609 NULL
99369 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
99370 +a2mp_send_41615 a2mp_send 4 41615 NULL
99371 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
99372 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
99373 +get_std_timing_41654 get_std_timing 0 41654 NULL
99374 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
99375 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
99376 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
99377 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
99378 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
99379 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
99380 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
99381 +fillonedir_41746 fillonedir 3 41746 NULL
99382 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
99383 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
99384 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
99385 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
99386 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
99387 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
99388 +irq_data_to_status_reg_41854 irq_data_to_status_reg 0 41854 NULL
99389 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
99390 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
99391 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
99392 +ceph_get_direct_page_vector_41917 ceph_get_direct_page_vector 2 41917 NULL
99393 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
99394 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
99395 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
99396 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
99397 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
99398 +portnames_read_41958 portnames_read 3 41958 NULL
99399 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
99400 +dst_mtu_41969 dst_mtu 0 41969 NULL
99401 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
99402 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
99403 +lguest_map_42008 lguest_map 1-2 42008 NULL
99404 +pool_allocate_42012 pool_allocate 3 42012 NULL
99405 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
99406 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
99407 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
99408 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
99409 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
99410 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
99411 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
99412 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
99413 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
99414 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
99415 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
99416 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL
99417 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
99418 +v9fs_alloc_rdir_buf_42150 v9fs_alloc_rdir_buf 2 42150 NULL
99419 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
99420 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
99421 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
99422 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
99423 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
99424 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
99425 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
99426 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
99427 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
99428 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
99429 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
99430 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
99431 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
99432 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
99433 +tcp_sync_mss_42330 tcp_sync_mss 2-0 42330 NULL
99434 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
99435 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
99436 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
99437 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
99438 +krng_get_random_42420 krng_get_random 3 42420 NULL
99439 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
99440 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
99441 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
99442 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
99443 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
99444 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
99445 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
99446 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
99447 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
99448 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
99449 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
99450 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
99451 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
99452 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
99453 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
99454 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
99455 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
99456 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
99457 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
99458 +map_state_42602 map_state 1 42602 NULL nohasharray
99459 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
99460 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
99461 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
99462 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
99463 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
99464 +_regmap_raw_write_42652 _regmap_raw_write 4-2 42652 NULL
99465 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
99466 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
99467 +vb2_read_42703 vb2_read 3 42703 NULL
99468 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
99469 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
99470 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
99471 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
99472 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
99473 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
99474 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
99475 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL
99476 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
99477 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
99478 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
99479 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
99480 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
99481 +set_arg_42824 set_arg 3 42824 NULL
99482 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
99483 +xfs_buf_read_uncached_42844 xfs_buf_read_uncached 3 42844 NULL
99484 +prandom_u32_42853 prandom_u32 0 42853 NULL
99485 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
99486 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
99487 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
99488 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
99489 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
99490 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
99491 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
99492 +hd_end_request_42904 hd_end_request 2 42904 NULL
99493 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
99494 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
99495 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
99496 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
99497 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
99498 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
99499 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
99500 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
99501 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
99502 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
99503 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
99504 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
99505 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
99506 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
99507 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
99508 +uuid_string_43154 uuid_string 0 43154 NULL
99509 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
99510 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
99511 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
99512 +process_measurement_43190 process_measurement 0 43190 NULL
99513 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
99514 +uio_write_43202 uio_write 3 43202 NULL
99515 +iso_callback_43208 iso_callback 3 43208 NULL
99516 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
99517 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
99518 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
99519 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
99520 +fixup_leb_43256 fixup_leb 3 43256 NULL
99521 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
99522 +evtchn_write_43278 evtchn_write 3 43278 NULL
99523 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
99524 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
99525 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
99526 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
99527 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
99528 +xenfb_write_43412 xenfb_write 3 43412 NULL
99529 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 NULL nohasharray
99530 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1 43423 &gdm_wimax_netif_rx_43423
99531 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
99532 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
99533 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
99534 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
99535 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
99536 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
99537 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
99538 +do_readlink_43518 do_readlink 2 43518 NULL
99539 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
99540 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
99541 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
99542 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
99543 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
99544 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
99545 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
99546 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
99547 +proc_read_43614 proc_read 3 43614 NULL
99548 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
99549 +tps65217_set_bits_43659 tps65217_set_bits 2 43659 NULL nohasharray
99550 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 &tps65217_set_bits_43659
99551 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
99552 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
99553 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
99554 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
99555 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
99556 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
99557 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
99558 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
99559 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
99560 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
99561 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
99562 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
99563 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
99564 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
99565 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
99566 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
99567 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
99568 +read_flush_43851 read_flush 3 43851 NULL
99569 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
99570 +pm860x_bulk_write_43875 pm860x_bulk_write 3-2 43875 NULL
99571 +ec_dbgfs_cmd_write_43895 ec_dbgfs_cmd_write 3 43895 NULL
99572 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
99573 +SendString_43928 SendString 3 43928 NULL
99574 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
99575 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
99576 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
99577 +nla_reserve_43984 nla_reserve 3 43984 NULL
99578 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
99579 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
99580 +emit_flags_44006 emit_flags 4-3 44006 NULL
99581 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
99582 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
99583 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
99584 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
99585 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
99586 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
99587 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
99588 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
99589 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
99590 +__set_free_44211 __set_free 2 44211 NULL
99591 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
99592 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
99593 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
99594 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
99595 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
99596 +enlarge_skb_44248 enlarge_skb 2 44248 NULL nohasharray
99597 +xfs_buf_readahead_map_44248 xfs_buf_readahead_map 3 44248 &enlarge_skb_44248
99598 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
99599 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
99600 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
99601 +bitmap_scnprintf_44318 bitmap_scnprintf 0-2 44318 NULL
99602 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
99603 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
99604 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
99605 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
99606 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
99607 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
99608 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
99609 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
99610 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
99611 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
99612 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
99613 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
99614 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
99615 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
99616 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
99617 +spidev_write_44510 spidev_write 3 44510 NULL
99618 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
99619 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
99620 +snd_pcm_drop_44542 snd_pcm_drop 0 44542 NULL
99621 +dbg_chk_pnode_44555 dbg_chk_pnode 0 44555 NULL
99622 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
99623 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
99624 +wm5100_gpio_set_44602 wm5100_gpio_set 2 44602 NULL
99625 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
99626 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
99627 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
99628 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
99629 +mpi_resize_44674 mpi_resize 2 44674 NULL
99630 +ts_read_44687 ts_read 3 44687 NULL
99631 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
99632 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
99633 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
99634 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
99635 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
99636 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
99637 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
99638 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
99639 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
99640 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
99641 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
99642 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
99643 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
99644 +sisusb_write_44834 sisusb_write 3 44834 NULL
99645 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
99646 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
99647 +skb_availroom_44883 skb_availroom 0 44883 NULL
99648 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
99649 +do_tty_write_44896 do_tty_write 5 44896 NULL
99650 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
99651 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
99652 +max77693_write_reg_45004 max77693_write_reg 2 45004 NULL
99653 +ftdi_process_packet_45005 ftdi_process_packet 5 45005 NULL
99654 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
99655 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
99656 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
99657 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
99658 +sel_write_user_45060 sel_write_user 3 45060 NULL
99659 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
99660 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
99661 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
99662 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
99663 +usbdev_read_45114 usbdev_read 3 45114 NULL
99664 +send_to_tty_45141 send_to_tty 3 45141 NULL
99665 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
99666 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
99667 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
99668 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
99669 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
99670 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
99671 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
99672 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
99673 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
99674 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
99675 +add_child_45201 add_child 4 45201 NULL
99676 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
99677 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
99678 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
99679 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
99680 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
99681 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
99682 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
99683 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
99684 +keymap_store_45406 keymap_store 4 45406 NULL
99685 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 NULL
99686 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
99687 +do_mmap_pgoff_45441 do_mmap_pgoff 0 45441 NULL
99688 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL
99689 +__node_remap_45458 __node_remap 4 45458 NULL
99690 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
99691 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
99692 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
99693 +snd_pcm_hwsync_45479 snd_pcm_hwsync 0 45479 NULL
99694 +arizona_init_fll_45503 arizona_init_fll 4-5 45503 NULL
99695 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
99696 +clone_bio_45516 clone_bio 6 45516 NULL
99697 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
99698 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
99699 +copy_macs_45534 copy_macs 4 45534 NULL
99700 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
99701 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
99702 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
99703 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
99704 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
99705 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
99706 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
99707 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
99708 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
99709 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
99710 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
99711 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
99712 +da9052_gpio_set_45643 da9052_gpio_set 2 45643 NULL
99713 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
99714 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
99715 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
99716 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
99717 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
99718 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
99719 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
99720 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
99721 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
99722 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
99723 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
99724 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
99725 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
99726 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
99727 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
99728 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
99729 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
99730 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
99731 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
99732 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
99733 +amthi_read_45831 amthi_read 4 45831 NULL
99734 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
99735 +isdn_write_45863 isdn_write 3 45863 NULL
99736 +rbd_get_num_segments_45864 rbd_get_num_segments 0-2-3 45864 NULL
99737 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
99738 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
99739 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
99740 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
99741 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
99742 +alloc_mr_45935 alloc_mr 1 45935 NULL
99743 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
99744 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
99745 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
99746 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
99747 +get_free_entries_46030 get_free_entries 1 46030 NULL
99748 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
99749 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
99750 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
99751 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
99752 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
99753 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
99754 +slhc_toss_46066 slhc_toss 0 46066 NULL
99755 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
99756 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
99757 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
99758 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
99759 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
99760 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
99761 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
99762 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
99763 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
99764 +qlcnic_alloc_msix_entries_46160 qlcnic_alloc_msix_entries 2 46160 NULL
99765 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
99766 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
99767 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
99768 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
99769 +dsp_write_46218 dsp_write 2 46218 NULL
99770 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
99771 +__le64_to_cpup_46257 __le64_to_cpup 0 46257 NULL
99772 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
99773 +ReadReg_46277 ReadReg 0 46277 NULL
99774 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
99775 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
99776 +twl6040_write_46351 twl6040_write 2 46351 NULL
99777 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
99778 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
99779 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
99780 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
99781 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
99782 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
99783 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
99784 +filldir64_46469 filldir64 3 46469 NULL
99785 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
99786 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
99787 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
99788 +kmsg_read_46514 kmsg_read 3 46514 NULL
99789 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
99790 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
99791 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
99792 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
99793 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
99794 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
99795 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
99796 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
99797 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
99798 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
99799 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
99800 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
99801 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
99802 +aircable_process_packet_46639 aircable_process_packet 5 46639 NULL
99803 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
99804 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
99805 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
99806 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
99807 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
99808 +prepare_copy_46725 prepare_copy 2 46725 NULL
99809 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
99810 +ext4_count_free_46754 ext4_count_free 2 46754 NULL
99811 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
99812 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
99813 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
99814 +scrub_chunk_46789 scrub_chunk 4 46789 NULL
99815 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
99816 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
99817 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
99818 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
99819 +ieee80211_rx_radiotap_len_46846 ieee80211_rx_radiotap_len 0 46846 NULL
99820 +spi_async_46857 spi_async 0 46857 NULL
99821 +ieee80211_mgmt_tx_46860 ieee80211_mgmt_tx 9 46860 NULL
99822 +vsnprintf_46863 vsnprintf 0 46863 NULL
99823 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
99824 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
99825 +rvmalloc_46873 rvmalloc 1 46873 NULL
99826 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
99827 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
99828 +em28xx_alloc_isoc_46892 em28xx_alloc_isoc 4 46892 NULL
99829 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
99830 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
99831 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
99832 +fb_write_46924 fb_write 3 46924 NULL
99833 +raid_status_46930 raid_status 5 46930 NULL
99834 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
99835 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
99836 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
99837 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
99838 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
99839 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
99840 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
99841 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
99842 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
99843 +__map_single_47020 __map_single 3-4-7 47020 NULL
99844 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
99845 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
99846 +wm8994_set_bits_47052 wm8994_set_bits 2 47052 NULL
99847 +fs_path_len_47060 fs_path_len 0 47060 NULL
99848 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
99849 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
99850 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
99851 +mousedev_read_47123 mousedev_read 3 47123 NULL
99852 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
99853 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
99854 +cxio_init_resource_fifo_random_47151 cxio_init_resource_fifo_random 3 47151 NULL
99855 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
99856 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
99857 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
99858 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
99859 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
99860 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
99861 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
99862 +wm8903_gpio_direction_in_47213 wm8903_gpio_direction_in 2 47213 NULL
99863 +l2headersize_47238 l2headersize 0 47238 NULL
99864 +options_write_47243 options_write 3 47243 NULL
99865 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
99866 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
99867 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
99868 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
99869 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
99870 +vsnprintf_47291 vsnprintf 0 47291 NULL
99871 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
99872 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
99873 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
99874 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
99875 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
99876 +trace_options_core_read_47390 trace_options_core_read 3 47390 NULL
99877 +nametbl_list_47391 nametbl_list 2 47391 NULL
99878 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
99879 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
99880 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
99881 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
99882 +vzalloc_47421 vzalloc 1 47421 NULL
99883 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
99884 +newpart_47485 newpart 6 47485 NULL
99885 +core_sys_select_47494 core_sys_select 1 47494 NULL
99886 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
99887 +unlink_simple_47506 unlink_simple 3 47506 NULL
99888 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
99889 +snd_pcm_resume_47530 snd_pcm_resume 0 47530 NULL
99890 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
99891 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
99892 +oz_events_read_47535 oz_events_read 3 47535 NULL
99893 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
99894 +cycx_setup_47562 cycx_setup 4 47562 NULL
99895 +read_ldt_47570 read_ldt 2 47570 NULL
99896 +pci_iomap_47575 pci_iomap 3 47575 NULL
99897 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
99898 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
99899 +wm831x_gpio_direction_out_47607 wm831x_gpio_direction_out 2 47607 NULL
99900 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
99901 +uea_request_47613 uea_request 4 47613 NULL
99902 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
99903 +tps65217_clear_bits_47619 tps65217_clear_bits 2 47619 NULL
99904 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
99905 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
99906 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
99907 +irq_linear_revmap_47682 irq_linear_revmap 0 47682 NULL
99908 +snd_pcm_info_47699 snd_pcm_info 0 47699 NULL
99909 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
99910 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
99911 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
99912 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
99913 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
99914 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
99915 +irq_domain_legacy_revmap_47765 irq_domain_legacy_revmap 0-2 47765 NULL
99916 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
99917 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
99918 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
99919 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
99920 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
99921 +__pcf50633_irq_mask_set_47847 __pcf50633_irq_mask_set 2 47847 NULL
99922 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
99923 +vhci_read_47878 vhci_read 3 47878 NULL
99924 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
99925 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
99926 +timeout_read_47915 timeout_read 3 47915 NULL
99927 +comedi_write_47926 comedi_write 3 47926 NULL
99928 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
99929 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
99930 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
99931 +pnpacpi_parse_allocated_irqresource_47986 pnpacpi_parse_allocated_irqresource 2 47986 NULL
99932 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
99933 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
99934 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
99935 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
99936 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
99937 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
99938 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
99939 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
99940 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
99941 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
99942 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
99943 +rtsx_read_cfg_seq_48139 rtsx_read_cfg_seq 5-3 48139 NULL
99944 +set_discoverable_48141 set_discoverable 4 48141 NULL
99945 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
99946 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
99947 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
99948 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
99949 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL
99950 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
99951 +init_ipath_48187 init_ipath 1 48187 NULL nohasharray
99952 +ieee80211_send_auth_48187 ieee80211_send_auth 6 48187 &init_ipath_48187
99953 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
99954 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
99955 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
99956 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
99957 +read_file_recv_48232 read_file_recv 3 48232 NULL
99958 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL nohasharray
99959 +blk_rq_pos_48233 blk_rq_pos 0 48233 &unaccount_shadowed_48233
99960 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
99961 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
99962 +send_set_info_48288 send_set_info 7 48288 NULL
99963 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
99964 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
99965 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
99966 +hash_setkey_48310 hash_setkey 3 48310 NULL
99967 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
99968 +skb_add_data_48363 skb_add_data 3 48363 NULL
99969 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
99970 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
99971 +snd_power_wait_48422 snd_power_wait 0 48422 NULL
99972 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
99973 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
99974 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
99975 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
99976 +send_control_msg_48498 send_control_msg 6 48498 NULL
99977 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
99978 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
99979 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
99980 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
99981 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
99982 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
99983 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
99984 +named_distribute_48544 named_distribute 4 48544 NULL
99985 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
99986 +ext_sd_execute_read_data_48589 ext_sd_execute_read_data 9 48589 NULL
99987 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
99988 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
99989 +mtd_read_48655 mtd_read 0 48655 NULL
99990 +lc_create_48662 lc_create 3 48662 NULL
99991 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
99992 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
99993 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
99994 +altera_drscan_48698 altera_drscan 2 48698 NULL
99995 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
99996 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
99997 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
99998 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
99999 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
100000 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
100001 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
100002 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
100003 +azx_get_position_48841 azx_get_position 0 48841 NULL
100004 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
100005 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL
100006 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
100007 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
100008 +get_num_ops_48886 get_num_ops 0 48886 NULL
100009 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
100010 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
100011 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
100012 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
100013 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL nohasharray
100014 +snd_pcm_update_hw_ptr_48925 snd_pcm_update_hw_ptr 0 48925 &gdth_isa_probe_one_48925
100015 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
100016 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
100017 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
100018 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
100019 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
100020 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
100021 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
100022 +xd_rw_49020 xd_rw 3-4 49020 NULL
100023 +transient_status_49027 transient_status 4 49027 NULL
100024 +ubi_read_49061 ubi_read 0 49061 NULL
100025 +tps65910_reg_write_49066 tps65910_reg_write 2 49066 NULL
100026 +calc_layout_49074 calc_layout 4 49074 NULL
100027 +vmx_set_msr_49090 vmx_set_msr 3 49090 NULL
100028 +scsi_register_49094 scsi_register 2 49094 NULL
100029 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
100030 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
100031 +pt_read_49136 pt_read 3 49136 NULL
100032 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
100033 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
100034 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
100035 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
100036 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
100037 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
100038 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
100039 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
100040 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
100041 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
100042 +pcf50633_gpio_invert_set_49256 pcf50633_gpio_invert_set 2 49256 NULL
100043 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
100044 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
100045 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
100046 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
100047 +uio_read_49300 uio_read 3 49300 NULL
100048 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
100049 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
100050 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
100051 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
100052 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
100053 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
100054 +px_raw_event_49371 px_raw_event 4 49371 NULL
100055 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
100056 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
100057 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
100058 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
100059 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
100060 +md_domain_init_49432 md_domain_init 2 49432 NULL
100061 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
100062 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
100063 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
100064 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
100065 +ieee80211_ie_split_49474 ieee80211_ie_split 0-5 49474 NULL
100066 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
100067 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
100068 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
100069 +wm831x_dcdc_set_mode_int_49546 wm831x_dcdc_set_mode_int 2 49546 NULL
100070 +smk_write_access_49561 smk_write_access 3 49561 NULL
100071 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
100072 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
100073 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
100074 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
100075 +heap_init_49617 heap_init 2 49617 NULL
100076 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
100077 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
100078 +svm_set_msr_49643 svm_set_msr 3 49643 NULL
100079 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
100080 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
100081 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
100082 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
100083 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
100084 +check_frame_49741 check_frame 0 49741 NULL
100085 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
100086 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
100087 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
100088 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
100089 +isku_sysfs_write_49767 isku_sysfs_write 6 49767 NULL
100090 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
100091 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
100092 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
100093 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
100094 +add_uuid_49831 add_uuid 4 49831 NULL
100095 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
100096 +__btrfs_map_block_49839 __btrfs_map_block 3 49839 NULL
100097 +twl4030_write_49846 twl4030_write 2 49846 NULL
100098 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
100099 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
100100 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
100101 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
100102 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
100103 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
100104 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
100105 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
100106 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
100107 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
100108 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
100109 +__module_alloc_50004 __module_alloc 1 50004 NULL
100110 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
100111 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
100112 +isdn_read_50021 isdn_read 3 50021 NULL
100113 +rbd_req_write_50041 rbd_req_write 4-5 50041 NULL
100114 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
100115 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
100116 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
100117 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
100118 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
100119 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
100120 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
100121 +read_file_slot_50111 read_file_slot 3 50111 NULL
100122 +copy_items_50140 copy_items 6 50140 NULL
100123 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
100124 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
100125 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
100126 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
100127 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
100128 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
100129 +odev_update_50169 odev_update 2 50169 NULL
100130 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
100131 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
100132 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
100133 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
100134 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
100135 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
100136 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
100137 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
100138 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
100139 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
100140 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
100141 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
100142 +do_launder_page_50329 do_launder_page 0 50329 NULL
100143 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
100144 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
100145 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
100146 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
100147 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
100148 +tpm_read_50344 tpm_read 3 50344 NULL
100149 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
100150 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
100151 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
100152 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
100153 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
100154 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
100155 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
100156 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
100157 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
100158 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
100159 +tps65217_update_bits_50472 tps65217_update_bits 2 50472 NULL
100160 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
100161 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
100162 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
100163 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
100164 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
100165 +pcf50633_reg_set_bit_mask_50544 pcf50633_reg_set_bit_mask 2 50544 NULL
100166 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
100167 +fat_readpages_50582 fat_readpages 4 50582 NULL
100168 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
100169 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
100170 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
100171 +__ffs_50625 __ffs 0 50625 NULL
100172 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
100173 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
100174 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
100175 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
100176 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
100177 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
100178 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
100179 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
100180 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
100181 +skb_padto_50759 skb_padto 2 50759 NULL
100182 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
100183 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
100184 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
100185 +tpm_write_50798 tpm_write 3 50798 NULL
100186 +tun_do_read_50800 tun_do_read 4 50800 NULL
100187 +write_flush_50803 write_flush 3 50803 NULL
100188 +dvb_play_50814 dvb_play 3 50814 NULL
100189 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
100190 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
100191 +pstore_mkfile_50830 pstore_mkfile 5 50830 NULL
100192 +dma_attach_50831 dma_attach 6-7 50831 NULL
100193 +SetArea_50835 SetArea 4 50835 NULL nohasharray
100194 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
100195 +self_check_write_50856 self_check_write 5 50856 NULL
100196 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
100197 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
100198 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
100199 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
100200 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
100201 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
100202 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
100203 +sock_bindtodevice_50942 sock_bindtodevice 3 50942 NULL
100204 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
100205 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
100206 +timeout_write_50991 timeout_write 3 50991 NULL
100207 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL nohasharray
100208 +wm8903_gpio_direction_out_50995 wm8903_gpio_direction_out 2 50995 &wm831x_irq_map_50995
100209 +proc_write_51003 proc_write 3 51003 NULL
100210 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
100211 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
100212 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
100213 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
100214 +dump_midi_51040 dump_midi 3 51040 NULL
100215 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
100216 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
100217 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
100218 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
100219 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
100220 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
100221 +lm3533_als_get_current_51120 lm3533_als_get_current 2 51120 NULL
100222 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
100223 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
100224 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
100225 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
100226 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
100227 +snd_pcm_unlink_51210 snd_pcm_unlink 0 51210 NULL
100228 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
100229 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
100230 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
100231 +tipc_send_51238 tipc_send 4 51238 NULL
100232 +drm_property_create_51239 drm_property_create 4 51239 NULL
100233 +st_read_51251 st_read 3 51251 NULL
100234 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
100235 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
100236 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
100237 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
100238 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
100239 +fd_do_readv_51297 fd_do_readv 3 51297 NULL
100240 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
100241 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
100242 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
100243 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
100244 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
100245 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
100246 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
100247 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
100248 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
100249 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
100250 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
100251 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
100252 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
100253 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
100254 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
100255 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
100256 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
100257 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
100258 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
100259 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
100260 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
100261 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
100262 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
100263 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
100264 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
100265 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
100266 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
100267 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
100268 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
100269 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
100270 +sel_write_access_51704 sel_write_access 3 51704 NULL
100271 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
100272 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
100273 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
100274 +msg_set_51725 msg_set 3 51725 NULL
100275 +dbg_check_lpt_nodes_51727 dbg_check_lpt_nodes 0 51727 NULL
100276 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
100277 +get_user_pages_fast_51751 get_user_pages_fast 0 51751 NULL
100278 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
100279 +if_write_51756 if_write 3 51756 NULL
100280 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
100281 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
100282 +__fswab32_51781 __fswab32 0 51781 NULL
100283 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
100284 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
100285 +wm2000_write_51834 wm2000_write 2 51834 NULL
100286 +ioread32_51847 ioread32 0 51847 NULL nohasharray
100287 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
100288 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
100289 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
100290 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
100291 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
100292 +user_read_51881 user_read 3 51881 NULL
100293 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
100294 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
100295 +iio_read_first_n_sw_rb_51911 iio_read_first_n_sw_rb 2 51911 NULL
100296 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
100297 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
100298 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
100299 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
100300 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
100301 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
100302 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
100303 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
100304 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
100305 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
100306 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
100307 +rdmalt_52022 rdmalt 0 52022 NULL
100308 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
100309 +override_release_52032 override_release 2 52032 NULL
100310 +end_port_52042 end_port 0 52042 NULL
100311 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
100312 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
100313 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
100314 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
100315 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
100316 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
100317 +retry_count_read_52129 retry_count_read 3 52129 NULL
100318 +snd_pcm_channel_info_user_52135 snd_pcm_channel_info_user 0 52135 NULL
100319 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
100320 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
100321 +htable_size_52148 htable_size 0-1 52148 NULL
100322 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
100323 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
100324 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
100325 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
100326 +print_prefix_52176 print_prefix 0 52176 NULL
100327 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
100328 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
100329 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
100330 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
100331 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
100332 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
100333 +mpol_to_str_52293 mpol_to_str 2 52293 NULL
100334 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
100335 +read_file_reset_52310 read_file_reset 3 52310 NULL
100336 +ssd1307fb_write_52315 ssd1307fb_write 3 52315 NULL
100337 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
100338 +hwflags_read_52318 hwflags_read 3 52318 NULL
100339 +snd_pcm_hw_free_52327 snd_pcm_hw_free 0 52327 NULL
100340 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
100341 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
100342 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
100343 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
100344 +iwl_dump_fh_52371 iwl_dump_fh 0 52371 NULL
100345 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
100346 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
100347 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
100348 +pcf50633_reg_clear_bits_52407 pcf50633_reg_clear_bits 2 52407 NULL
100349 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
100350 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
100351 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
100352 +delay_status_52431 delay_status 5 52431 NULL
100353 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
100354 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
100355 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
100356 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
100357 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
100358 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
100359 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
100360 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
100361 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
100362 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
100363 +emit_code_52583 emit_code 0-3 52583 NULL
100364 +snd_pcm_sw_params_52594 snd_pcm_sw_params 0 52594 NULL
100365 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
100366 +ntfs_get_nr_significant_bytes_52688 ntfs_get_nr_significant_bytes 0 52688 NULL
100367 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
100368 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
100369 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
100370 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
100371 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
100372 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
100373 +alloc_extent_buffer_52824 alloc_extent_buffer 3 52824 NULL
100374 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
100375 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
100376 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
100377 +twlreg_write_52880 twlreg_write 3 52880 NULL
100378 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
100379 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
100380 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
100381 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
100382 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
100383 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
100384 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
100385 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
100386 +send_packet_52960 send_packet 4 52960 NULL
100387 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
100388 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 NULL
100389 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
100390 +num_node_state_52989 num_node_state 0 52989 NULL
100391 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
100392 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
100393 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
100394 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
100395 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
100396 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
100397 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
100398 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
100399 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
100400 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
100401 +verity_status_53120 verity_status 5 53120 NULL
100402 +line6_dumpreq_initbuf_53123 line6_dumpreq_initbuf 3 53123 NULL
100403 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
100404 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
100405 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
100406 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
100407 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
100408 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
100409 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
100410 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
100411 +lirc_buffer_init_53282 lirc_buffer_init 3-2 53282 NULL
100412 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
100413 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
100414 +vm_mmap_53339 vm_mmap 0 53339 NULL
100415 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
100416 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
100417 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
100418 +wm8996_gpio_set_53421 wm8996_gpio_set 2 53421 NULL
100419 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
100420 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
100421 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
100422 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
100423 +n2_run_53459 n2_run 3 53459 NULL
100424 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
100425 +wm831x_write_53469 wm831x_write 2 53469 NULL
100426 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
100427 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
100428 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
100429 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
100430 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
100431 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
100432 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
100433 +check_acl_53512 check_acl 0 53512 NULL
100434 +set_registers_53582 set_registers 3 53582 NULL
100435 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
100436 +__readw_53594 __readw 0 53594 NULL
100437 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1 53626 NULL
100438 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
100439 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
100440 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
100441 +_preload_range_53676 _preload_range 2-3 53676 NULL
100442 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
100443 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
100444 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 NULL nohasharray
100445 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 &igb_alloc_q_vector_53690
100446 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
100447 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
100448 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
100449 +wdm_write_53735 wdm_write 3 53735 NULL
100450 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
100451 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
100452 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
100453 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
100454 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
100455 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
100456 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
100457 +regmap_raw_write_53803 regmap_raw_write 4-2 53803 NULL
100458 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
100459 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
100460 +cpumask_next_zero_53835 cpumask_next_zero 1 53835 NULL
100461 +pms_read_53873 pms_read 3 53873 NULL
100462 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
100463 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL
100464 +proc_file_read_53905 proc_file_read 3 53905 NULL
100465 +azx_via_get_position_53916 azx_via_get_position 0 53916 NULL
100466 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
100467 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
100468 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
100469 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
100470 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
100471 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
100472 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
100473 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
100474 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
100475 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
100476 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
100477 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
100478 +_malloc_54077 _malloc 1 54077 NULL
100479 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
100480 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
100481 +create_xattr_54106 create_xattr 5 54106 NULL
100482 +strn_len_54122 strn_len 0 54122 NULL
100483 +isku_receive_54130 isku_receive 4 54130 NULL
100484 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
100485 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
100486 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
100487 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
100488 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
100489 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
100490 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
100491 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
100492 +reada_add_block_54247 reada_add_block 2 54247 NULL
100493 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
100494 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
100495 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
100496 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
100497 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
100498 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
100499 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
100500 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
100501 +sprintf_54306 sprintf 0 54306 NULL
100502 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
100503 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
100504 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
100505 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
100506 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
100507 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
100508 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
100509 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
100510 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
100511 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
100512 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
100513 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
100514 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
100515 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
100516 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
100517 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
100518 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
100519 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
100520 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL
100521 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
100522 +viacam_read_54526 viacam_read 3 54526 NULL
100523 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
100524 +setsockopt_54539 setsockopt 5 54539 NULL
100525 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
100526 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
100527 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
100528 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
100529 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
100530 +irq_of_parse_and_map_54646 irq_of_parse_and_map 0 54646 NULL
100531 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
100532 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
100533 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
100534 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
100535 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
100536 +evm_read_key_54674 evm_read_key 3 54674 NULL
100537 +resource_string_54699 resource_string 0 54699 NULL
100538 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
100539 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
100540 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
100541 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
100542 +kzalloc_54740 kzalloc 1 54740 NULL
100543 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
100544 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
100545 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
100546 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
100547 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
100548 +domain_init_54797 domain_init 2 54797 NULL
100549 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
100550 +nfsd_write_54809 nfsd_write 6 54809 NULL
100551 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
100552 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
100553 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
100554 +write_rio_54837 write_rio 3 54837 NULL
100555 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
100556 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
100557 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
100558 +printer_read_54851 printer_read 3 54851 NULL
100559 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
100560 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
100561 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
100562 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
100563 +lm3533_led_get_lv_reg_54900 lm3533_led_get_lv_reg 0-2 54900 NULL
100564 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
100565 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
100566 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
100567 +add_port_54941 add_port 2 54941 NULL
100568 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
100569 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
100570 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
100571 +c4_add_card_54968 c4_add_card 3 54968 NULL
100572 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
100573 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
100574 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
100575 +rds_ib_inc_copy_to_user_55007 rds_ib_inc_copy_to_user 3 55007 NULL
100576 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
100577 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
100578 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
100579 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
100580 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
100581 +snd_pcm_capture_hw_avail_55086 snd_pcm_capture_hw_avail 0 55086 NULL
100582 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
100583 +corrupt_data_55120 corrupt_data 0 55120 NULL
100584 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
100585 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
100586 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
100587 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
100588 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
100589 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
100590 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
100591 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
100592 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL nohasharray
100593 +pcf50633_gpio_set_55209 pcf50633_gpio_set 2 55209 &ht40allow_map_read_55209
100594 +ssd1307fb_write_cmd_array_55211 ssd1307fb_write_cmd_array 3 55211 NULL nohasharray
100595 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 &ssd1307fb_write_cmd_array_55211
100596 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
100597 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
100598 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
100599 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
100600 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
100601 +ptrace_request_55288 ptrace_request 3 55288 NULL
100602 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
100603 +rbd_create_rw_ops_55297 rbd_create_rw_ops 1 55297 NULL
100604 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
100605 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 NULL
100606 +vme_user_read_55338 vme_user_read 3 55338 NULL
100607 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
100608 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
100609 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
100610 +__send_to_port_55383 __send_to_port 3 55383 NULL
100611 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
100612 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
100613 +alloc_skb_55439 alloc_skb 1 55439 NULL
100614 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
100615 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
100616 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
100617 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
100618 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
100619 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
100620 +wm5100_gpio_direction_out_55497 wm5100_gpio_direction_out 2 55497 NULL
100621 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
100622 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
100623 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
100624 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
100625 +ea_get_55522 ea_get 0 55522 NULL
100626 +buffer_size_55534 buffer_size 0 55534 NULL
100627 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
100628 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
100629 +add_partition_55588 add_partition 2 55588 NULL
100630 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
100631 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
100632 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
100633 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
100634 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
100635 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
100636 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
100637 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
100638 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
100639 +read_oldmem_55658 read_oldmem 3 55658 NULL
100640 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
100641 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
100642 +get_info_55681 get_info 3 55681 NULL
100643 +arizona_gpio_direction_in_55690 arizona_gpio_direction_in 2 55690 NULL
100644 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
100645 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
100646 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
100647 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
100648 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 3-2 55738 NULL
100649 +set_local_name_55757 set_local_name 4 55757 NULL
100650 +btrfs_init_new_buffer_55761 btrfs_init_new_buffer 4 55761 NULL
100651 +strlen_55778 strlen 0 55778 NULL nohasharray
100652 +is_idx_node_in_tnc_55778 is_idx_node_in_tnc 0 55778 &strlen_55778
100653 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
100654 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
100655 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
100656 +btrfs_find_create_tree_block_55812 btrfs_find_create_tree_block 3 55812 NULL
100657 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
100658 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
100659 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
100660 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
100661 +hsc_write_55875 hsc_write 3 55875 NULL
100662 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
100663 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
100664 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
100665 +handle_response_55951 handle_response 5 55951 NULL
100666 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
100667 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
100668 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
100669 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
100670 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
100671 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
100672 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
100673 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
100674 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
100675 +map_addr_56144 map_addr 7 56144 NULL
100676 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
100677 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
100678 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
100679 +skb_headroom_56200 skb_headroom 0 56200 NULL
100680 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
100681 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
100682 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
100683 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
100684 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
100685 +scrub_setup_recheck_block_56245 scrub_setup_recheck_block 4-3 56245 NULL
100686 +fd_copyin_56247 fd_copyin 3 56247 NULL
100687 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
100688 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
100689 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
100690 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
100691 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
100692 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
100693 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
100694 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
100695 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
100696 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
100697 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
100698 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
100699 +tps80031_ext_power_req_config_56353 tps80031_ext_power_req_config 3-4-5 56353 NULL
100700 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
100701 +dev_read_56369 dev_read 3 56369 NULL
100702 +alloc_dummy_extent_buffer_56374 alloc_dummy_extent_buffer 2 56374 NULL
100703 +snd_pcm_common_ioctl1_56382 snd_pcm_common_ioctl1 0 56382 NULL
100704 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
100705 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
100706 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
100707 +store_msg_56417 store_msg 3 56417 NULL
100708 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
100709 +ec_dbgfs_cmd_read_56431 ec_dbgfs_cmd_read 3 56431 NULL
100710 +fl_create_56435 fl_create 5 56435 NULL
100711 +gnttab_map_56439 gnttab_map 2 56439 NULL
100712 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
100713 +set_connectable_56458 set_connectable 4 56458 NULL
100714 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
100715 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
100716 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
100717 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
100718 +ip_options_get_56538 ip_options_get 4 56538 NULL
100719 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
100720 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
100721 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
100722 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
100723 +event_filter_write_56609 event_filter_write 3 56609 NULL
100724 +gather_array_56641 gather_array 3 56641 NULL
100725 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
100726 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
100727 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
100728 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
100729 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
100730 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
100731 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
100732 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
100733 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
100734 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
100735 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
100736 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
100737 +do_syslog_56807 do_syslog 3 56807 NULL
100738 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
100739 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
100740 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
100741 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
100742 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
100743 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
100744 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
100745 +strcspn_56913 strcspn 0 56913 NULL
100746 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
100747 +check_header_56930 check_header 2 56930 NULL
100748 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
100749 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
100750 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
100751 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
100752 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
100753 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
100754 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
100755 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
100756 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
100757 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
100758 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
100759 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
100760 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
100761 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
100762 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
100763 +snd_pcm_hw_params_old_user_57108 snd_pcm_hw_params_old_user 0 57108 NULL
100764 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
100765 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
100766 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
100767 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
100768 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
100769 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
100770 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
100771 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
100772 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
100773 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
100774 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
100775 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
100776 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
100777 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
100778 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
100779 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
100780 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
100781 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
100782 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
100783 +fw_file_size_57307 fw_file_size 0 57307 NULL
100784 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
100785 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
100786 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
100787 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
100788 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
100789 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
100790 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
100791 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
100792 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
100793 +read_file_blob_57406 read_file_blob 3 57406 NULL
100794 +enclosure_register_57412 enclosure_register 3 57412 NULL
100795 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
100796 +wm831x_gpio_set_debounce_57428 wm831x_gpio_set_debounce 2 57428 NULL
100797 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
100798 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
100799 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
100800 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
100801 +ReadReg_57453 ReadReg 0 57453 NULL
100802 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
100803 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
100804 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
100805 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
100806 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
100807 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
100808 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
100809 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
100810 +skb_headlen_57501 skb_headlen 0 57501 NULL
100811 +copy_in_user_57502 copy_in_user 3 57502 NULL
100812 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
100813 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
100814 +init_tag_map_57515 init_tag_map 3 57515 NULL
100815 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
100816 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
100817 +inode_permission_57531 inode_permission 0 57531 NULL
100818 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
100819 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
100820 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
100821 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
100822 +lp8788_update_bits_57600 lp8788_update_bits 2 57600 NULL
100823 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
100824 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
100825 +tps65217_reg_write_57623 tps65217_reg_write 2 57623 NULL nohasharray
100826 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 &tps65217_reg_write_57623
100827 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
100828 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
100829 +mem_read_57631 mem_read 3 57631 NULL
100830 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
100831 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
100832 +r3964_write_57662 r3964_write 4 57662 NULL
100833 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
100834 +__lgwrite_57669 __lgwrite 4 57669 NULL
100835 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
100836 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
100837 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
100838 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
100839 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
100840 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
100841 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
100842 +ld2_57794 ld2 0 57794 NULL
100843 +ivtv_read_57796 ivtv_read 3 57796 NULL
100844 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
100845 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
100846 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
100847 +copy_to_user_57835 copy_to_user 3 57835 NULL
100848 +flash_read_57843 flash_read 3 57843 NULL
100849 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
100850 +ad5380_info_to_reg_57905 ad5380_info_to_reg 0 57905 NULL
100851 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
100852 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
100853 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
100854 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
100855 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
100856 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
100857 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
100858 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
100859 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
100860 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
100861 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
100862 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
100863 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
100864 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
100865 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
100866 +mc13783_write_58033 mc13783_write 2 58033 NULL
100867 +mce_async_out_58056 mce_async_out 3 58056 NULL
100868 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
100869 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
100870 +cm4040_write_58079 cm4040_write 3 58079 NULL
100871 +udi_log_event_58105 udi_log_event 3 58105 NULL
100872 +savemem_58129 savemem 3 58129 NULL
100873 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
100874 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
100875 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
100876 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
100877 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
100878 +btrfs_mksubvol_58240 btrfs_mksubvol 3 58240 NULL
100879 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
100880 +read_file_debug_58256 read_file_debug 3 58256 NULL
100881 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
100882 +profile_load_58267 profile_load 3 58267 NULL
100883 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
100884 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
100885 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
100886 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
100887 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
100888 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
100889 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
100890 +ieee80211_send_probe_req_58337 ieee80211_send_probe_req 4-6 58337 NULL
100891 +next_pidmap_58347 next_pidmap 2 58347 NULL
100892 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
100893 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
100894 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
100895 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
100896 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
100897 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
100898 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
100899 +capabilities_read_58457 capabilities_read 3 58457 NULL
100900 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
100901 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
100902 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
100903 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
100904 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
100905 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
100906 +wm831x_reg_write_58489 wm831x_reg_write 2 58489 NULL
100907 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
100908 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
100909 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
100910 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
100911 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
100912 +xip_file_read_58592 xip_file_read 3 58592 NULL
100913 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
100914 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
100915 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
100916 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
100917 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
100918 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
100919 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
100920 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
100921 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
100922 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
100923 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
100924 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
100925 +acpi_map_58725 acpi_map 1-2 58725 NULL
100926 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
100927 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
100928 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
100929 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
100930 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
100931 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
100932 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
100933 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
100934 +isku_sysfs_read_58806 isku_sysfs_read 6 58806 NULL
100935 +ep_read_58813 ep_read 3 58813 NULL
100936 +command_write_58841 command_write 3 58841 NULL
100937 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
100938 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
100939 +hw_write_58881 hw_write 2 58881 NULL
100940 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
100941 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
100942 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
100943 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
100944 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
100945 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
100946 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
100947 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
100948 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
100949 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
100950 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
100951 +ep_write_59008 ep_write 3 59008 NULL
100952 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
100953 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
100954 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
100955 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
100956 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
100957 +da9052_gpio_direction_input_59062 da9052_gpio_direction_input 2 59062 NULL
100958 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
100959 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
100960 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
100961 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
100962 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
100963 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
100964 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
100965 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
100966 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
100967 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
100968 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
100969 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
100970 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
100971 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
100972 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
100973 +dt3155_read_59226 dt3155_read 3 59226 NULL
100974 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
100975 +rbd_do_request_59239 rbd_do_request 6-7 59239 NULL
100976 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
100977 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
100978 +nla_len_59258 nla_len 0 59258 NULL
100979 +da9055_reg_update_59280 da9055_reg_update 2 59280 NULL
100980 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
100981 +fd_copyout_59323 fd_copyout 3 59323 NULL
100982 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
100983 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
100984 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 NULL
100985 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
100986 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
100987 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
100988 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
100989 +snd_pcm_tstamp_59431 snd_pcm_tstamp 0 59431 NULL
100990 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
100991 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
100992 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
100993 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
100994 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
100995 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
100996 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
100997 +rds_pin_pages_59507 rds_pin_pages 0 59507 NULL
100998 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
100999 +tunables_write_59563 tunables_write 3 59563 NULL
101000 +memdup_user_59590 memdup_user 2 59590 NULL
101001 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
101002 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
101003 +mtrr_write_59622 mtrr_write 3 59622 NULL
101004 +ip_vs_icmp_xmit_59624 ip_vs_icmp_xmit 4 59624 NULL
101005 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
101006 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
101007 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
101008 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
101009 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
101010 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
101011 +wm8400_write_59675 wm8400_write 2 59675 NULL
101012 +sriov_enable_59689 sriov_enable 2 59689 NULL
101013 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
101014 +snd_pcm_info_user_59711 snd_pcm_info_user 0 59711 NULL
101015 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
101016 +wm8996_gpio_direction_in_59739 wm8996_gpio_direction_in 2 59739 NULL
101017 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
101018 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
101019 +strnlen_59746 strnlen 0 59746 NULL
101020 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
101021 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
101022 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
101023 +sec_reg_update_59771 sec_reg_update 2 59771 NULL
101024 +venus_remove_59781 venus_remove 4 59781 NULL
101025 +xlog_do_recover_59789 xlog_do_recover 3 59789 NULL
101026 +ipw_write_59807 ipw_write 3 59807 NULL
101027 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
101028 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
101029 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
101030 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
101031 +fs64_to_cpu_59845 fs64_to_cpu 0 59845 NULL
101032 +tun_put_user_59849 tun_put_user 4 59849 NULL
101033 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
101034 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL
101035 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
101036 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
101037 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
101038 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 NULL nohasharray
101039 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 &compat_ipmi_ioctl_59956
101040 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
101041 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
101042 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
101043 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
101044 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
101045 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
101046 +register_device_60015 register_device 2-3 60015 NULL
101047 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
101048 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
101049 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
101050 +ceph_calc_raw_layout_60035 ceph_calc_raw_layout 4 60035 NULL
101051 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
101052 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
101053 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
101054 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
101055 +load_module_60056 load_module 2 60056 NULL nohasharray
101056 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 &load_module_60056
101057 +compat_writev_60063 compat_writev 3 60063 NULL
101058 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 8-6 60064 NULL
101059 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
101060 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
101061 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
101062 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
101063 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
101064 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
101065 +init_state_60165 init_state 2 60165 NULL
101066 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
101067 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
101068 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
101069 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
101070 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
101071 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
101072 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
101073 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
101074 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
101075 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL
101076 +lp8788_select_buck_vout_addr_60241 lp8788_select_buck_vout_addr 0 60241 NULL
101077 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
101078 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
101079 +printer_write_60276 printer_write 3 60276 NULL
101080 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
101081 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
101082 +getDataLength_60301 getDataLength 0 60301 NULL
101083 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
101084 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
101085 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
101086 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
101087 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
101088 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
101089 +driver_names_read_60399 driver_names_read 3 60399 NULL
101090 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
101091 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
101092 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
101093 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
101094 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
101095 +rx_data_60442 rx_data 4 60442 NULL
101096 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
101097 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
101098 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
101099 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
101100 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
101101 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
101102 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
101103 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
101104 +usb_control_msg_60624 usb_control_msg 0 60624 NULL
101105 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
101106 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
101107 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
101108 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
101109 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
101110 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
101111 +init_data_container_60709 init_data_container 1 60709 NULL
101112 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
101113 +raid_status_60755 raid_status 5 60755 NULL
101114 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
101115 +opticon_write_60775 opticon_write 4 60775 NULL
101116 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
101117 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
101118 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
101119 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
101120 +alloc_irq_from_60868 alloc_irq_from 1 60868 NULL
101121 +generic_writepages_60871 generic_writepages 0 60871 NULL
101122 +ubifs_read_one_lp_60882 ubifs_read_one_lp 0 60882 NULL
101123 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
101124 +wm8962_gpio_set_60894 wm8962_gpio_set 2 60894 NULL
101125 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
101126 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
101127 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
101128 +pti_char_write_60960 pti_char_write 3 60960 NULL
101129 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
101130 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
101131 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
101132 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
101133 +symtab_init_61050 symtab_init 2 61050 NULL
101134 +fuse_send_write_61053 fuse_send_write 0 61053 NULL
101135 +snd_pcm_pause_61054 snd_pcm_pause 0 61054 NULL
101136 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
101137 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
101138 +snd_pcm_update_hw_ptr0_61084 snd_pcm_update_hw_ptr0 0 61084 NULL
101139 +get_derived_key_61100 get_derived_key 4 61100 NULL
101140 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
101141 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
101142 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
101143 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
101144 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
101145 +__vmalloc_61168 __vmalloc 1 61168 NULL
101146 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
101147 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
101148 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
101149 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
101150 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
101151 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
101152 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
101153 +sys_add_key_61288 sys_add_key 4 61288 NULL
101154 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
101155 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
101156 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
101157 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
101158 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
101159 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
101160 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
101161 +change_xattr_61390 change_xattr 5 61390 NULL
101162 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
101163 +irq_create_of_mapping_61428 irq_create_of_mapping 0 61428 NULL
101164 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
101165 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
101166 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
101167 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
101168 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
101169 +mc13xxx_reg_write_61490 mc13xxx_reg_write 2 61490 NULL
101170 +erst_errno_61526 erst_errno 0 61526 NULL
101171 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
101172 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
101173 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
101174 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
101175 +seq_open_private_61589 seq_open_private 3 61589 NULL
101176 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
101177 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
101178 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
101179 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
101180 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
101181 +ieee80211_rx_bss_info_61630 ieee80211_rx_bss_info 3 61630 NULL
101182 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
101183 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
101184 +resize_stripes_61650 resize_stripes 2 61650 NULL
101185 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
101186 +insert_one_name_61668 insert_one_name 7 61668 NULL
101187 +snd_pcm_playback_avail_61671 snd_pcm_playback_avail 0 61671 NULL
101188 +lock_loop_61681 lock_loop 1 61681 NULL
101189 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
101190 +filter_read_61692 filter_read 3 61692 NULL
101191 +iov_length_61716 iov_length 0 61716 NULL
101192 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
101193 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
101194 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
101195 +gfs2_meta_wait_61773 gfs2_meta_wait 0 61773 NULL
101196 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
101197 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
101198 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
101199 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
101200 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
101201 +get_fw_name_61874 get_fw_name 3 61874 NULL
101202 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
101203 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
101204 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
101205 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
101206 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
101207 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
101208 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
101209 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
101210 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
101211 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
101212 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
101213 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
101214 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
101215 +cow_file_range_61979 cow_file_range 3 61979 NULL
101216 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
101217 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
101218 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
101219 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
101220 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
101221 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
101222 +do_pselect_62061 do_pselect 1 62061 NULL
101223 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2 62074 NULL
101224 +__next_gcwq_cpu_62078 __next_gcwq_cpu 1 62078 NULL
101225 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
101226 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
101227 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
101228 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
101229 +ql_status_62135 ql_status 5 62135 NULL
101230 +video_usercopy_62151 video_usercopy 2 62151 NULL
101231 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
101232 +_irq_to_addr_62183 _irq_to_addr 0-1 62183 NULL
101233 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
101234 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
101235 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
101236 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
101237 +allocate_partition_62245 allocate_partition 4 62245 NULL
101238 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
101239 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
101240 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
101241 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
101242 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
101243 +subseq_list_62332 subseq_list 3-0 62332 NULL
101244 +flash_write_62354 flash_write 3 62354 NULL
101245 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
101246 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
101247 +altera_irscan_62396 altera_irscan 2 62396 NULL
101248 +set_ssp_62411 set_ssp 4 62411 NULL
101249 +tscadc_writel_62426 tscadc_writel 2 62426 NULL
101250 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
101251 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
101252 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
101253 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
101254 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
101255 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
101256 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL
101257 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
101258 +debugfs_read_62535 debugfs_read 3 62535 NULL
101259 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
101260 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
101261 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
101262 +get_subdir_62581 get_subdir 3 62581 NULL
101263 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
101264 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
101265 +get_desc_base_62617 get_desc_base 0 62617 NULL
101266 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
101267 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
101268 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
101269 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
101270 +wm8994_gpio_direction_in_62649 wm8994_gpio_direction_in 2 62649 NULL
101271 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
101272 +write_62671 write 3 62671 NULL
101273 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
101274 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
101275 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
101276 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
101277 +rdm_62719 rdm 0 62719 NULL
101278 +key_replays_read_62746 key_replays_read 3 62746 NULL
101279 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
101280 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
101281 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
101282 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
101283 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
101284 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
101285 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
101286 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
101287 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
101288 +aoechr_write_62883 aoechr_write 3 62883 NULL nohasharray
101289 +em28xx_init_isoc_62883 em28xx_init_isoc 4 62883 &aoechr_write_62883
101290 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
101291 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
101292 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
101293 +getdqbuf_62908 getdqbuf 1 62908 NULL
101294 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
101295 +PTR_ERR_63033 PTR_ERR 0 63033 NULL nohasharray
101296 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 &PTR_ERR_63033
101297 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
101298 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
101299 +unlink1_63059 unlink1 3 63059 NULL
101300 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
101301 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
101302 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
101303 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
101304 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
101305 +snd_pcm_status_user_63140 snd_pcm_status_user 0 63140 NULL
101306 +ubifs_change_one_lp_63157 ubifs_change_one_lp 0 63157 NULL
101307 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
101308 +vme_master_read_63221 vme_master_read 0 63221 NULL
101309 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
101310 +ptp_read_63251 ptp_read 4 63251 NULL
101311 +ntfs_attr_can_be_non_resident_63267 ntfs_attr_can_be_non_resident 0 63267 NULL
101312 +raid5_resize_63306 raid5_resize 2 63306 NULL
101313 +proc_info_read_63344 proc_info_read 3 63344 NULL
101314 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
101315 +idmouse_read_63374 idmouse_read 3 63374 NULL
101316 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
101317 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
101318 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
101319 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
101320 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
101321 +kone_send_63435 kone_send 4 63435 NULL
101322 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
101323 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
101324 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
101325 +read_kcore_63488 read_kcore 3 63488 NULL
101326 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
101327 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
101328 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
101329 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
101330 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
101331 +kvm_write_guest_page_63555 kvm_write_guest_page 5 63555 &dbg_leb_write_63555
101332 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
101333 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
101334 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
101335 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
101336 +module_alloc_63630 module_alloc 1 63630 NULL
101337 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
101338 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
101339 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
101340 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
101341 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
101342 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
101343 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
101344 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
101345 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
101346 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
101347 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
101348 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
101349 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
101350 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
101351 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
101352 +snd_pcm_link_63772 snd_pcm_link 0 63772 NULL
101353 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
101354 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
101355 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
101356 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
101357 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
101358 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
101359 +sel_write_load_63830 sel_write_load 3 63830 NULL
101360 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
101361 +ieee80211_if_fmt_channel_type_63855 ieee80211_if_fmt_channel_type 3 63855 NULL
101362 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
101363 +divas_write_63901 divas_write 3 63901 NULL
101364 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
101365 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
101366 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
101367 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
101368 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
101369 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
101370 +__team_options_register_63941 __team_options_register 3 63941 NULL
101371 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
101372 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
101373 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
101374 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
101375 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
101376 +kmemdup_64015 kmemdup 2 64015 NULL
101377 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 NULL
101378 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
101379 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
101380 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
101381 +get_u8_64076 get_u8 0 64076 NULL
101382 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
101383 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
101384 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
101385 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
101386 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
101387 +init_bch_64130 init_bch 1-2 64130 NULL
101388 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
101389 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
101390 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
101391 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
101392 +read_pulse_64227 read_pulse 0-3 64227 NULL
101393 +header_len_64232 header_len 0 64232 NULL
101394 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
101395 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
101396 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
101397 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
101398 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
101399 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
101400 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
101401 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
101402 +ffz_64324 ffz 0 64324 NULL
101403 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
101404 +ts_write_64336 ts_write 3 64336 NULL
101405 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
101406 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
101407 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
101408 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
101409 +ilo_write_64378 ilo_write 3 64378 NULL
101410 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
101411 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
101412 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
101413 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
101414 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
101415 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
101416 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
101417 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
101418 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
101419 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL
101420 +ieee80211_ie_build_ht_cap_64443 ieee80211_ie_build_ht_cap 0 64443 NULL
101421 +cap_capable_64462 cap_capable 0 64462 NULL
101422 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
101423 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
101424 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
101425 +remove_uuid_64505 remove_uuid 4 64505 NULL
101426 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
101427 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
101428 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
101429 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
101430 +__spi_sync_64561 __spi_sync 0 64561 NULL
101431 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
101432 +fanotify_write_64623 fanotify_write 3 64623 NULL
101433 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
101434 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
101435 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
101436 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
101437 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
101438 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
101439 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
101440 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
101441 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
101442 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
101443 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
101444 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
101445 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
101446 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
101447 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
101448 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
101449 +twl6040_reg_write_64790 twl6040_reg_write 2 64790 NULL
101450 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
101451 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
101452 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
101453 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
101454 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
101455 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
101456 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
101457 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
101458 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
101459 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
101460 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
101461 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
101462 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
101463 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
101464 +pskb_pull_65005 pskb_pull 2 65005 NULL
101465 +unifi_write_65012 unifi_write 3 65012 NULL
101466 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
101467 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
101468 +insert_dent_65034 insert_dent 7 65034 NULL
101469 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
101470 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
101471 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
101472 +make_idx_node_65068 make_idx_node 0 65068 NULL
101473 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
101474 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
101475 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2 65076 NULL
101476 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
101477 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
101478 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
101479 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
101480 +print_endpoint_stat_65232 print_endpoint_stat 0-4-3 65232 NULL
101481 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
101482 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
101483 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
101484 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
101485 +get_unaligned_le16_65293 get_unaligned_le16 0 65293 NULL
101486 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
101487 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
101488 +get_var_len_65304 get_var_len 0 65304 NULL
101489 +unpack_array_65318 unpack_array 0 65318 NULL
101490 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
101491 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
101492 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
101493 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
101494 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
101495 +strchr_65372 strchr 0 65372 NULL
101496 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1 65397 NULL
101497 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
101498 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
101499 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
101500 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
101501 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
101502 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
101503 +pn533_init_target_frame_65438 pn533_init_target_frame 3 65438 NULL
101504 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
101505 +regmap_write_65478 regmap_write 2 65478 NULL
101506 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
101507 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
101508 +alloc_dr_65495 alloc_dr 2 65495 NULL
101509 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
101510 new file mode 100644
101511 index 0000000..9db0d0e
101512 --- /dev/null
101513 +++ b/tools/gcc/size_overflow_plugin.c
101514 @@ -0,0 +1,2114 @@
101515 +/*
101516 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
101517 + * Licensed under the GPL v2, or (at your option) v3
101518 + *
101519 + * Homepage:
101520 + * http://www.grsecurity.net/~ephox/overflow_plugin/
101521 + *
101522 + * Documentation:
101523 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
101524 + *
101525 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
101526 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
101527 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
101528 + *
101529 + * Usage:
101530 + * $ 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
101531 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
101532 + */
101533 +
101534 +#include "gcc-plugin.h"
101535 +#include "config.h"
101536 +#include "system.h"
101537 +#include "coretypes.h"
101538 +#include "tree.h"
101539 +#include "tree-pass.h"
101540 +#include "intl.h"
101541 +#include "plugin-version.h"
101542 +#include "tm.h"
101543 +#include "toplev.h"
101544 +#include "function.h"
101545 +#include "tree-flow.h"
101546 +#include "plugin.h"
101547 +#include "gimple.h"
101548 +#include "diagnostic.h"
101549 +#include "cfgloop.h"
101550 +
101551 +#if BUILDING_GCC_VERSION >= 4008
101552 +#define TODO_dump_func 0
101553 +#endif
101554 +
101555 +struct size_overflow_hash {
101556 + const struct size_overflow_hash * const next;
101557 + const char * const name;
101558 + const unsigned int param;
101559 +};
101560 +
101561 +#include "size_overflow_hash.h"
101562 +
101563 +enum mark {
101564 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
101565 +};
101566 +
101567 +enum err_code_conditions {
101568 + CAST_ONLY, FROM_CONST
101569 +};
101570 +
101571 +static unsigned int call_count = 0;
101572 +
101573 +#define __unused __attribute__((__unused__))
101574 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
101575 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
101576 +#define BEFORE_STMT true
101577 +#define AFTER_STMT false
101578 +#define CREATE_NEW_VAR NULL_TREE
101579 +#define CODES_LIMIT 32
101580 +#define MAX_PARAM 31
101581 +#define MY_STMT GF_PLF_1
101582 +#define NO_CAST_CHECK GF_PLF_2
101583 +#define FROM_ARG true
101584 +#define FROM_RET false
101585 +
101586 +#if BUILDING_GCC_VERSION == 4005
101587 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
101588 +#endif
101589 +
101590 +int plugin_is_GPL_compatible;
101591 +void debug_gimple_stmt(gimple gs);
101592 +
101593 +static tree expand(struct pointer_set_t *visited, tree lhs);
101594 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
101595 +static tree report_size_overflow_decl;
101596 +static const_tree const_char_ptr_type_node;
101597 +static unsigned int handle_function(void);
101598 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
101599 +static tree get_size_overflow_type(gimple stmt, const_tree node);
101600 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
101601 +static void print_missing_msg(tree func, unsigned int argnum);
101602 +
101603 +static struct plugin_info size_overflow_plugin_info = {
101604 + .version = "20130410beta",
101605 + .help = "no-size-overflow\tturn off size overflow checking\n",
101606 +};
101607 +
101608 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101609 +{
101610 + unsigned int arg_count;
101611 + enum tree_code code = TREE_CODE(*node);
101612 +
101613 + switch (code) {
101614 + case FUNCTION_DECL:
101615 + arg_count = type_num_arguments(TREE_TYPE(*node));
101616 + break;
101617 + case FUNCTION_TYPE:
101618 + case METHOD_TYPE:
101619 + arg_count = type_num_arguments(*node);
101620 + break;
101621 + default:
101622 + *no_add_attrs = true;
101623 + error("%s: %qE attribute only applies to functions", __func__, name);
101624 + return NULL_TREE;
101625 + }
101626 +
101627 + for (; args; args = TREE_CHAIN(args)) {
101628 + tree position = TREE_VALUE(args);
101629 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
101630 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
101631 + *no_add_attrs = true;
101632 + }
101633 + }
101634 + return NULL_TREE;
101635 +}
101636 +
101637 +static const char* get_asm_name(tree node)
101638 +{
101639 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
101640 +}
101641 +
101642 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101643 +{
101644 + unsigned int arg_count, arg_num;
101645 + enum tree_code code = TREE_CODE(*node);
101646 +
101647 + switch (code) {
101648 + case FUNCTION_DECL:
101649 + arg_count = type_num_arguments(TREE_TYPE(*node));
101650 + break;
101651 + case FUNCTION_TYPE:
101652 + case METHOD_TYPE:
101653 + arg_count = type_num_arguments(*node);
101654 + break;
101655 + case FIELD_DECL:
101656 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
101657 + if (arg_num != 0) {
101658 + *no_add_attrs = true;
101659 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
101660 + }
101661 + return NULL_TREE;
101662 + default:
101663 + *no_add_attrs = true;
101664 + error("%qE attribute only applies to functions", name);
101665 + return NULL_TREE;
101666 + }
101667 +
101668 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
101669 + return NULL_TREE;
101670 +
101671 + for (; args; args = TREE_CHAIN(args)) {
101672 + tree position = TREE_VALUE(args);
101673 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
101674 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
101675 + *no_add_attrs = true;
101676 + }
101677 + }
101678 + return NULL_TREE;
101679 +}
101680 +
101681 +static struct attribute_spec size_overflow_attr = {
101682 + .name = "size_overflow",
101683 + .min_length = 1,
101684 + .max_length = -1,
101685 + .decl_required = true,
101686 + .type_required = false,
101687 + .function_type_required = false,
101688 + .handler = handle_size_overflow_attribute,
101689 +#if BUILDING_GCC_VERSION >= 4007
101690 + .affects_type_identity = false
101691 +#endif
101692 +};
101693 +
101694 +static struct attribute_spec intentional_overflow_attr = {
101695 + .name = "intentional_overflow",
101696 + .min_length = 1,
101697 + .max_length = -1,
101698 + .decl_required = true,
101699 + .type_required = false,
101700 + .function_type_required = false,
101701 + .handler = handle_intentional_overflow_attribute,
101702 +#if BUILDING_GCC_VERSION >= 4007
101703 + .affects_type_identity = false
101704 +#endif
101705 +};
101706 +
101707 +static void register_attributes(void __unused *event_data, void __unused *data)
101708 +{
101709 + register_attribute(&size_overflow_attr);
101710 + register_attribute(&intentional_overflow_attr);
101711 +}
101712 +
101713 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
101714 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
101715 +{
101716 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
101717 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
101718 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
101719 +
101720 + unsigned int m = 0x57559429;
101721 + unsigned int n = 0x5052acdb;
101722 + const unsigned int *key4 = (const unsigned int *)key;
101723 + unsigned int h = len;
101724 + unsigned int k = len + seed + n;
101725 + unsigned long long p;
101726 +
101727 + while (len >= 8) {
101728 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
101729 + len -= 8;
101730 + }
101731 + if (len >= 4) {
101732 + cwmixb(key4[0]) key4 += 1;
101733 + len -= 4;
101734 + }
101735 + if (len)
101736 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
101737 + cwmixb(h ^ (k + n));
101738 + return k ^ h;
101739 +
101740 +#undef cwfold
101741 +#undef cwmixa
101742 +#undef cwmixb
101743 +}
101744 +
101745 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
101746 +{
101747 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
101748 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
101749 + return fn ^ codes;
101750 +}
101751 +
101752 +static inline tree get_original_function_decl(tree fndecl)
101753 +{
101754 + if (DECL_ABSTRACT_ORIGIN(fndecl))
101755 + return DECL_ABSTRACT_ORIGIN(fndecl);
101756 + return fndecl;
101757 +}
101758 +
101759 +static inline gimple get_def_stmt(const_tree node)
101760 +{
101761 + gcc_assert(node != NULL_TREE);
101762 + if (TREE_CODE(node) != SSA_NAME)
101763 + return NULL;
101764 + return SSA_NAME_DEF_STMT(node);
101765 +}
101766 +
101767 +static unsigned char get_tree_code(const_tree type)
101768 +{
101769 + switch (TREE_CODE(type)) {
101770 + case ARRAY_TYPE:
101771 + return 0;
101772 + case BOOLEAN_TYPE:
101773 + return 1;
101774 + case ENUMERAL_TYPE:
101775 + return 2;
101776 + case FUNCTION_TYPE:
101777 + return 3;
101778 + case INTEGER_TYPE:
101779 + return 4;
101780 + case POINTER_TYPE:
101781 + return 5;
101782 + case RECORD_TYPE:
101783 + return 6;
101784 + case UNION_TYPE:
101785 + return 7;
101786 + case VOID_TYPE:
101787 + return 8;
101788 + case REAL_TYPE:
101789 + return 9;
101790 + case VECTOR_TYPE:
101791 + return 10;
101792 + case REFERENCE_TYPE:
101793 + return 11;
101794 + case OFFSET_TYPE:
101795 + return 12;
101796 + case COMPLEX_TYPE:
101797 + return 13;
101798 + default:
101799 + debug_tree((tree)type);
101800 + gcc_unreachable();
101801 + }
101802 +}
101803 +
101804 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
101805 +{
101806 + gcc_assert(type != NULL_TREE);
101807 +
101808 + while (type && len < CODES_LIMIT) {
101809 + tree_codes[len] = get_tree_code(type);
101810 + len++;
101811 + type = TREE_TYPE(type);
101812 + }
101813 + return len;
101814 +}
101815 +
101816 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
101817 +{
101818 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
101819 + enum tree_code code = TREE_CODE(type);
101820 + size_t len = 0;
101821 +
101822 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
101823 +
101824 + arg = TYPE_ARG_TYPES(type);
101825 + // skip builtins __builtin_constant_p
101826 + if (!arg && DECL_BUILT_IN(fndecl))
101827 + return 0;
101828 +
101829 + if (TREE_CODE_CLASS(code) == tcc_type)
101830 + result = type;
101831 + else
101832 + result = DECL_RESULT(fndecl);
101833 +
101834 + gcc_assert(result != NULL_TREE);
101835 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
101836 +
101837 + if (arg == NULL_TREE) {
101838 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
101839 + arg_field = DECL_ARGUMENT_FLD(fndecl);
101840 + if (arg_field == NULL_TREE)
101841 + return 0;
101842 + arg = TREE_TYPE(arg_field);
101843 + len = add_type_codes(arg, tree_codes, len);
101844 + gcc_assert(len != 0);
101845 + return len;
101846 + }
101847 +
101848 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
101849 + while (arg && len < CODES_LIMIT) {
101850 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
101851 + arg = TREE_CHAIN(arg);
101852 + }
101853 +
101854 + gcc_assert(len != 0);
101855 + return len;
101856 +}
101857 +
101858 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
101859 +{
101860 + unsigned int hash;
101861 + const struct size_overflow_hash *entry;
101862 + unsigned char tree_codes[CODES_LIMIT];
101863 + size_t len;
101864 + const char *func_name;
101865 +
101866 + fndecl = get_original_function_decl(fndecl);
101867 + len = get_function_decl(fndecl, tree_codes);
101868 + if (len == 0)
101869 + return NULL;
101870 +
101871 + func_name = get_asm_name(fndecl);
101872 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
101873 +
101874 + entry = size_overflow_hash[hash];
101875 + while (entry) {
101876 + if (!strcmp(entry->name, func_name))
101877 + return entry;
101878 + entry = entry->next;
101879 + }
101880 +
101881 + return NULL;
101882 +}
101883 +
101884 +static bool is_bool(const_tree node)
101885 +{
101886 + const_tree type;
101887 +
101888 + if (node == NULL_TREE)
101889 + return false;
101890 +
101891 + type = TREE_TYPE(node);
101892 + if (!INTEGRAL_TYPE_P(type))
101893 + return false;
101894 + if (TREE_CODE(type) == BOOLEAN_TYPE)
101895 + return true;
101896 + if (TYPE_PRECISION(type) == 1)
101897 + return true;
101898 + return false;
101899 +}
101900 +
101901 +static bool skip_types(const_tree var)
101902 +{
101903 + tree type;
101904 +
101905 + if (is_gimple_constant(var))
101906 + return true;
101907 +
101908 + switch (TREE_CODE(var)) {
101909 + case ADDR_EXPR:
101910 +#if BUILDING_GCC_VERSION >= 4006
101911 + case MEM_REF:
101912 +#endif
101913 + case ARRAY_REF:
101914 + case BIT_FIELD_REF:
101915 + case INDIRECT_REF:
101916 + case TARGET_MEM_REF:
101917 + return true;
101918 + case PARM_DECL:
101919 + case VAR_DECL:
101920 + case COMPONENT_REF:
101921 + return false;
101922 + default:
101923 + break;
101924 + }
101925 +
101926 + gcc_assert(TREE_CODE(var) == SSA_NAME);
101927 +
101928 + type = TREE_TYPE(var);
101929 + switch (TREE_CODE(type)) {
101930 + case INTEGER_TYPE:
101931 + case ENUMERAL_TYPE:
101932 + return false;
101933 + case BOOLEAN_TYPE:
101934 + return is_bool(var);
101935 + default:
101936 + break;
101937 + }
101938 +
101939 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
101940 +
101941 + type = TREE_TYPE(type);
101942 + gcc_assert(type != NULL_TREE);
101943 + switch (TREE_CODE(type)) {
101944 + case RECORD_TYPE:
101945 + case POINTER_TYPE:
101946 + case ARRAY_TYPE:
101947 + return true;
101948 + case VOID_TYPE:
101949 + case INTEGER_TYPE:
101950 + case UNION_TYPE:
101951 + return false;
101952 + default:
101953 + break;
101954 + }
101955 +
101956 + debug_tree((tree)var);
101957 + gcc_unreachable();
101958 +}
101959 +
101960 +static unsigned int find_arg_number(const_tree arg, tree func)
101961 +{
101962 + tree var;
101963 + unsigned int argnum = 1;
101964 +
101965 + if (TREE_CODE(arg) == SSA_NAME)
101966 + arg = SSA_NAME_VAR(arg);
101967 +
101968 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
101969 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
101970 + continue;
101971 + if (!skip_types(var))
101972 + return argnum;
101973 + }
101974 +
101975 + return 0;
101976 +}
101977 +
101978 +static tree create_new_var(tree type)
101979 +{
101980 + tree new_var = create_tmp_var(type, "cicus");
101981 +
101982 +#if BUILDING_GCC_VERSION <= 4007
101983 + add_referenced_var(new_var);
101984 + mark_sym_for_renaming(new_var);
101985 +#endif
101986 + return new_var;
101987 +}
101988 +
101989 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
101990 +{
101991 + gimple assign;
101992 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101993 + tree type = TREE_TYPE(rhs1);
101994 + tree lhs = create_new_var(type);
101995 +
101996 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
101997 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
101998 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
101999 +
102000 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
102001 + update_stmt(assign);
102002 + gimple_set_plf(assign, MY_STMT, true);
102003 + return assign;
102004 +}
102005 +
102006 +static tree cast_a_tree(tree type, tree var)
102007 +{
102008 + gcc_assert(type != NULL_TREE);
102009 + gcc_assert(var != NULL_TREE);
102010 + gcc_assert(fold_convertible_p(type, var));
102011 +
102012 + return fold_convert(type, var);
102013 +}
102014 +
102015 +static tree get_lhs(const_gimple stmt)
102016 +{
102017 + switch (gimple_code(stmt)) {
102018 + case GIMPLE_ASSIGN:
102019 + return gimple_get_lhs(stmt);
102020 + case GIMPLE_PHI:
102021 + return gimple_phi_result(stmt);
102022 + case GIMPLE_CALL:
102023 + return gimple_call_lhs(stmt);
102024 + default:
102025 + return NULL_TREE;
102026 + }
102027 +}
102028 +
102029 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
102030 +{
102031 + const_gimple def_stmt = get_def_stmt(rhs);
102032 +
102033 + if (force)
102034 + return false;
102035 +
102036 + if (is_gimple_constant(rhs))
102037 + return false;
102038 +
102039 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
102040 + return false;
102041 +
102042 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
102043 + return false;
102044 +
102045 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
102046 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
102047 + return false;
102048 +
102049 + return true;
102050 +}
102051 +
102052 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
102053 +{
102054 + gimple assign, def_stmt;
102055 +
102056 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
102057 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
102058 + gcc_unreachable();
102059 +
102060 + def_stmt = get_def_stmt(rhs);
102061 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
102062 + return def_stmt;
102063 +
102064 + if (lhs == CREATE_NEW_VAR)
102065 + lhs = create_new_var(dst_type);
102066 +
102067 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
102068 +
102069 + if (!gsi_end_p(*gsi)) {
102070 + location_t loc = gimple_location(gsi_stmt(*gsi));
102071 + gimple_set_location(assign, loc);
102072 + }
102073 +
102074 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
102075 +
102076 + if (before)
102077 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
102078 + else
102079 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
102080 + update_stmt(assign);
102081 + gimple_set_plf(assign, MY_STMT, true);
102082 +
102083 + return assign;
102084 +}
102085 +
102086 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
102087 +{
102088 + gimple_stmt_iterator gsi;
102089 + tree lhs;
102090 + const_gimple new_stmt;
102091 +
102092 + if (rhs == NULL_TREE)
102093 + return NULL_TREE;
102094 +
102095 + gsi = gsi_for_stmt(stmt);
102096 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
102097 +
102098 + lhs = get_lhs(new_stmt);
102099 + gcc_assert(lhs != NULL_TREE);
102100 + return lhs;
102101 +}
102102 +
102103 +static tree cast_to_TI_type(gimple stmt, tree node)
102104 +{
102105 + gimple_stmt_iterator gsi;
102106 + gimple cast_stmt;
102107 + tree type = TREE_TYPE(node);
102108 +
102109 + if (types_compatible_p(type, intTI_type_node))
102110 + return node;
102111 +
102112 + gsi = gsi_for_stmt(stmt);
102113 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102114 + return gimple_get_lhs(cast_stmt);
102115 +}
102116 +
102117 +static void check_function_hash(const_gimple stmt)
102118 +{
102119 + tree func;
102120 + const struct size_overflow_hash *hash;
102121 +
102122 + if (gimple_code(stmt) != GIMPLE_CALL)
102123 + return;
102124 +
102125 + func = gimple_call_fndecl(stmt);
102126 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
102127 + if (func == NULL_TREE)
102128 + return;
102129 +
102130 + hash = get_function_hash(func);
102131 + if (!hash)
102132 + print_missing_msg(func, 0);
102133 +}
102134 +
102135 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
102136 +{
102137 + tree lhs, new_lhs;
102138 + gimple_stmt_iterator gsi;
102139 +
102140 + if (rhs1 == NULL_TREE) {
102141 + debug_gimple_stmt(oldstmt);
102142 + error("%s: rhs1 is NULL_TREE", __func__);
102143 + gcc_unreachable();
102144 + }
102145 +
102146 + switch (gimple_code(oldstmt)) {
102147 + case GIMPLE_ASM:
102148 + lhs = rhs1;
102149 + break;
102150 + case GIMPLE_CALL:
102151 + lhs = gimple_call_lhs(oldstmt);
102152 + break;
102153 + case GIMPLE_ASSIGN:
102154 + lhs = gimple_get_lhs(oldstmt);
102155 + break;
102156 + default:
102157 + debug_gimple_stmt(oldstmt);
102158 + gcc_unreachable();
102159 + }
102160 +
102161 + gsi = gsi_for_stmt(oldstmt);
102162 + pointer_set_insert(visited, oldstmt);
102163 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
102164 + basic_block next_bb, cur_bb;
102165 + const_edge e;
102166 +
102167 + gcc_assert(before == false);
102168 + gcc_assert(stmt_can_throw_internal(oldstmt));
102169 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
102170 + gcc_assert(!gsi_end_p(gsi));
102171 +
102172 + cur_bb = gimple_bb(oldstmt);
102173 + next_bb = cur_bb->next_bb;
102174 + e = find_edge(cur_bb, next_bb);
102175 + gcc_assert(e != NULL);
102176 + gcc_assert(e->flags & EDGE_FALLTHRU);
102177 +
102178 + gsi = gsi_after_labels(next_bb);
102179 + gcc_assert(!gsi_end_p(gsi));
102180 +
102181 + before = true;
102182 + oldstmt = gsi_stmt(gsi);
102183 + }
102184 +
102185 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
102186 + return new_lhs;
102187 +}
102188 +
102189 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
102190 +{
102191 + gimple stmt;
102192 + gimple_stmt_iterator gsi;
102193 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
102194 +
102195 + if (gimple_plf(oldstmt, MY_STMT))
102196 + return lhs;
102197 +
102198 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
102199 + rhs1 = gimple_assign_rhs1(oldstmt);
102200 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
102201 + }
102202 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
102203 + rhs2 = gimple_assign_rhs2(oldstmt);
102204 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
102205 + }
102206 +
102207 + stmt = gimple_copy(oldstmt);
102208 + gimple_set_location(stmt, gimple_location(oldstmt));
102209 + gimple_set_plf(stmt, MY_STMT, true);
102210 +
102211 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
102212 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
102213 +
102214 + size_overflow_type = get_size_overflow_type(oldstmt, node);
102215 +
102216 + new_var = create_new_var(size_overflow_type);
102217 + new_var = make_ssa_name(new_var, stmt);
102218 + gimple_set_lhs(stmt, new_var);
102219 +
102220 + if (rhs1 != NULL_TREE)
102221 + gimple_assign_set_rhs1(stmt, rhs1);
102222 +
102223 + if (rhs2 != NULL_TREE)
102224 + gimple_assign_set_rhs2(stmt, rhs2);
102225 +#if BUILDING_GCC_VERSION >= 4007
102226 + if (rhs3 != NULL_TREE)
102227 + gimple_assign_set_rhs3(stmt, rhs3);
102228 +#endif
102229 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
102230 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
102231 +
102232 + gsi = gsi_for_stmt(oldstmt);
102233 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
102234 + update_stmt(stmt);
102235 + pointer_set_insert(visited, oldstmt);
102236 + return gimple_get_lhs(stmt);
102237 +}
102238 +
102239 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
102240 +{
102241 + basic_block first_bb;
102242 + gimple assign;
102243 + gimple_stmt_iterator gsi;
102244 +
102245 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102246 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
102247 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
102248 +
102249 + gsi = gsi_start_bb(first_bb);
102250 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
102251 + return gimple_get_lhs(assign);
102252 +}
102253 +
102254 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
102255 +{
102256 + gimple_stmt_iterator gsi;
102257 + const_gimple assign;
102258 + gimple def_stmt = get_def_stmt(new_arg);
102259 +
102260 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
102261 + gsi = gsi_after_labels(gimple_bb(def_stmt));
102262 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
102263 + } else {
102264 + gsi = gsi_for_stmt(def_stmt);
102265 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
102266 + }
102267 +
102268 + return gimple_get_lhs(assign);
102269 +}
102270 +
102271 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
102272 +{
102273 + basic_block bb;
102274 + gimple_stmt_iterator gsi;
102275 + const_gimple assign, def_stmt;
102276 +
102277 + def_stmt = get_def_stmt(arg);
102278 + bb = gimple_bb(def_stmt);
102279 + gcc_assert(bb->index != 0);
102280 + gsi = gsi_after_labels(bb);
102281 +
102282 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
102283 + return gimple_get_lhs(assign);
102284 +}
102285 +
102286 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
102287 +{
102288 + tree size_overflow_type;
102289 + const_gimple def_stmt = get_def_stmt(arg);
102290 +
102291 + if (phi_ssa_name != NULL_TREE)
102292 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
102293 +
102294 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
102295 +
102296 + if (new_arg != NULL_TREE) {
102297 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
102298 + return use_phi_ssa_name(phi_ssa_name, new_arg);
102299 + }
102300 +
102301 + switch(gimple_code(def_stmt)) {
102302 + case GIMPLE_PHI:
102303 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
102304 + case GIMPLE_NOP:
102305 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
102306 + default:
102307 + debug_gimple_stmt((gimple)def_stmt);
102308 + gcc_unreachable();
102309 + }
102310 +}
102311 +
102312 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
102313 +{
102314 + basic_block bb;
102315 + gimple phi;
102316 + gimple_seq seq;
102317 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
102318 +
102319 + bb = gsi_bb(gsi);
102320 +
102321 + phi = create_phi_node(result, bb);
102322 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
102323 + seq = phi_nodes(bb);
102324 + gsi = gsi_last(seq);
102325 + gsi_remove(&gsi, false);
102326 +
102327 + gsi = gsi_for_stmt(oldstmt);
102328 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
102329 + gimple_set_bb(phi, bb);
102330 + gimple_set_plf(phi, MY_STMT, true);
102331 + return phi;
102332 +}
102333 +
102334 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
102335 +{
102336 + gimple new_phi = NULL;
102337 + gimple oldstmt = get_def_stmt(orig_result);
102338 + tree phi_ssa_name = NULL_TREE;
102339 + unsigned int i;
102340 +
102341 + pointer_set_insert(visited, oldstmt);
102342 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
102343 + tree arg, new_arg;
102344 +
102345 + arg = gimple_phi_arg_def(oldstmt, i);
102346 +
102347 + new_arg = expand(visited, arg);
102348 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
102349 + if (i == 0) {
102350 + phi_ssa_name = new_arg;
102351 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
102352 + }
102353 +
102354 + gcc_assert(new_phi != NULL);
102355 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
102356 + }
102357 +
102358 + gcc_assert(new_phi != NULL);
102359 + update_stmt(new_phi);
102360 + return gimple_phi_result(new_phi);
102361 +}
102362 +
102363 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
102364 +{
102365 + const_gimple assign;
102366 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102367 + tree origtype = TREE_TYPE(orig_rhs);
102368 +
102369 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
102370 +
102371 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102372 + return gimple_get_lhs(assign);
102373 +}
102374 +
102375 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
102376 +{
102377 + const_tree rhs1, lhs, rhs1_type, lhs_type;
102378 + enum machine_mode lhs_mode, rhs_mode;
102379 + gimple def_stmt = get_def_stmt(no_const_rhs);
102380 +
102381 + if (!gimple_assign_cast_p(def_stmt))
102382 + return false;
102383 +
102384 + rhs1 = gimple_assign_rhs1(def_stmt);
102385 + lhs = gimple_get_lhs(def_stmt);
102386 + rhs1_type = TREE_TYPE(rhs1);
102387 + lhs_type = TREE_TYPE(lhs);
102388 + rhs_mode = TYPE_MODE(rhs1_type);
102389 + lhs_mode = TYPE_MODE(lhs_type);
102390 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
102391 + return false;
102392 +
102393 + return true;
102394 +}
102395 +
102396 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
102397 +{
102398 + tree rhs1 = gimple_assign_rhs1(stmt);
102399 + tree lhs = gimple_get_lhs(stmt);
102400 + const_tree rhs1_type = TREE_TYPE(rhs1);
102401 + const_tree lhs_type = TREE_TYPE(lhs);
102402 +
102403 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
102404 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102405 +
102406 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
102407 +}
102408 +
102409 +static bool no_uses(tree node)
102410 +{
102411 + imm_use_iterator imm_iter;
102412 + use_operand_p use_p;
102413 +
102414 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
102415 + const_gimple use_stmt = USE_STMT(use_p);
102416 + if (use_stmt == NULL)
102417 + return true;
102418 + if (is_gimple_debug(use_stmt))
102419 + continue;
102420 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
102421 + continue;
102422 + return false;
102423 + }
102424 + return true;
102425 +}
102426 +
102427 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
102428 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
102429 +{
102430 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
102431 + gimple def_stmt = get_def_stmt(lhs);
102432 +
102433 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
102434 + return false;
102435 +
102436 + rhs1 = gimple_assign_rhs1(def_stmt);
102437 + rhs_type = TREE_TYPE(rhs1);
102438 + lhs_type = TREE_TYPE(lhs);
102439 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
102440 + return false;
102441 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
102442 + return false;
102443 +
102444 + def_stmt = get_def_stmt(rhs1);
102445 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
102446 + return false;
102447 +
102448 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
102449 + return false;
102450 +
102451 + rhs1 = gimple_assign_rhs1(def_stmt);
102452 + rhs2 = gimple_assign_rhs2(def_stmt);
102453 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
102454 + return false;
102455 +
102456 + if (is_gimple_constant(rhs2))
102457 + not_const_rhs = rhs1;
102458 + else
102459 + not_const_rhs = rhs2;
102460 +
102461 + return no_uses(not_const_rhs);
102462 +}
102463 +
102464 +static bool skip_lhs_cast_check(const_gimple stmt)
102465 +{
102466 + const_tree rhs = gimple_assign_rhs1(stmt);
102467 + const_gimple def_stmt = get_def_stmt(rhs);
102468 +
102469 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
102470 + if (gimple_code(def_stmt) == GIMPLE_ASM)
102471 + return true;
102472 +
102473 + if (is_const_plus_unsigned_signed_truncation(rhs))
102474 + return true;
102475 +
102476 + return false;
102477 +}
102478 +
102479 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
102480 +{
102481 + bool cast_lhs, cast_rhs;
102482 + tree lhs = gimple_get_lhs(stmt);
102483 + tree rhs = gimple_assign_rhs1(stmt);
102484 + const_tree lhs_type = TREE_TYPE(lhs);
102485 + const_tree rhs_type = TREE_TYPE(rhs);
102486 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
102487 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
102488 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
102489 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
102490 +
102491 + static bool check_lhs[3][4] = {
102492 + // ss su us uu
102493 + { false, true, true, false }, // lhs > rhs
102494 + { false, false, false, false }, // lhs = rhs
102495 + { true, true, true, true }, // lhs < rhs
102496 + };
102497 +
102498 + static bool check_rhs[3][4] = {
102499 + // ss su us uu
102500 + { true, false, true, true }, // lhs > rhs
102501 + { true, false, true, true }, // lhs = rhs
102502 + { true, false, true, true }, // lhs < rhs
102503 + };
102504 +
102505 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
102506 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
102507 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102508 +
102509 + if (lhs_size > rhs_size) {
102510 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102511 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102512 + } else if (lhs_size == rhs_size) {
102513 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102514 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102515 + } else {
102516 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102517 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102518 + }
102519 +
102520 + if (!cast_lhs && !cast_rhs)
102521 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102522 +
102523 + if (cast_lhs && !skip_lhs_cast_check(stmt))
102524 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
102525 +
102526 + if (cast_rhs)
102527 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
102528 +
102529 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102530 +}
102531 +
102532 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
102533 +{
102534 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
102535 +
102536 + if (gimple_plf(stmt, MY_STMT))
102537 + return lhs;
102538 +
102539 + rhs1 = gimple_assign_rhs1(stmt);
102540 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
102541 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102542 +
102543 + new_rhs1 = expand(visited, rhs1);
102544 +
102545 + if (new_rhs1 == NULL_TREE)
102546 + return create_cast_assign(visited, stmt);
102547 +
102548 + if (gimple_plf(stmt, NO_CAST_CHECK))
102549 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102550 +
102551 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
102552 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
102553 +
102554 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
102555 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
102556 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102557 + }
102558 +
102559 + if (!gimple_assign_cast_p(stmt))
102560 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102561 +
102562 + return create_cast_overflow_check(visited, new_rhs1, stmt);
102563 +}
102564 +
102565 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
102566 +{
102567 + tree rhs1, lhs = gimple_get_lhs(stmt);
102568 + gimple def_stmt = get_def_stmt(lhs);
102569 +
102570 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
102571 + rhs1 = gimple_assign_rhs1(def_stmt);
102572 +
102573 + if (is_gimple_constant(rhs1))
102574 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102575 +
102576 + switch (TREE_CODE(rhs1)) {
102577 + case SSA_NAME:
102578 + return handle_unary_rhs(visited, def_stmt);
102579 + case ARRAY_REF:
102580 + case BIT_FIELD_REF:
102581 + case ADDR_EXPR:
102582 + case COMPONENT_REF:
102583 + case INDIRECT_REF:
102584 +#if BUILDING_GCC_VERSION >= 4006
102585 + case MEM_REF:
102586 +#endif
102587 + case TARGET_MEM_REF:
102588 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102589 + case PARM_DECL:
102590 + case VAR_DECL:
102591 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102592 +
102593 + default:
102594 + debug_gimple_stmt(def_stmt);
102595 + debug_tree(rhs1);
102596 + gcc_unreachable();
102597 + }
102598 +}
102599 +
102600 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
102601 +{
102602 + gimple cond_stmt;
102603 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
102604 +
102605 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
102606 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
102607 + update_stmt(cond_stmt);
102608 +}
102609 +
102610 +static tree create_string_param(tree string)
102611 +{
102612 + tree i_type, a_type;
102613 + const int length = TREE_STRING_LENGTH(string);
102614 +
102615 + gcc_assert(length > 0);
102616 +
102617 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
102618 + a_type = build_array_type(char_type_node, i_type);
102619 +
102620 + TREE_TYPE(string) = a_type;
102621 + TREE_CONSTANT(string) = 1;
102622 + TREE_READONLY(string) = 1;
102623 +
102624 + return build1(ADDR_EXPR, ptr_type_node, string);
102625 +}
102626 +
102627 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
102628 +{
102629 + gimple func_stmt;
102630 + const_gimple def_stmt;
102631 + const_tree loc_line;
102632 + tree loc_file, ssa_name, current_func;
102633 + expanded_location xloc;
102634 + char *ssa_name_buf;
102635 + int len;
102636 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
102637 +
102638 + def_stmt = get_def_stmt(arg);
102639 + xloc = expand_location(gimple_location(def_stmt));
102640 +
102641 + if (!gimple_has_location(def_stmt)) {
102642 + xloc = expand_location(gimple_location(stmt));
102643 + if (!gimple_has_location(stmt))
102644 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
102645 + }
102646 +
102647 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
102648 +
102649 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
102650 + loc_file = create_string_param(loc_file);
102651 +
102652 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
102653 + current_func = create_string_param(current_func);
102654 +
102655 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
102656 + call_count++;
102657 + 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);
102658 + gcc_assert(len > 0);
102659 + ssa_name = build_string(len + 1, ssa_name_buf);
102660 + free(ssa_name_buf);
102661 + ssa_name = create_string_param(ssa_name);
102662 +
102663 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
102664 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
102665 +
102666 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
102667 +}
102668 +
102669 +static void __unused print_the_code_insertions(const_gimple stmt)
102670 +{
102671 + location_t loc = gimple_location(stmt);
102672 +
102673 + inform(loc, "Integer size_overflow check applied here.");
102674 +}
102675 +
102676 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
102677 +{
102678 + basic_block cond_bb, join_bb, bb_true;
102679 + edge e;
102680 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102681 +
102682 + cond_bb = gimple_bb(stmt);
102683 + if (before)
102684 + gsi_prev(&gsi);
102685 + if (gsi_end_p(gsi))
102686 + e = split_block_after_labels(cond_bb);
102687 + else
102688 + e = split_block(cond_bb, gsi_stmt(gsi));
102689 + cond_bb = e->src;
102690 + join_bb = e->dest;
102691 + e->flags = EDGE_FALSE_VALUE;
102692 + e->probability = REG_BR_PROB_BASE;
102693 +
102694 + bb_true = create_empty_bb(cond_bb);
102695 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
102696 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
102697 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
102698 +
102699 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
102700 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
102701 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
102702 +
102703 + if (current_loops != NULL) {
102704 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
102705 + add_bb_to_loop(bb_true, cond_bb->loop_father);
102706 + }
102707 +
102708 + insert_cond(cond_bb, arg, cond_code, type_value);
102709 + insert_cond_result(bb_true, stmt, arg, min);
102710 +
102711 +// print_the_code_insertions(stmt);
102712 +}
102713 +
102714 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
102715 +{
102716 + const_tree rhs_type = TREE_TYPE(rhs);
102717 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
102718 +
102719 + gcc_assert(rhs_type != NULL_TREE);
102720 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
102721 + return;
102722 +
102723 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
102724 +
102725 + if (is_const_plus_unsigned_signed_truncation(rhs))
102726 + return;
102727 +
102728 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
102729 + // typemax (-1) < typemin (0)
102730 + if (TREE_OVERFLOW(type_max))
102731 + return;
102732 +
102733 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
102734 +
102735 + cast_rhs_type = TREE_TYPE(cast_rhs);
102736 + type_max_type = TREE_TYPE(type_max);
102737 + type_min_type = TREE_TYPE(type_min);
102738 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
102739 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
102740 +
102741 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
102742 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
102743 +}
102744 +
102745 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
102746 +{
102747 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
102748 + return false;
102749 + if (!is_gimple_constant(rhs))
102750 + return false;
102751 + return true;
102752 +}
102753 +
102754 +static tree get_def_stmt_rhs(const_tree var)
102755 +{
102756 + tree rhs1, def_stmt_rhs1;
102757 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
102758 +
102759 + def_stmt = get_def_stmt(var);
102760 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
102761 +
102762 + rhs1 = gimple_assign_rhs1(def_stmt);
102763 + rhs1_def_stmt = get_def_stmt(rhs1);
102764 + if (!gimple_assign_cast_p(rhs1_def_stmt))
102765 + return rhs1;
102766 +
102767 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102768 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
102769 +
102770 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
102771 + case GIMPLE_CALL:
102772 + case GIMPLE_NOP:
102773 + case GIMPLE_ASM:
102774 + case GIMPLE_PHI:
102775 + return def_stmt_rhs1;
102776 + case GIMPLE_ASSIGN:
102777 + return rhs1;
102778 + default:
102779 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
102780 + gcc_unreachable();
102781 + }
102782 +}
102783 +
102784 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
102785 +{
102786 + tree new_rhs, orig_rhs;
102787 + void (*gimple_assign_set_rhs)(gimple, tree);
102788 + tree rhs1 = gimple_assign_rhs1(stmt);
102789 + tree rhs2 = gimple_assign_rhs2(stmt);
102790 + tree lhs = gimple_get_lhs(stmt);
102791 +
102792 + if (!check_overflow)
102793 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102794 +
102795 + if (change_rhs == NULL_TREE)
102796 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102797 +
102798 + if (new_rhs2 == NULL_TREE) {
102799 + orig_rhs = rhs1;
102800 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
102801 + } else {
102802 + orig_rhs = rhs2;
102803 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
102804 + }
102805 +
102806 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
102807 +
102808 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
102809 + gimple_assign_set_rhs(stmt, new_rhs);
102810 + update_stmt(stmt);
102811 +
102812 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102813 +}
102814 +
102815 +static bool is_subtraction_special(const_gimple stmt)
102816 +{
102817 + gimple rhs1_def_stmt, rhs2_def_stmt;
102818 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
102819 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
102820 + const_tree rhs1 = gimple_assign_rhs1(stmt);
102821 + const_tree rhs2 = gimple_assign_rhs2(stmt);
102822 +
102823 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
102824 + return false;
102825 +
102826 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
102827 +
102828 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
102829 + return false;
102830 +
102831 + rhs1_def_stmt = get_def_stmt(rhs1);
102832 + rhs2_def_stmt = get_def_stmt(rhs2);
102833 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
102834 + return false;
102835 +
102836 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102837 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
102838 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
102839 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
102840 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
102841 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
102842 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
102843 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
102844 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
102845 + return false;
102846 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
102847 + return false;
102848 +
102849 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
102850 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
102851 + return true;
102852 +}
102853 +
102854 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
102855 +{
102856 + tree new_rhs1, new_rhs2;
102857 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
102858 + gimple assign, stmt = get_def_stmt(lhs);
102859 + tree rhs1 = gimple_assign_rhs1(stmt);
102860 + tree rhs2 = gimple_assign_rhs2(stmt);
102861 +
102862 + if (!is_subtraction_special(stmt))
102863 + return NULL_TREE;
102864 +
102865 + new_rhs1 = expand(visited, rhs1);
102866 + new_rhs2 = expand(visited, rhs2);
102867 +
102868 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
102869 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
102870 +
102871 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
102872 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
102873 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
102874 + }
102875 +
102876 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
102877 + new_lhs = gimple_get_lhs(assign);
102878 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
102879 +
102880 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102881 +}
102882 +
102883 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
102884 +{
102885 + const_gimple def_stmt;
102886 +
102887 + if (TREE_CODE(rhs) != SSA_NAME)
102888 + return false;
102889 +
102890 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
102891 + return false;
102892 +
102893 + def_stmt = get_def_stmt(rhs);
102894 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
102895 + return false;
102896 +
102897 + return true;
102898 +}
102899 +
102900 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
102901 +{
102902 + tree rhs1, rhs2, new_lhs;
102903 + gimple def_stmt = get_def_stmt(lhs);
102904 + tree new_rhs1 = NULL_TREE;
102905 + tree new_rhs2 = NULL_TREE;
102906 +
102907 + rhs1 = gimple_assign_rhs1(def_stmt);
102908 + rhs2 = gimple_assign_rhs2(def_stmt);
102909 +
102910 + /* no DImode/TImode division in the 32/64 bit kernel */
102911 + switch (gimple_assign_rhs_code(def_stmt)) {
102912 + case RDIV_EXPR:
102913 + case TRUNC_DIV_EXPR:
102914 + case CEIL_DIV_EXPR:
102915 + case FLOOR_DIV_EXPR:
102916 + case ROUND_DIV_EXPR:
102917 + case TRUNC_MOD_EXPR:
102918 + case CEIL_MOD_EXPR:
102919 + case FLOOR_MOD_EXPR:
102920 + case ROUND_MOD_EXPR:
102921 + case EXACT_DIV_EXPR:
102922 + case POINTER_PLUS_EXPR:
102923 + case BIT_AND_EXPR:
102924 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102925 + default:
102926 + break;
102927 + }
102928 +
102929 + new_lhs = handle_integer_truncation(visited, lhs);
102930 + if (new_lhs != NULL_TREE)
102931 + return new_lhs;
102932 +
102933 + if (TREE_CODE(rhs1) == SSA_NAME)
102934 + new_rhs1 = expand(visited, rhs1);
102935 + if (TREE_CODE(rhs2) == SSA_NAME)
102936 + new_rhs2 = expand(visited, rhs2);
102937 +
102938 + if (is_a_neg_overflow(def_stmt, rhs2))
102939 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
102940 + if (is_a_neg_overflow(def_stmt, rhs1))
102941 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
102942 +
102943 +
102944 + if (is_a_constant_overflow(def_stmt, rhs2))
102945 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
102946 + if (is_a_constant_overflow(def_stmt, rhs1))
102947 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
102948 +
102949 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102950 +}
102951 +
102952 +#if BUILDING_GCC_VERSION >= 4007
102953 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
102954 +{
102955 + if (is_gimple_constant(rhs))
102956 + return cast_a_tree(size_overflow_type, rhs);
102957 + if (TREE_CODE(rhs) != SSA_NAME)
102958 + return NULL_TREE;
102959 + return expand(visited, rhs);
102960 +}
102961 +
102962 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
102963 +{
102964 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
102965 + gimple def_stmt = get_def_stmt(lhs);
102966 +
102967 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
102968 +
102969 + rhs1 = gimple_assign_rhs1(def_stmt);
102970 + rhs2 = gimple_assign_rhs2(def_stmt);
102971 + rhs3 = gimple_assign_rhs3(def_stmt);
102972 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
102973 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
102974 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
102975 +
102976 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
102977 +}
102978 +#endif
102979 +
102980 +static tree get_size_overflow_type(gimple stmt, const_tree node)
102981 +{
102982 + const_tree type;
102983 + tree new_type;
102984 +
102985 + gcc_assert(node != NULL_TREE);
102986 +
102987 + type = TREE_TYPE(node);
102988 +
102989 + if (gimple_plf(stmt, MY_STMT))
102990 + return TREE_TYPE(node);
102991 +
102992 + switch (TYPE_MODE(type)) {
102993 + case QImode:
102994 + new_type = intHI_type_node;
102995 + break;
102996 + case HImode:
102997 + new_type = intSI_type_node;
102998 + break;
102999 + case SImode:
103000 + new_type = intDI_type_node;
103001 + break;
103002 + case DImode:
103003 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
103004 + new_type = intDI_type_node;
103005 + else
103006 + new_type = intTI_type_node;
103007 + break;
103008 + default:
103009 + debug_tree((tree)node);
103010 + error("%s: unsupported gcc configuration.", __func__);
103011 + gcc_unreachable();
103012 + }
103013 +
103014 + if (TYPE_QUALS(type) != 0)
103015 + return build_qualified_type(new_type, TYPE_QUALS(type));
103016 + return new_type;
103017 +}
103018 +
103019 +static tree expand_visited(gimple def_stmt)
103020 +{
103021 + const_gimple next_stmt;
103022 + gimple_stmt_iterator gsi;
103023 + enum gimple_code code = gimple_code(def_stmt);
103024 +
103025 + if (code == GIMPLE_ASM)
103026 + return NULL_TREE;
103027 +
103028 + gsi = gsi_for_stmt(def_stmt);
103029 + gsi_next(&gsi);
103030 +
103031 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
103032 + return NULL_TREE;
103033 + gcc_assert(!gsi_end_p(gsi));
103034 + next_stmt = gsi_stmt(gsi);
103035 +
103036 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
103037 + return NULL_TREE;
103038 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
103039 +
103040 + return get_lhs(next_stmt);
103041 +}
103042 +
103043 +static tree expand(struct pointer_set_t *visited, tree lhs)
103044 +{
103045 + gimple def_stmt;
103046 +
103047 + if (skip_types(lhs))
103048 + return NULL_TREE;
103049 +
103050 + def_stmt = get_def_stmt(lhs);
103051 +
103052 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
103053 + return NULL_TREE;
103054 +
103055 + if (gimple_plf(def_stmt, MY_STMT))
103056 + return lhs;
103057 +
103058 + if (pointer_set_contains(visited, def_stmt))
103059 + return expand_visited(def_stmt);
103060 +
103061 + switch (gimple_code(def_stmt)) {
103062 + case GIMPLE_PHI:
103063 + return handle_phi(visited, lhs);
103064 + case GIMPLE_CALL:
103065 + case GIMPLE_ASM:
103066 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
103067 + case GIMPLE_ASSIGN:
103068 + switch (gimple_num_ops(def_stmt)) {
103069 + case 2:
103070 + return handle_unary_ops(visited, def_stmt);
103071 + case 3:
103072 + return handle_binary_ops(visited, lhs);
103073 +#if BUILDING_GCC_VERSION >= 4007
103074 + case 4:
103075 + return handle_ternary_ops(visited, lhs);
103076 +#endif
103077 + }
103078 + default:
103079 + debug_gimple_stmt(def_stmt);
103080 + error("%s: unknown gimple code", __func__);
103081 + gcc_unreachable();
103082 + }
103083 +}
103084 +
103085 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
103086 +{
103087 + const_gimple assign;
103088 + tree orig_type = TREE_TYPE(orig_node);
103089 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
103090 +
103091 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
103092 + return gimple_get_lhs(assign);
103093 +}
103094 +
103095 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
103096 +{
103097 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
103098 + update_stmt(stmt);
103099 +}
103100 +
103101 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
103102 +{
103103 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
103104 + update_stmt(stmt);
103105 +}
103106 +
103107 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
103108 +{
103109 + tree arg;
103110 + const_tree origarg;
103111 +
103112 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
103113 + return true;
103114 +
103115 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
103116 + while (origarg && *argnum) {
103117 + (*argnum)--;
103118 + origarg = TREE_CHAIN(origarg);
103119 + }
103120 +
103121 + gcc_assert(*argnum == 0);
103122 +
103123 + gcc_assert(origarg != NULL_TREE);
103124 + *argnum = 0;
103125 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
103126 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
103127 + return true;
103128 + return false;
103129 +}
103130 +
103131 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
103132 +{
103133 + gimple phi = get_def_stmt(result);
103134 + unsigned int i, n = gimple_phi_num_args(phi);
103135 +
103136 + if (!phi)
103137 + return MARK_NO;
103138 +
103139 + pointer_set_insert(visited, phi);
103140 + for (i = 0; i < n; i++) {
103141 + enum mark marked;
103142 + const_tree arg = gimple_phi_arg_def(phi, i);
103143 + marked = pre_expand(visited, search_err_code, arg);
103144 + if (marked != MARK_NO)
103145 + return marked;
103146 + }
103147 + return MARK_NO;
103148 +}
103149 +
103150 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
103151 +{
103152 + gimple def_stmt = get_def_stmt(lhs);
103153 + const_tree rhs;
103154 +
103155 + if (!def_stmt)
103156 + return MARK_NO;
103157 +
103158 + rhs = gimple_assign_rhs1(def_stmt);
103159 +
103160 + def_stmt = get_def_stmt(rhs);
103161 + if (is_gimple_constant(rhs))
103162 + search_err_code[FROM_CONST] = true;
103163 +
103164 + return pre_expand(visited, search_err_code, rhs);
103165 +}
103166 +
103167 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
103168 +{
103169 + gimple def_stmt = get_def_stmt(lhs);
103170 + const_tree rhs1, rhs2;
103171 + enum mark marked;
103172 +
103173 + if (!def_stmt)
103174 + return MARK_NO;
103175 +
103176 + search_err_code[CAST_ONLY] = false;
103177 +
103178 + rhs1 = gimple_assign_rhs1(def_stmt);
103179 + rhs2 = gimple_assign_rhs2(def_stmt);
103180 + marked = pre_expand(visited, search_err_code, rhs1);
103181 + if (marked != MARK_NO)
103182 + return marked;
103183 + return pre_expand(visited, search_err_code, rhs2);
103184 +}
103185 +
103186 +static const_tree search_field_decl(const_tree comp_ref)
103187 +{
103188 + const_tree field = NULL_TREE;
103189 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
103190 +
103191 + for (i = 0; i < len; i++) {
103192 + field = TREE_OPERAND(comp_ref, i);
103193 + if (TREE_CODE(field) == FIELD_DECL)
103194 + break;
103195 + }
103196 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
103197 + return field;
103198 +}
103199 +
103200 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
103201 +{
103202 + const_tree attr, p;
103203 +
103204 + // 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);
103205 + if (fndecl == NULL_TREE)
103206 + return MARK_NO;
103207 +
103208 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
103209 + if (!attr || !TREE_VALUE(attr))
103210 + return MARK_NO;
103211 +
103212 + p = TREE_VALUE(attr);
103213 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
103214 + return MARK_TURN_OFF;
103215 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
103216 + return MARK_NOT_INTENTIONAL;
103217 + if (argnum == 0) {
103218 + gcc_assert(current_function_decl == fndecl);
103219 + return MARK_NO;
103220 + }
103221 +
103222 + do {
103223 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
103224 + return MARK_YES;
103225 + p = TREE_CHAIN(p);
103226 + } while (p);
103227 +
103228 + return MARK_NO;
103229 +}
103230 +
103231 +static void print_missing_msg(tree func, unsigned int argnum)
103232 +{
103233 + unsigned int new_hash;
103234 + size_t len;
103235 + unsigned char tree_codes[CODES_LIMIT];
103236 + location_t loc;
103237 + const char *curfunc;
103238 +
103239 + func = get_original_function_decl(func);
103240 + loc = DECL_SOURCE_LOCATION(func);
103241 + curfunc = get_asm_name(func);
103242 +
103243 + len = get_function_decl(func, tree_codes);
103244 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
103245 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
103246 +}
103247 +
103248 +static unsigned int search_missing_attribute(const_tree arg)
103249 +{
103250 + unsigned int argnum;
103251 + const struct size_overflow_hash *hash;
103252 + const_tree type = TREE_TYPE(arg);
103253 + tree func = get_original_function_decl(current_function_decl);
103254 +
103255 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
103256 +
103257 + if (TREE_CODE(type) == POINTER_TYPE)
103258 + return 0;
103259 +
103260 + argnum = find_arg_number(arg, func);
103261 + if (argnum == 0)
103262 + return 0;
103263 +
103264 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
103265 + return argnum;
103266 +
103267 + hash = get_function_hash(func);
103268 + if (!hash || !(hash->param & (1U << argnum))) {
103269 + print_missing_msg(func, argnum);
103270 + return 0;
103271 + }
103272 + return argnum;
103273 +}
103274 +
103275 +static enum mark is_already_marked(const_tree lhs)
103276 +{
103277 + unsigned int argnum;
103278 + const_tree fndecl;
103279 +
103280 + argnum = search_missing_attribute(lhs);
103281 + fndecl = get_original_function_decl(current_function_decl);
103282 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
103283 + return MARK_YES;
103284 + return MARK_NO;
103285 +}
103286 +
103287 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
103288 +{
103289 + const_gimple def_stmt;
103290 +
103291 + if (skip_types(lhs))
103292 + return MARK_NO;
103293 +
103294 + if (TREE_CODE(lhs) == PARM_DECL)
103295 + return is_already_marked(lhs);
103296 +
103297 + if (TREE_CODE(lhs) == COMPONENT_REF) {
103298 + const_tree field, attr;
103299 +
103300 + field = search_field_decl(lhs);
103301 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
103302 + if (!attr || !TREE_VALUE(attr))
103303 + return MARK_NO;
103304 + return MARK_YES;
103305 + }
103306 +
103307 + def_stmt = get_def_stmt(lhs);
103308 +
103309 + if (!def_stmt)
103310 + return MARK_NO;
103311 +
103312 + if (pointer_set_contains(visited, def_stmt))
103313 + return MARK_NO;
103314 +
103315 + switch (gimple_code(def_stmt)) {
103316 + case GIMPLE_NOP:
103317 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
103318 + return is_already_marked(lhs);
103319 + return MARK_NO;
103320 + case GIMPLE_PHI:
103321 + return walk_phi(visited, search_err_code, lhs);
103322 + case GIMPLE_CALL:
103323 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
103324 + return MARK_TURN_OFF;
103325 + check_function_hash(def_stmt);
103326 + return MARK_NO;
103327 + case GIMPLE_ASM:
103328 + search_err_code[CAST_ONLY] = false;
103329 + return MARK_NO;
103330 + case GIMPLE_ASSIGN:
103331 + switch (gimple_num_ops(def_stmt)) {
103332 + case 2:
103333 + return walk_unary_ops(visited, search_err_code, lhs);
103334 + case 3:
103335 + return walk_binary_ops(visited, search_err_code, lhs);
103336 + }
103337 + default:
103338 + debug_gimple_stmt((gimple)def_stmt);
103339 + error("%s: unknown gimple code", __func__);
103340 + gcc_unreachable();
103341 + }
103342 +}
103343 +
103344 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
103345 +static bool skip_asm(const_tree arg)
103346 +{
103347 + gimple def_stmt = get_def_stmt(arg);
103348 +
103349 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
103350 + return false;
103351 +
103352 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
103353 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
103354 +}
103355 +
103356 +/*
103357 +0</MARK_YES: no dup, search attributes (so, int)
103358 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
103359 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
103360 +*/
103361 +
103362 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
103363 +{
103364 + struct pointer_set_t *visited;
103365 + enum mark is_marked, is_found;
103366 + location_t loc;
103367 + bool search_err_code[2] = {true, false};
103368 +
103369 + is_marked = mark_status(current_function_decl, 0);
103370 + if (is_marked == MARK_TURN_OFF)
103371 + return true;
103372 +
103373 + is_marked = mark_status(fndecl, argnum + 1);
103374 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
103375 + return true;
103376 +
103377 + visited = pointer_set_create();
103378 + is_found = pre_expand(visited, search_err_code, arg);
103379 + pointer_set_destroy(visited);
103380 +
103381 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
103382 + return true;
103383 +
103384 + if (where == FROM_ARG && skip_asm(arg))
103385 + return true;
103386 +
103387 + if (is_found == MARK_TURN_OFF)
103388 + return true;
103389 +
103390 + if ((is_found == MARK_YES && is_marked == MARK_YES))
103391 + return true;
103392 +
103393 + if (is_found == MARK_YES) {
103394 + loc = DECL_SOURCE_LOCATION(fndecl);
103395 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
103396 + return true;
103397 + }
103398 + return false;
103399 +}
103400 +
103401 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
103402 +{
103403 + struct pointer_set_t *visited;
103404 + tree arg, new_arg;
103405 + bool match;
103406 +
103407 + if (argnum == 0)
103408 + return;
103409 +
103410 + argnum--;
103411 +
103412 + match = get_function_arg(&argnum, fndecl);
103413 + if (!match)
103414 + return;
103415 + gcc_assert(gimple_call_num_args(stmt) > argnum);
103416 + arg = gimple_call_arg(stmt, argnum);
103417 + if (arg == NULL_TREE)
103418 + return;
103419 +
103420 + if (skip_types(arg))
103421 + return;
103422 +
103423 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
103424 + return;
103425 +
103426 + visited = pointer_set_create();
103427 + new_arg = expand(visited, arg);
103428 + pointer_set_destroy(visited);
103429 +
103430 + if (new_arg == NULL_TREE)
103431 + return;
103432 +
103433 + change_function_arg(stmt, arg, argnum, new_arg);
103434 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
103435 +}
103436 +
103437 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
103438 +{
103439 + tree p = TREE_VALUE(attr);
103440 + do {
103441 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
103442 + p = TREE_CHAIN(p);
103443 + } while (p);
103444 +}
103445 +
103446 +static void handle_function_by_hash(gimple stmt, tree fndecl)
103447 +{
103448 + unsigned int num;
103449 + const struct size_overflow_hash *hash;
103450 +
103451 + hash = get_function_hash(fndecl);
103452 + if (!hash)
103453 + return;
103454 +
103455 + for (num = 0; num <= MAX_PARAM; num++)
103456 + if (hash->param & (1U << num))
103457 + handle_function_arg(stmt, fndecl, num);
103458 +}
103459 +
103460 +static bool check_return_value(void)
103461 +{
103462 + const struct size_overflow_hash *hash;
103463 +
103464 + hash = get_function_hash(current_function_decl);
103465 + if (!hash || !(hash->param & 1U << 0))
103466 + return false;
103467 +
103468 + return true;
103469 +}
103470 +
103471 +static void handle_return_value(gimple ret_stmt)
103472 +{
103473 + struct pointer_set_t *visited;
103474 + tree ret, new_ret;
103475 +
103476 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
103477 + return;
103478 +
103479 + ret = gimple_return_retval(ret_stmt);
103480 +
103481 + if (skip_types(ret))
103482 + return;
103483 +
103484 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
103485 + return;
103486 +
103487 + visited = pointer_set_create();
103488 + new_ret = expand(visited, ret);
103489 + pointer_set_destroy(visited);
103490 +
103491 + change_function_return(ret_stmt, ret, new_ret);
103492 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
103493 +}
103494 +
103495 +static void set_plf_false(void)
103496 +{
103497 + basic_block bb;
103498 +
103499 + FOR_ALL_BB(bb) {
103500 + gimple_stmt_iterator si;
103501 +
103502 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
103503 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
103504 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
103505 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
103506 + }
103507 +}
103508 +
103509 +static unsigned int handle_function(void)
103510 +{
103511 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
103512 + bool check_ret;
103513 +
103514 + set_plf_false();
103515 +
103516 + check_ret = check_return_value();
103517 +
103518 + do {
103519 + gimple_stmt_iterator gsi;
103520 + next = bb->next_bb;
103521 +
103522 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103523 + tree fndecl, attr;
103524 + gimple stmt = gsi_stmt(gsi);
103525 +
103526 + if (check_ret)
103527 + handle_return_value(stmt);
103528 +
103529 + if (!(is_gimple_call(stmt)))
103530 + continue;
103531 + fndecl = gimple_call_fndecl(stmt);
103532 + if (fndecl == NULL_TREE)
103533 + continue;
103534 + if (gimple_call_num_args(stmt) == 0)
103535 + continue;
103536 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
103537 + if (!attr || !TREE_VALUE(attr))
103538 + handle_function_by_hash(stmt, fndecl);
103539 + else
103540 + handle_function_by_attribute(stmt, attr, fndecl);
103541 + gsi = gsi_for_stmt(stmt);
103542 + next = gimple_bb(stmt)->next_bb;
103543 + }
103544 + bb = next;
103545 + } while (bb);
103546 + return 0;
103547 +}
103548 +
103549 +static struct gimple_opt_pass size_overflow_pass = {
103550 + .pass = {
103551 + .type = GIMPLE_PASS,
103552 + .name = "size_overflow",
103553 +#if BUILDING_GCC_VERSION >= 4008
103554 + .optinfo_flags = OPTGROUP_NONE,
103555 +#endif
103556 + .gate = NULL,
103557 + .execute = handle_function,
103558 + .sub = NULL,
103559 + .next = NULL,
103560 + .static_pass_number = 0,
103561 + .tv_id = TV_NONE,
103562 + .properties_required = PROP_cfg,
103563 + .properties_provided = 0,
103564 + .properties_destroyed = 0,
103565 + .todo_flags_start = 0,
103566 + .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
103567 + }
103568 +};
103569 +
103570 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
103571 +{
103572 + tree fntype;
103573 +
103574 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
103575 +
103576 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
103577 + fntype = build_function_type_list(void_type_node,
103578 + const_char_ptr_type_node,
103579 + unsigned_type_node,
103580 + const_char_ptr_type_node,
103581 + const_char_ptr_type_node,
103582 + NULL_TREE);
103583 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
103584 +
103585 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
103586 + TREE_PUBLIC(report_size_overflow_decl) = 1;
103587 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
103588 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
103589 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
103590 +}
103591 +
103592 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103593 +{
103594 + int i;
103595 + const char * const plugin_name = plugin_info->base_name;
103596 + const int argc = plugin_info->argc;
103597 + const struct plugin_argument * const argv = plugin_info->argv;
103598 + bool enable = true;
103599 +
103600 + struct register_pass_info size_overflow_pass_info = {
103601 + .pass = &size_overflow_pass.pass,
103602 + .reference_pass_name = "ssa",
103603 + .ref_pass_instance_number = 1,
103604 + .pos_op = PASS_POS_INSERT_AFTER
103605 + };
103606 +
103607 + if (!plugin_default_version_check(version, &gcc_version)) {
103608 + error(G_("incompatible gcc/plugin versions"));
103609 + return 1;
103610 + }
103611 +
103612 + for (i = 0; i < argc; ++i) {
103613 + if (!strcmp(argv[i].key, "no-size-overflow")) {
103614 + enable = false;
103615 + continue;
103616 + }
103617 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103618 + }
103619 +
103620 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
103621 + if (enable) {
103622 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
103623 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
103624 + }
103625 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103626 +
103627 + return 0;
103628 +}
103629 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
103630 new file mode 100644
103631 index 0000000..ac2901e
103632 --- /dev/null
103633 +++ b/tools/gcc/stackleak_plugin.c
103634 @@ -0,0 +1,327 @@
103635 +/*
103636 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
103637 + * Licensed under the GPL v2
103638 + *
103639 + * Note: the choice of the license means that the compilation process is
103640 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103641 + * but for the kernel it doesn't matter since it doesn't link against
103642 + * any of the gcc libraries
103643 + *
103644 + * gcc plugin to help implement various PaX features
103645 + *
103646 + * - track lowest stack pointer
103647 + *
103648 + * TODO:
103649 + * - initialize all local variables
103650 + *
103651 + * BUGS:
103652 + * - none known
103653 + */
103654 +#include "gcc-plugin.h"
103655 +#include "config.h"
103656 +#include "system.h"
103657 +#include "coretypes.h"
103658 +#include "tree.h"
103659 +#include "tree-pass.h"
103660 +#include "flags.h"
103661 +#include "intl.h"
103662 +#include "toplev.h"
103663 +#include "plugin.h"
103664 +//#include "expr.h" where are you...
103665 +#include "diagnostic.h"
103666 +#include "plugin-version.h"
103667 +#include "tm.h"
103668 +#include "function.h"
103669 +#include "basic-block.h"
103670 +#include "gimple.h"
103671 +#include "rtl.h"
103672 +#include "emit-rtl.h"
103673 +
103674 +#if BUILDING_GCC_VERSION >= 4008
103675 +#define TODO_dump_func 0
103676 +#endif
103677 +
103678 +extern void print_gimple_stmt(FILE *, gimple, int, int);
103679 +
103680 +int plugin_is_GPL_compatible;
103681 +
103682 +static int track_frame_size = -1;
103683 +static const char track_function[] = "pax_track_stack";
103684 +static const char check_function[] = "pax_check_alloca";
103685 +static bool init_locals;
103686 +
103687 +static struct plugin_info stackleak_plugin_info = {
103688 + .version = "201302112000",
103689 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
103690 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
103691 +};
103692 +
103693 +static bool gate_stackleak_track_stack(void);
103694 +static unsigned int execute_stackleak_tree_instrument(void);
103695 +static unsigned int execute_stackleak_final(void);
103696 +
103697 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
103698 + .pass = {
103699 + .type = GIMPLE_PASS,
103700 + .name = "stackleak_tree_instrument",
103701 +#if BUILDING_GCC_VERSION >= 4008
103702 + .optinfo_flags = OPTGROUP_NONE,
103703 +#endif
103704 + .gate = gate_stackleak_track_stack,
103705 + .execute = execute_stackleak_tree_instrument,
103706 + .sub = NULL,
103707 + .next = NULL,
103708 + .static_pass_number = 0,
103709 + .tv_id = TV_NONE,
103710 + .properties_required = PROP_gimple_leh | PROP_cfg,
103711 + .properties_provided = 0,
103712 + .properties_destroyed = 0,
103713 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
103714 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
103715 + }
103716 +};
103717 +
103718 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
103719 + .pass = {
103720 + .type = RTL_PASS,
103721 + .name = "stackleak_final",
103722 +#if BUILDING_GCC_VERSION >= 4008
103723 + .optinfo_flags = OPTGROUP_NONE,
103724 +#endif
103725 + .gate = gate_stackleak_track_stack,
103726 + .execute = execute_stackleak_final,
103727 + .sub = NULL,
103728 + .next = NULL,
103729 + .static_pass_number = 0,
103730 + .tv_id = TV_NONE,
103731 + .properties_required = 0,
103732 + .properties_provided = 0,
103733 + .properties_destroyed = 0,
103734 + .todo_flags_start = 0,
103735 + .todo_flags_finish = TODO_dump_func
103736 + }
103737 +};
103738 +
103739 +static bool gate_stackleak_track_stack(void)
103740 +{
103741 + return track_frame_size >= 0;
103742 +}
103743 +
103744 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
103745 +{
103746 + gimple check_alloca;
103747 + tree fntype, fndecl, alloca_size;
103748 +
103749 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
103750 + fndecl = build_fn_decl(check_function, fntype);
103751 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103752 +
103753 + // insert call to void pax_check_alloca(unsigned long size)
103754 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
103755 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
103756 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
103757 +}
103758 +
103759 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
103760 +{
103761 + gimple track_stack;
103762 + tree fntype, fndecl;
103763 +
103764 + fntype = build_function_type_list(void_type_node, NULL_TREE);
103765 + fndecl = build_fn_decl(track_function, fntype);
103766 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103767 +
103768 + // insert call to void pax_track_stack(void)
103769 + track_stack = gimple_build_call(fndecl, 0);
103770 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
103771 +}
103772 +
103773 +#if BUILDING_GCC_VERSION == 4005
103774 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
103775 +{
103776 + tree fndecl;
103777 +
103778 + if (!is_gimple_call(stmt))
103779 + return false;
103780 + fndecl = gimple_call_fndecl(stmt);
103781 + if (!fndecl)
103782 + return false;
103783 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
103784 + return false;
103785 +// print_node(stderr, "pax", fndecl, 4);
103786 + return DECL_FUNCTION_CODE(fndecl) == code;
103787 +}
103788 +#endif
103789 +
103790 +static bool is_alloca(gimple stmt)
103791 +{
103792 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
103793 + return true;
103794 +
103795 +#if BUILDING_GCC_VERSION >= 4007
103796 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
103797 + return true;
103798 +#endif
103799 +
103800 + return false;
103801 +}
103802 +
103803 +static unsigned int execute_stackleak_tree_instrument(void)
103804 +{
103805 + basic_block bb, entry_bb;
103806 + bool prologue_instrumented = false, is_leaf = true;
103807 +
103808 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
103809 +
103810 + // 1. loop through BBs and GIMPLE statements
103811 + FOR_EACH_BB(bb) {
103812 + gimple_stmt_iterator gsi;
103813 +
103814 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103815 + gimple stmt;
103816 +
103817 + stmt = gsi_stmt(gsi);
103818 +
103819 + if (is_gimple_call(stmt))
103820 + is_leaf = false;
103821 +
103822 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
103823 + if (!is_alloca(stmt))
103824 + continue;
103825 +
103826 + // 2. insert stack overflow check before each __builtin_alloca call
103827 + stackleak_check_alloca(&gsi);
103828 +
103829 + // 3. insert track call after each __builtin_alloca call
103830 + stackleak_add_instrumentation(&gsi);
103831 + if (bb == entry_bb)
103832 + prologue_instrumented = true;
103833 + }
103834 + }
103835 +
103836 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
103837 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
103838 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
103839 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
103840 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
103841 + return 0;
103842 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
103843 + return 0;
103844 +
103845 + // 4. insert track call at the beginning
103846 + if (!prologue_instrumented) {
103847 + gimple_stmt_iterator gsi;
103848 +
103849 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103850 + if (dom_info_available_p(CDI_DOMINATORS))
103851 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103852 + gsi = gsi_start_bb(bb);
103853 + stackleak_add_instrumentation(&gsi);
103854 + }
103855 +
103856 + return 0;
103857 +}
103858 +
103859 +static unsigned int execute_stackleak_final(void)
103860 +{
103861 + rtx insn, next;
103862 +
103863 + if (cfun->calls_alloca)
103864 + return 0;
103865 +
103866 + // keep calls only if function frame is big enough
103867 + if (get_frame_size() >= track_frame_size)
103868 + return 0;
103869 +
103870 + // 1. find pax_track_stack calls
103871 + for (insn = get_insns(); insn; insn = next) {
103872 + // 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))
103873 + rtx body;
103874 +
103875 + next = NEXT_INSN(insn);
103876 + if (!CALL_P(insn))
103877 + continue;
103878 + body = PATTERN(insn);
103879 + if (GET_CODE(body) != CALL)
103880 + continue;
103881 + body = XEXP(body, 0);
103882 + if (GET_CODE(body) != MEM)
103883 + continue;
103884 + body = XEXP(body, 0);
103885 + if (GET_CODE(body) != SYMBOL_REF)
103886 + continue;
103887 + if (strcmp(XSTR(body, 0), track_function))
103888 + continue;
103889 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103890 + // 2. delete call
103891 + delete_insn_and_edges(insn);
103892 +#if BUILDING_GCC_VERSION >= 4007
103893 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
103894 + insn = next;
103895 + next = NEXT_INSN(insn);
103896 + delete_insn_and_edges(insn);
103897 + }
103898 +#endif
103899 + }
103900 +
103901 +// print_simple_rtl(stderr, get_insns());
103902 +// print_rtl(stderr, get_insns());
103903 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103904 +
103905 + return 0;
103906 +}
103907 +
103908 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103909 +{
103910 + const char * const plugin_name = plugin_info->base_name;
103911 + const int argc = plugin_info->argc;
103912 + const struct plugin_argument * const argv = plugin_info->argv;
103913 + int i;
103914 + struct register_pass_info stackleak_tree_instrument_pass_info = {
103915 + .pass = &stackleak_tree_instrument_pass.pass,
103916 +// .reference_pass_name = "tree_profile",
103917 + .reference_pass_name = "optimized",
103918 + .ref_pass_instance_number = 1,
103919 + .pos_op = PASS_POS_INSERT_BEFORE
103920 + };
103921 + struct register_pass_info stackleak_final_pass_info = {
103922 + .pass = &stackleak_final_rtl_opt_pass.pass,
103923 + .reference_pass_name = "final",
103924 + .ref_pass_instance_number = 1,
103925 + .pos_op = PASS_POS_INSERT_BEFORE
103926 + };
103927 +
103928 + if (!plugin_default_version_check(version, &gcc_version)) {
103929 + error(G_("incompatible gcc/plugin versions"));
103930 + return 1;
103931 + }
103932 +
103933 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
103934 +
103935 + for (i = 0; i < argc; ++i) {
103936 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
103937 + if (!argv[i].value) {
103938 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103939 + continue;
103940 + }
103941 + track_frame_size = atoi(argv[i].value);
103942 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
103943 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103944 + continue;
103945 + }
103946 + if (!strcmp(argv[i].key, "initialize-locals")) {
103947 + if (argv[i].value) {
103948 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103949 + continue;
103950 + }
103951 + init_locals = true;
103952 + continue;
103953 + }
103954 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103955 + }
103956 +
103957 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
103958 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
103959 +
103960 + return 0;
103961 +}
103962 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
103963 new file mode 100644
103964 index 0000000..5afca14
103965 --- /dev/null
103966 +++ b/tools/gcc/structleak_plugin.c
103967 @@ -0,0 +1,271 @@
103968 +/*
103969 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
103970 + * Licensed under the GPL v2
103971 + *
103972 + * Note: the choice of the license means that the compilation process is
103973 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103974 + * but for the kernel it doesn't matter since it doesn't link against
103975 + * any of the gcc libraries
103976 + *
103977 + * gcc plugin to forcibly initialize certain local variables that could
103978 + * otherwise leak kernel stack to userland if they aren't properly initialized
103979 + * by later code
103980 + *
103981 + * Homepage: http://pax.grsecurity.net/
103982 + *
103983 + * Usage:
103984 + * $ # for 4.5/4.6/C based 4.7
103985 + * $ 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
103986 + * $ # for C++ based 4.7/4.8+
103987 + * $ 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
103988 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
103989 + *
103990 + * TODO: eliminate redundant initializers
103991 + * increase type coverage
103992 + */
103993 +
103994 +#include "gcc-plugin.h"
103995 +#include "config.h"
103996 +#include "system.h"
103997 +#include "coretypes.h"
103998 +#include "tree.h"
103999 +#include "tree-pass.h"
104000 +#include "intl.h"
104001 +#include "plugin-version.h"
104002 +#include "tm.h"
104003 +#include "toplev.h"
104004 +#include "function.h"
104005 +#include "tree-flow.h"
104006 +#include "plugin.h"
104007 +#include "gimple.h"
104008 +#include "diagnostic.h"
104009 +#include "cfgloop.h"
104010 +#include "langhooks.h"
104011 +
104012 +#if BUILDING_GCC_VERSION >= 4008
104013 +#define TODO_dump_func 0
104014 +#endif
104015 +
104016 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
104017 +
104018 +// unused type flag in all versions 4.5-4.8
104019 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
104020 +
104021 +int plugin_is_GPL_compatible;
104022 +void debug_gimple_stmt(gimple gs);
104023 +
104024 +static struct plugin_info structleak_plugin_info = {
104025 + .version = "201304082245",
104026 + .help = "disable\tdo not activate plugin\n",
104027 +};
104028 +
104029 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
104030 +{
104031 + *no_add_attrs = true;
104032 +
104033 + // check for types? for now accept everything linux has to offer
104034 + if (TREE_CODE(*node) != FIELD_DECL)
104035 + return NULL_TREE;
104036 +
104037 + *no_add_attrs = false;
104038 + return NULL_TREE;
104039 +}
104040 +
104041 +static struct attribute_spec user_attr = {
104042 + .name = "user",
104043 + .min_length = 0,
104044 + .max_length = 0,
104045 + .decl_required = false,
104046 + .type_required = false,
104047 + .function_type_required = false,
104048 + .handler = handle_user_attribute,
104049 +#if BUILDING_GCC_VERSION >= 4007
104050 + .affects_type_identity = true
104051 +#endif
104052 +};
104053 +
104054 +static void register_attributes(void *event_data, void *data)
104055 +{
104056 + register_attribute(&user_attr);
104057 +// register_attribute(&force_attr);
104058 +}
104059 +
104060 +static tree get_field_type(tree field)
104061 +{
104062 + return strip_array_types(TREE_TYPE(field));
104063 +}
104064 +
104065 +static bool is_userspace_type(tree type)
104066 +{
104067 + tree field;
104068 +
104069 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
104070 + tree fieldtype = get_field_type(field);
104071 + enum tree_code code = TREE_CODE(fieldtype);
104072 +
104073 + if (code == RECORD_TYPE || code == UNION_TYPE)
104074 + if (is_userspace_type(fieldtype))
104075 + return true;
104076 +
104077 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
104078 + return true;
104079 + }
104080 + return false;
104081 +}
104082 +
104083 +static void finish_type(void *event_data, void *data)
104084 +{
104085 + tree type = (tree)event_data;
104086 +
104087 + if (TYPE_USERSPACE(type))
104088 + return;
104089 +
104090 + if (is_userspace_type(type))
104091 + TYPE_USERSPACE(type) = 1;
104092 +}
104093 +
104094 +static void initialize(tree var)
104095 +{
104096 + basic_block bb;
104097 + gimple_stmt_iterator gsi;
104098 + tree initializer;
104099 + gimple init_stmt;
104100 +
104101 + // this is the original entry bb before the forced split
104102 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
104103 +
104104 + // first check if the variable is already initialized, warn otherwise
104105 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
104106 + gimple stmt = gsi_stmt(gsi);
104107 + tree rhs1 = gimple_assign_rhs1(stmt);
104108 +
104109 + // we're looking for an assignment of a single rhs...
104110 + if (!gimple_assign_single_p(stmt))
104111 + continue;
104112 + // ... of a non-clobbering expression...
104113 + if (TREE_CLOBBER_P(rhs1))
104114 + continue;
104115 + // ... to our variable...
104116 + if (gimple_get_lhs(stmt) != var)
104117 + continue;
104118 + // if it's an initializer then we're good
104119 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
104120 + return;
104121 + }
104122 +
104123 + // build the initializer expression
104124 + initializer = make_node(CONSTRUCTOR);
104125 + TREE_TYPE(initializer) = TREE_TYPE(var);
104126 +
104127 + // build the initializer stmt
104128 + init_stmt = gimple_build_assign(var, initializer);
104129 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
104130 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
104131 + update_stmt(init_stmt);
104132 +}
104133 +
104134 +static unsigned int handle_function(void)
104135 +{
104136 + basic_block bb;
104137 + unsigned int ret = 0;
104138 + tree var;
104139 +
104140 +#if BUILDING_GCC_VERSION == 4005
104141 + tree vars;
104142 +#else
104143 + unsigned int i;
104144 +#endif
104145 +
104146 + // split the first bb where we can put the forced initializers
104147 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
104148 + if (dom_info_available_p(CDI_DOMINATORS))
104149 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
104150 +
104151 + // enumarate all local variables and forcibly initialize our targets
104152 +#if BUILDING_GCC_VERSION == 4005
104153 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
104154 + var = TREE_VALUE(vars);
104155 +#else
104156 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
104157 +#endif
104158 + tree type = TREE_TYPE(var);
104159 +
104160 + gcc_assert(DECL_P(var));
104161 + if (!auto_var_in_fn_p(var, current_function_decl))
104162 + continue;
104163 +
104164 + // only care about structure types
104165 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
104166 + continue;
104167 +
104168 + // if the type is of interest, examine the variable
104169 + if (TYPE_USERSPACE(type))
104170 + initialize(var);
104171 + }
104172 +
104173 + return ret;
104174 +}
104175 +
104176 +static struct gimple_opt_pass structleak_pass = {
104177 + .pass = {
104178 + .type = GIMPLE_PASS,
104179 + .name = "structleak",
104180 +#if BUILDING_GCC_VERSION >= 4008
104181 + .optinfo_flags = OPTGROUP_NONE,
104182 +#endif
104183 + .gate = NULL,
104184 + .execute = handle_function,
104185 + .sub = NULL,
104186 + .next = NULL,
104187 + .static_pass_number = 0,
104188 + .tv_id = TV_NONE,
104189 + .properties_required = PROP_cfg,
104190 + .properties_provided = 0,
104191 + .properties_destroyed = 0,
104192 + .todo_flags_start = 0,
104193 + .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
104194 + }
104195 +};
104196 +
104197 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
104198 +{
104199 + int i;
104200 + const char * const plugin_name = plugin_info->base_name;
104201 + const int argc = plugin_info->argc;
104202 + const struct plugin_argument * const argv = plugin_info->argv;
104203 + bool enable = true;
104204 +
104205 + struct register_pass_info structleak_pass_info = {
104206 + .pass = &structleak_pass.pass,
104207 + .reference_pass_name = "ssa",
104208 + .ref_pass_instance_number = 1,
104209 + .pos_op = PASS_POS_INSERT_AFTER
104210 + };
104211 +
104212 + if (!plugin_default_version_check(version, &gcc_version)) {
104213 + error(G_("incompatible gcc/plugin versions"));
104214 + return 1;
104215 + }
104216 +
104217 + if (strcmp(lang_hooks.name, "GNU C")) {
104218 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
104219 + enable = false;
104220 + }
104221 +
104222 + for (i = 0; i < argc; ++i) {
104223 + if (!strcmp(argv[i].key, "disable")) {
104224 + enable = false;
104225 + continue;
104226 + }
104227 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104228 + }
104229 +
104230 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
104231 + if (enable) {
104232 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
104233 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
104234 + }
104235 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
104236 +
104237 + return 0;
104238 +}
104239 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
104240 index 6789d78..4afd019e 100644
104241 --- a/tools/perf/util/include/asm/alternative-asm.h
104242 +++ b/tools/perf/util/include/asm/alternative-asm.h
104243 @@ -5,4 +5,7 @@
104244
104245 #define altinstruction_entry #
104246
104247 + .macro pax_force_retaddr rip=0, reload=0
104248 + .endm
104249 +
104250 #endif
104251 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
104252 index 96b919d..c49bb74 100644
104253 --- a/tools/perf/util/include/linux/compiler.h
104254 +++ b/tools/perf/util/include/linux/compiler.h
104255 @@ -18,4 +18,12 @@
104256 #define __force
104257 #endif
104258
104259 +#ifndef __size_overflow
104260 +# define __size_overflow(...)
104261 +#endif
104262 +
104263 +#ifndef __intentional_overflow
104264 +# define __intentional_overflow(...)
104265 +#endif
104266 +
104267 #endif
104268 diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
104269 index cfb7e4d..52058f0 100644
104270 --- a/virt/kvm/ioapic.c
104271 +++ b/virt/kvm/ioapic.c
104272 @@ -73,9 +73,12 @@ static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic,
104273 u32 redir_index = (ioapic->ioregsel - 0x10) >> 1;
104274 u64 redir_content;
104275
104276 - ASSERT(redir_index < IOAPIC_NUM_PINS);
104277 + if (redir_index < IOAPIC_NUM_PINS)
104278 + redir_content =
104279 + ioapic->redirtbl[redir_index].bits;
104280 + else
104281 + redir_content = ~0ULL;
104282
104283 - redir_content = ioapic->redirtbl[redir_index].bits;
104284 result = (ioapic->ioregsel & 0x1) ?
104285 (redir_content >> 32) & 0xffffffff :
104286 redir_content & 0xffffffff;
104287 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
104288 index 1cd693a..f4a7b20 100644
104289 --- a/virt/kvm/kvm_main.c
104290 +++ b/virt/kvm/kvm_main.c
104291 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
104292
104293 static cpumask_var_t cpus_hardware_enabled;
104294 static int kvm_usage_count = 0;
104295 -static atomic_t hardware_enable_failed;
104296 +static atomic_unchecked_t hardware_enable_failed;
104297
104298 struct kmem_cache *kvm_vcpu_cache;
104299 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
104300
104301 -static __read_mostly struct preempt_ops kvm_preempt_ops;
104302 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
104303 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
104304 +static struct preempt_ops kvm_preempt_ops = {
104305 + .sched_in = kvm_sched_in,
104306 + .sched_out = kvm_sched_out,
104307 +};
104308
104309 struct dentry *kvm_debugfs_dir;
104310
104311 @@ -731,7 +736,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
104312 /* We can read the guest memory with __xxx_user() later on. */
104313 if (user_alloc &&
104314 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
104315 - !access_ok(VERIFY_WRITE,
104316 + !__access_ok(VERIFY_WRITE,
104317 (void __user *)(unsigned long)mem->userspace_addr,
104318 mem->memory_size)))
104319 goto out;
104320 @@ -1783,7 +1788,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
104321 return 0;
104322 }
104323
104324 -static struct file_operations kvm_vcpu_fops = {
104325 +static file_operations_no_const kvm_vcpu_fops __read_only = {
104326 .release = kvm_vcpu_release,
104327 .unlocked_ioctl = kvm_vcpu_ioctl,
104328 #ifdef CONFIG_COMPAT
104329 @@ -2304,7 +2309,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
104330 return 0;
104331 }
104332
104333 -static struct file_operations kvm_vm_fops = {
104334 +static file_operations_no_const kvm_vm_fops __read_only = {
104335 .release = kvm_vm_release,
104336 .unlocked_ioctl = kvm_vm_ioctl,
104337 #ifdef CONFIG_COMPAT
104338 @@ -2402,7 +2407,7 @@ out:
104339 return r;
104340 }
104341
104342 -static struct file_operations kvm_chardev_ops = {
104343 +static file_operations_no_const kvm_chardev_ops __read_only = {
104344 .unlocked_ioctl = kvm_dev_ioctl,
104345 .compat_ioctl = kvm_dev_ioctl,
104346 .llseek = noop_llseek,
104347 @@ -2428,7 +2433,7 @@ static void hardware_enable_nolock(void *junk)
104348
104349 if (r) {
104350 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
104351 - atomic_inc(&hardware_enable_failed);
104352 + atomic_inc_unchecked(&hardware_enable_failed);
104353 printk(KERN_INFO "kvm: enabling virtualization on "
104354 "CPU%d failed\n", cpu);
104355 }
104356 @@ -2482,10 +2487,10 @@ static int hardware_enable_all(void)
104357
104358 kvm_usage_count++;
104359 if (kvm_usage_count == 1) {
104360 - atomic_set(&hardware_enable_failed, 0);
104361 + atomic_set_unchecked(&hardware_enable_failed, 0);
104362 on_each_cpu(hardware_enable_nolock, NULL, 1);
104363
104364 - if (atomic_read(&hardware_enable_failed)) {
104365 + if (atomic_read_unchecked(&hardware_enable_failed)) {
104366 hardware_disable_all_nolock();
104367 r = -EBUSY;
104368 }
104369 @@ -2843,7 +2848,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
104370 kvm_arch_vcpu_put(vcpu);
104371 }
104372
104373 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104374 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104375 struct module *module)
104376 {
104377 int r;
104378 @@ -2879,7 +2884,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104379 if (!vcpu_align)
104380 vcpu_align = __alignof__(struct kvm_vcpu);
104381 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
104382 - 0, NULL);
104383 + SLAB_USERCOPY, NULL);
104384 if (!kvm_vcpu_cache) {
104385 r = -ENOMEM;
104386 goto out_free_3;
104387 @@ -2889,9 +2894,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104388 if (r)
104389 goto out_free;
104390
104391 + pax_open_kernel();
104392 kvm_chardev_ops.owner = module;
104393 kvm_vm_fops.owner = module;
104394 kvm_vcpu_fops.owner = module;
104395 + pax_close_kernel();
104396
104397 r = misc_register(&kvm_dev);
104398 if (r) {
104399 @@ -2901,9 +2908,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104400
104401 register_syscore_ops(&kvm_syscore_ops);
104402
104403 - kvm_preempt_ops.sched_in = kvm_sched_in;
104404 - kvm_preempt_ops.sched_out = kvm_sched_out;
104405 -
104406 r = kvm_init_debug();
104407 if (r) {
104408 printk(KERN_ERR "kvm: create debugfs files failed\n");